I am referring this example. It is on vanilla javascript.
Imported everything to as an angular provider service in angular 7.3.8 with AMI version 0.32.0 (three 0.99.0).
Using the same test examples as in the link above. Original scan with segmentation map is getting loaded but the class color is not loaded.
Please refer the code below to understand the changes:
loadAMIFile()
Not loading files using loader.load() as in original version but only parsing as loader.load() is not handling non-Dicom files properly. Hence, getting the required data to pass to loader.parse() from files using the below script.
loadAMIFile(files) {
const ext = files[0].name.split('.').pop();
this.readAsDataURL(files[0]).then((dataUrl) => {
this.readAsArrayBuffer(files[0]).then((arrayBuffer) => {
const resp = {
buffer: arrayBuffer,
extension: ext,
filename: files[0].name,
gzcompressed: null,
pathname: "",
query: "",
url: dataUrl + '?filename=' + files[0].name
};
that.amiProvider.toParse(resp);
}).catch(error => {
console.log('oops... something went wrong...');
console.log(error);
});
}).catch(error => {
console.log('oops... something went wrong...');
console.log(error);
});
}
amiProvider.toParse()
Here the data gets parsed and loaded by calling handleSeries().
For simplicity, I am loading the same file twice, whereas in reality, first, the original scan will get loaded and on user request, it's segmentation map should get loaded. In this case, I am loading the labelmap file but it does not show respective class colors. Everything else is as similar as in the jsfiddle link.
toParse(toBeParsedDict) {
this.loader = new this.LoadersVolume(this.threeD);
const toBeParsedDictArr = [toBeParsedDict, toBeParsedDict];
const promises = [];
const that = this;
toBeParsedDictArr.forEach(toBeParsedDict_ => {
// To avoid shallow copy.
const copied = {...toBeParsedDict_};
promises.push(that.loader.parse(copied));
});
Promise.all(promises).then(data => {
console.log(data);
this.handleSeries(data);
}).catch(err => console.log(err));
I have also tried with vanilla js (copying entire project from the link above to local system) and the same issue occurred there as well.
Does anyone face such issue before?
NOTE: Original fiddle version has used AMI 0.0.17 ( ThreeJS 86) which is not working at all locally i.e. not loading test files at all. So both versions have been modified. Is there any problem with the version of the modules I am using.
Okay, So after 1 month of headache and testing all AMI versions, got to know that in the angular environment only AMI 0.0.17 is giving a color map.
Though It does not support MGZ/MGH files, I angularised and integrated MGH parser from the latest AMI (AMI 0.32.0) into my project to have support for MGZ/MGH file parsing.
Now it works like a charm.
ami.component.ts
ami.provider.ts
mghParser.helper.ts
volumeParser.helper.ts
And a little bit change in parse() of AMI 0.0.17 library to accommodate MGH parser. In the future, with the support of the latest AMI with color map integrated properly, the code will work without the need for any change in the library again.