# Nrrdwrite.m of 2d image

**URL:** <https://discourse.slicer.org/t/nrrdwrite-m-of-2d-image/2050>\
**Category:** Support\
**Created:** [February 7, 2018, 8:47pm UTC](https://discourse.slicer.org/t/nrrdwrite-m-of-2d-image/2050 "2018-02-07T20:47:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcsharp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gcsharp/32/863_2.png) [@gcsharp](https://discourse.slicer.org/u/gcsharp)\
**Post date:** [February 7, 2018, 8:47pm UTC](https://discourse.slicer.org/t/nrrdwrite-m-of-2d-image/2050/1 "2018-02-07T20:47:01Z")

</div>

Hi, I’m trying to use nrrdwrite.m to create nrrds, but it doesn’t work on 2D images. Does anyone know if/how in Octave I can convert these to 3D images with one voxel in the 3rd dimension?

Alternatively, I can submit a patch to nrrdwrite, if such an interpretation is desirable.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 7, 2018, 9:03pm UTC](https://discourse.slicer.org/t/nrrdwrite-m-of-2d-image/2050/2 "2018-02-07T21:03:29Z")

</div>

I think they will need to be one slice 3d nrrd files.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 7, 2018, 9:59pm UTC](https://discourse.slicer.org/t/nrrdwrite-m-of-2d-image/2050/3 "2018-02-07T21:59:06Z")

</div>

I’ve updated this nrrdwrite function to be able to save 2D image (as single-slice 3D volume):

> <https://github.com/PerkLab/SlicerMatlabBridge/blob/master/MatlabCommander/commandserver/nrrdwrite.m>

---

<div class="post-metadata">

**Author:** ![gcsharp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gcsharp/32/863_2.png) [@gcsharp](https://discourse.slicer.org/u/gcsharp)\
**Post date:** [February 7, 2018, 10:57pm UTC](https://discourse.slicer.org/t/nrrdwrite-m-of-2d-image/2050/4 "2018-02-07T22:57:15Z")

</div>

Works great. Thanks!

I suggest a tiny little change: line 76 would benefit from a semi-colon!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 10, 2018, 8:13pm UTC](https://discourse.slicer.org/t/nrrdwrite-m-of-2d-image/2050/5 "2018-02-10T20:13:08Z")

</div>

Thank you, I’ve fixed it.
