what is the correct way of loading a nifti image with vtk.js ?

i didnt find much documentation on ITKImageReader and this piece of code i improvised keeps giving me an “Invalid or missing input” error

const niftiReader = vtkITKImageReader.newInstance()
const image = niftiReader.getOutputData(0)

const marchingCubes = ImageMarchingCubes.newInstance()

You will also need to run await niftiReader.parseAsArrayBuffer(fileAsArrayBuffer), and then call getOutputData.

what does fileAsArrayBuffer represent ? sorry if its a dumb sounding question im pretty new to vtk.js

fileAsArrayBuffer represents the file contents as an ArrayBuffer. For instance, if you have an <input type="file">, you select your file, then convert it to an array buffer via await file.arrayBuffer().

oooh so ITKReader is supposed to be used with a browser, i thought it read files from the local directory like the rest of the readers. thanks alot for clarifying.

1 Like