How to convert DICOM file series to nrrd

Hello guys. I am a beginner. I use itk.js in front-end(JavaScript).
I can read DICOM files in my program the problem is that i don’t know how to convert it to nrrd.
Currently It’s an array that i made with readImageDICOMFileSeries function.
Thank you for your help.

Does this post help you? If not, @matt.mccormick might want to pitch in.

I read the article already, unfortunately It’s not enough because I have to do the conversion and anonymization fully on the frontend.

Hi @nyuszi ,

You can convert to a NRRD with writeImageArrayBuffer. Use the .nrrd extension in the fileName.

Thanks for your answer @matt.mccormick!

I got some new problems,
when i try to use the following line:
nrrdFile = writeImageArrayBuffer(null, false,image,“filename.nrrd”,“nrrd”);

I got this error:
“WorkerGlobalScope.importScripts: Failed to load worker script at …/ImageIOs/itkNrrdImageIOJSBindingWasm.js (nsresult = 0x804b001d)”

My second question is how can i parse a dicom series? If I interpret this correctly writeImageArrayBuffer only parses a slice of that image.

Hi @matt.mccormick,
Do you have any suggestions with my problem?

Hi @nyuszi ,

Instead, try:

{ arrayBuffer, webWorker } = await writeImageArrayBuffer(null, false, image, "filename.nrrd")
webWorker.terminate()

Note:

  • The return type of the function is an object with the two noted members.
  • The function returns a Promise – you need to await it.
  • nrrd is not a valid / supported mime type.
  • You will want to terminate the web worker if you are not going to use it further.

My second question is how can i parse a dicom series? I

See readImageDICOMFileSeries.

1 Like