# How to convert DICOM file series to nrrd

**URL:** https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561
**Category:** Beginner Questions
**Tags:** javascript
**Created:** [November 8, 2021, 1:28pm UTC](https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561 "2021-11-08T13:28:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![nyuszi](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@nyuszi](https://discourse.itk.org/u/nyuszi)
#### Post date: [November 8, 2021, 1:28pm UTC](https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561/1 "2021-11-08T13:28:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [November 8, 2021, 2:50pm UTC](https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561/2 "2021-11-08T14:50:53Z")

</div>

Does [this post](https://discourse.itk.org/t/how-to-create-an-itk-js-image-object/1163/3) help you? If not, @matt.mccormick might want to pitch in.

---

<div class="post-metadata">

### Author: ![nyuszi](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@nyuszi](https://discourse.itk.org/u/nyuszi)
#### Post date: [November 9, 2021, 8:49am UTC](https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561/3 "2021-11-09T08:49:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [November 12, 2021, 3:07pm UTC](https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561/4 "2021-11-12T15:07:37Z")

</div>

Hi @nyuszi ,

You can convert to a NRRD with [`writeImageArrayBuffer`](https://insightsoftwareconsortium.github.io/itk-wasm/api/browser_io.html#writeImageArrayBuffer-webWorker-Worker-null-useCompression-boolean-image-Image-fileName-string-mimeType-string-Promise-lt-webWorker-Worker-arrayBuffer-ArrayBuffer-gt). Use the `.nrrd` extension in the `fileName`.

---

<div class="post-metadata">

### Author: ![nyuszi](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@nyuszi](https://discourse.itk.org/u/nyuszi)
#### Post date: [November 15, 2021, 10:41am UTC](https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561/5 "2021-11-15T10:41:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![nyuszi](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@nyuszi](https://discourse.itk.org/u/nyuszi)
#### Post date: [January 4, 2022, 9:55pm UTC](https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561/6 "2022-01-04T21:55:52Z")

</div>

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

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [January 20, 2022, 9:51pm UTC](https://discourse.itk.org/t/how-to-convert-dicom-file-series-to-nrrd/4561/7 "2022-01-20T21:51:46Z")

</div>

Hi @nyuszi ,

> [@nyuszi](#):
>
> when i try to use the following line:  
> nrrdFile = writeImageArrayBuffer(null, false,image,“filename.nrrd”,“nrrd”);

Instead, try:

```auto
{ 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](https://insightsoftwareconsortium.github.io/itk-wasm/api/browser_io.html#readImageDICOMFileSeries-fileList-File-FileList-singleSortedSeries-boolean-false-Promise-lt-image-Image-webWorkerPool-WorkerPool-gt).
