Hi all,
I am trying to unzip a file with CT series in it and I can only display one image. When I try passing multiple images, it fails.
I am using itk.js 13.1.1. This is the error:
message: “FS error” stack: “<generic error, no stack>”
I am also a beginner with JS… Here’s my code. Thank you in advance!
const promises = [];
var list = zip.folder("mydata/original").file(/^CT/);
console.log(list.length); // prints 97
console.log(list[0]); // shows me correct data
promises.push(zip.file(list[0].name).async("blob"));
promises.push(zip.file(list[1].name).async("blob"));
Promise.all(promises)
.then(function (data) {
console.log("data.length = " + data.length); // data.length = 2
return readImageDICOMFileSeries( data)
.then(function ({ image, webWorker }) {
console.log("3 - in itk stuff");
webWorker.terminate();
showImage(image);
})
.catch(console.log);
})
.catch(console.log);
The readImageDICOMFileSeries expects an Array or FileList of File objects instead of Blob objects. A File object can be constructured from a Blob object with its constructor:
HI @matt.mccormick
Thank you for the information. I have solved it in a different way, but I will keep this in mind when the developments evolves.
I have another question. How to load RT Struct files with contours into ITK js or VTK js?
vtk.js/Sources/Common/DataModel/ITKHelper seems to be only for images.
thank you @matt.mccormick
that might be too advanced for now.
What I have done is saving a poly data with vtkXMLPolyDataWriter in c++, and now I am trying to load that file using:
import vtkITKPolyDataReader from ‘vtk.js/Sources/IO/Misc/ITKPolyDataReader’;
import readPolyDataArrayBuffer from ‘itk/readPolyDataArrayBuffer’;
However, I cannot find any example of how to load such a file.
I am trying:
const polyReader = vtkITKPolyDataReader.newInstance();
polyReader.setReadPolyDataArrayBufferFromITK(file);
but I get a dependency error asking the 2nd import (above).
I am trying to use this but without success. I still dont understand JS that well, so I cannot really understand the arguments necessary for the function and how to get the polydata into a list. I am trying the following, without success:
promises.push(polyReader.setUrl(file.name)
.then(() => {
var polydata = reader.getOutput();
polyList.push(polyData);
})
As for the other ITK things, I have little clue how useful will this be. I still have much to learn about js.
Best,
Lonewolf
---- EDIT:
I added a proper catch() and I see the reader is getting a url to the file, instead of the file that is in memory, extracted from the zip. Coming from c++ it’s always straightforward to see the functions signatures and types. Not here…I look at the API and it tells me nothing. Any chance for any typescript compatibility? that would make it easier for a noob like me