# Exporting NRRD files as TIFF image stack

**URL:** <https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221>\
**Category:** Support\
**Created:** [November 15, 2024, 8:10pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221 "2024-11-15T20:10:04Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaimigray](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jaimigray/32/67886_2.png) [@jaimigray](https://discourse.slicer.org/u/jaimigray)\
**Post date:** [November 15, 2024, 8:10pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/1 "2024-11-15T20:10:04Z")

</div>

Is there a way we can convert and export our NRRD files as a TIFF stack without exporting to imageJ/IrfanView afterwards to convert the format from DICOM to a TIFF image series? If not, this seems like something we should have, since the major file format for MorphoSource uploads is a TIFFstack…

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 15, 2024, 8:50pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/2 "2024-11-15T20:50:05Z")

</div>

That’s really a MOrphoSource problem, not a Slicer one.

TIFF (or any other 2D format) is not a good format to retain 3D data, particularly for archival purposes. The lack of standardized metadata to describe image spacing, image coordinate system make those formats problematic. We explained this to MorphoSource team multiple times, and while they seem to appreciate the problem, they don’t seem to be willing to act on it.

At this point there is no interest in the Slicer core team to take a NRRD file and convert into an 2D image sequence, since it will create a whole lot of can of worms and possibly degrade the data quality as well.

Having that, there is nothing to stop someone to write a short python script that will iterate over the image numpy array and write them as a series of 2D images. It is not difficult, in fact all necessary python functions are probably documented in the Slicer script repository.

---

<div class="post-metadata">

**Author:** ![jaimigray](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jaimigray/32/67886_2.png) [@jaimigray](https://discourse.slicer.org/u/jaimigray)\
**Post date:** [November 15, 2024, 8:52pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/3 "2024-11-15T20:52:47Z")

</div>

Thanks for the quick answer Murat. I’m trying to walk a 3D Slicer user through uploading their data to MS, so I’ll direct them to conversion outside of the Slicer environment for now.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 15, 2024, 8:53pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/4 "2024-11-15T20:53:36Z")

</div>

By the way, if you want to see how unpredictable this can be:

1. Download the MRHead dataset
2. Click ctrl+S and bring up the save as dialog box and choose the format of TIFF. This will save the file as a multiframe tiff (a single tiff image, with slices)
3. Load that data into Slicer and see that orientaton and spacing is incorrect.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 15, 2024, 8:54pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/5 "2024-11-15T20:54:34Z")

</div>

I suggested the MorphoSource team to collaborate on data exporter from Slicer for this specific use case. That way it would have been possible to control some of the things, but they don’t seem to be interested in that either.

---

<div class="post-metadata">

**Author:** ![Amy\_Morton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/amy_morton/32/67318_2.png) [@Amy\_Morton](https://discourse.slicer.org/u/Amy_Morton)\
**Post date:** [November 18, 2024, 7:09pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/6 "2024-11-18T19:09:38Z")

</div>

At [SlicerAutoscoperM](https://autoscoper.readthedocs.io/en/latest/), we also deal with TIFF being necessary input to existing software (Autoscoper)

Jaimi, you may find [some of our module functions](https://github.com/BrownBiomechanics/SlicerAutoscoperM/blob/main/AutoscoperM/AutoscoperMLib/IO.py) helpful.

---

<div class="post-metadata">

**Author:** ![aubricot](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aubricot/32/67544_2.png) [@aubricot](https://discourse.slicer.org/u/aubricot)\
**Post date:** [November 19, 2024, 5:11pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/7 "2024-11-19T17:11:50Z")

</div>

Hi Murat, wouldn’t it be feasible to export an nrrd as a tiff stack with a metadata file in the same folder (similar to metadata files exported during recon from projections to tiff stacks)? I’d imagine the relevant info could be retained and recognized by Slicer during subsequent import of the converted tiff stack, just like it is for importing a reconstructed tiff stack. I quickly wrote a little python script ([GitHub nrrd2tiff](https://github.com/aubricot/nrrd2tiff/tree/main)) to do the conversion and copy over metadata info both from the original scanner metadata file and from the header of the nrrd. I’d love to develop it a bit further to make sure all the relevant information is retained, if you have any advice.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 19, 2024, 5:25pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/8 "2024-11-19T17:25:46Z")

</div>

> [@aubricot](#):
>
> wouldn’t it be feasible to export an nrrd as a tiff stack with a metadata file in the same folder (similar to metadata files exported during recon from projections to tiff stacks)?

No, not really. That’s poor data management. There are many issues: What is the convention of that file, what fields there would be, what are the units, what format (csv, tab, json, xml?), which reader is going to read all that? Most programs will see a tiff file and completely ignore that file. There is already a well documented, open formats that covers all of that situation, why re-invent the wheel.

> [@aubricot](#):
>
> quickly wrote a little python script ([GitHub nrrd2tiff](https://github.com/aubricot/nrrd2tiff/tree/main)) to do the conversion and copy over metadata info both from the original scanner metadata file and from the header of the nrrd.

As I said, all the necessary functionality to do that exists, we just don’t want to have it as a core feature of Slicer.

> [@aubricot](#):
>
> d. I’d love to develop it a bit further to make sure all the relevant information is retained, if you have any advice.

Looks good to me. I would suggest reloading your new tiff sequence back into Slicer and double checking that it is indeed complete and consistent with the original data.

---

<div class="post-metadata">

**Author:** ![aubricot](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aubricot/32/67544_2.png) [@aubricot](https://discourse.slicer.org/u/aubricot)\
**Post date:** [November 19, 2024, 5:33pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/9 "2024-11-19T17:33:19Z")

</div>

Thanks for the quick response. So far, the datasets I’ve tried seem consistent upon reimport to Slicer, but I will keep verifying before I apply it to all ~130 of the datasets I still need to upload to MorphoSource. Completely understood that converting Nrrd’s to Tiff’s is not an ideal solution for data management best practices, but for those of us that want to use 3D Slicer and upload our datasets to MorphoSource, I don’t see an alternative.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 19, 2024, 5:40pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/10 "2024-11-19T17:40:51Z")

</div>

> [@aubricot](#):
>
> but for those of us that want to use 3D Slicer and upload our datasets to MorphoSource, I don’t see an alternative.

I understand that, it is a MorphoSource requirement. But what we don’t want to encourage is to use of those formats as primary mean to keep the image data. If you want test, do this:

Crop your original NRRD file and/or put it under a transform. Save it as a new NRRD file, then export your NRRD file your script as your TIFF sequence. Then reload both of them into the Slicer. I suspect your tiff file no longer will have the correct orientation and the origin of the modified NRRD.

That’s what we want to avoid.

---

<div class="post-metadata">

**Author:** ![aubricot](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aubricot/32/67544_2.png) [@aubricot](https://discourse.slicer.org/u/aubricot)\
**Post date:** [November 19, 2024, 6:19pm UTC](https://discourse.slicer.org/t/exporting-nrrd-files-as-tiff-image-stack/40221/11 "2024-11-19T18:19:35Z")

</div>

Indeed, the orientation and origin are different for the cropped Nrrd and original. If you all were willing to add a feature to simplify the process for those of us wanting to upload to MorphoSource, it seems like optional form fields in the ImageStacks module for origin, pixel size, height/width/no images would correct for this loss of information. Totally understood that you all don’t want to open this can of worms, though. Thanks for the info, it’s been helpful and interesting.

 ![Screen Shot 2024-11-19 at 13.14.10](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/f/0fb4878d60a02a21b312a66e78d32ca53c22ceaa.jpeg)
