'How to Convert Dicom file url into filelist
Dicom Url is in the viewFile variable, when i pass it into the LoaddicomImages function it gives error only data of type filelist needs to be passed into the function. I cannot change the filelist type of the argument of the function because it is mandatory to keep the type filelist.
export class ViewerComponent implements OnInit {
@ViewChild(DICOMViewerComponent, { static: true }) viewPort: DICOMViewerComponent;
viewFile: any;
constructor(private router: Router)
{
this.viewFile = this.router.getCurrentNavigation().extras.state['item'];
console.log(this.viewFile);
}
ngOnInit() {
cornerstoneWADOImageLoader.external.cornerstone = cornerstone; // inicializa WADO Image loader
// configura codecs e web workers
cornerstoneWADOImageLoader.webWorkerManager.initialize({
webWorkerPath: './assets/cornerstone/webworkers/cornerstoneWADOImageLoaderWebWorker.js',
taskConfiguration: {
'decodeTask': {
codecsPath: '../codecs/cornerstoneWADOImageLoaderCodecs.js'
}
}
});
this.loadDICOMImages(this.viewFile)
}
/**
* Load selected DICOM images
*
* @param files list of selected dicom files
*/
loadDICOMImages(files : FileList) {
console.log(files)
if (files && files.length > 0) {
let imageList = [];
const fileList:Array<File> = Array.from(files);
fileList.sort((a,b) => {
if ( a.name > b.name ) return 1;
if ( b.name > a.name ) return -1;
return 0;
})
cornerstoneWADOImageLoader.wadouri.fileManager.purge();
// cornerstoneWADOImageLoader.wadouri.dataSetCacheManager.purge();
// loop thru the File list and build a list of wadouri imageIds (dicomfile:)
for (let i = 0; i < fileList.length; i++) {
const dicomFile: File = fileList[i];
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(dicomFile);
imageList.push(imageId);
}
this.viewPort.resetAllTools();
// now load all Images, using their wadouri
this.viewPort.loadStudyImages(imageList);
} else alert('Choose DICOM images to display.');
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
