readImageDICOMFileSeries() reports 'filepath is undefined' on browser console

I’m new to Javascript and ITK. I started by cloning the ITK-JS repository, and am working thru the examples.

My objective – from my browser, to read all of the images in a directory (an MR series) into a single ITK image (3D volume).

I started with the ‘webpack’ example in the ITK-JS example – got that working in my browser.

I then: 1. Changed the index.html to enable multiple for the <input type='file'> element. I confirmed that worked properly by writing the contents of the FileList object to the html element, and got that working with the ‘readFile()’; then 2. Replaced the ‘readFile(null, files[0])’ with ‘readImageDICOMFileSeries(null, files)’.

When I run the code with the ‘readImageDICOMFileSeries()’ I get the console message: “TypeError: filePath is undefined”. (NOTE: If I use ‘readImageDicomFileSeries(null, files[0])’ that does not give an error).

I have tried several variants, but always seem to get the same error. Here is my current code:

  //
  //  read the images
  // return readFile(null, files[0])  // -- this line works
  return readImageDICOMFileSeries(null, files)  // the causes TypeError: filePath is undefined 
      .then((worker)=>{
              const {image}=worker;
              let mFile = JSON.stringify(image) ;
              alert(mFile)
              console.log(image);
      })
      .catch(error=>{
              console.error(error);
              alert(error.message);
      })

What am I doing wrong?

Thanks in advance for your help.

Doug

Hi Doug,

This example may be a helpful reference:

Worth verifying – the import statement is importing itk/readImageDICOMFileSeries instead of itk/readImageFile.

Hope this helps,
Matt

1 Like