# .nrrd file cannot be reopened after saving it

**URL:** <https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943>\
**Category:** Support\
**Created:** [April 16, 2023, 7:18pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943 "2023-04-16T19:18:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Binswanger](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joshua_binswanger/32/65531_2.png) [@Joshua\_Binswanger](https://discourse.slicer.org/u/Joshua_Binswanger)\
**Post date:** [April 16, 2023, 7:18pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943/1 "2023-04-16T19:18:19Z")

</div>

Hey Slicer People,

First off: Super powerful and fun to use software! really appreciate all you created and did! Hard to belive all this is free 🙂

Anyways, I stumbled upon a problem which baffles me a bit. I created some segmentations in the segment editor and everything worked fine. I added another segmentation saved the file and wanted to create a surface representation and the porgram gave me an out of memory error message. I clicked ok, quit the program and wanted to open the file again. Now I want to open the file again (segmentation file saved as seg.nrrd) I get an out of memory error again…

" Slicer has caught an application error, please save your work and restart.

The application has run out of memory. Increasing virtual memory size in system settings or adding more RAM may fix this issue.

If you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at [https://slicer.org](https://slicer.org)

The message detail is:

Exception thrown in event: bad array new length"

This is kinda bad for me as I dont have a back up… I was wondering if I could somehow adjust the .nrrd file so that I dont get the out of memory error when I open the file. Already checked if “Segmentation\_MasterRepresentation:=Binary labelmap” is set. So it should not load any Closed Surface Representations, which can cause problems.

How would you suggest to go about saving my segmentations… Is there a way to modify the .nrrd header to only load certain labelmaps?

Thanks for any help in advance, would really appreaciate it. Especially to understand what went wrong and how to avoid it next time… 🙂

Best  
Joshua

---

<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:** [April 16, 2023, 7:20pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943/2 "2023-04-16T19:20:21Z")

</div>

Is “closed surface” representation listed in the image header, too? You may need to remove that to prevent automatic creation of closed surface representation on load.

---

<div class="post-metadata">

**Author:** ![Joshua\_Binswanger](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joshua_binswanger/32/65531_2.png) [@Joshua\_Binswanger](https://discourse.slicer.org/u/Joshua_Binswanger)\
**Post date:** [April 16, 2023, 8:49pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943/3 "2023-04-16T20:49:37Z")

</div>

Hey Andras,

Thanks for the quick reply. I am not sure which image header you refer to. It is a different file you refer to then the seg.nrrd? Unfortunately I am not that familiar with the technical aspects of file handling… 🙂

But the whole header of the seg.nrrd file reads:

NRRD0004

# Complete NRRD file format specification at:

# [Teem: nrrd: Definition of NRRD File Format](http://teem.sourceforge.net/nrrd/format.html)

type: unsigned char  
dimension: 4  
space: left-posterior-superior  
sizes: 7 907 688 840  
space directions: none (1.0000000150184933,0,0) (0,1.0000000150184933,0) (0,0,1)  
kinds: list domain domain domain  
encoding: gzip  
space origin: (0,-8.0000001201479467,-14)  
Segment0\_Color:=0.501961 0.682353 0.501961  
Segment0\_ColorAutoGenerated:=1  
Segment0\_Extent:=0 906 0 687 0 839  
Segment0\_ID:=EICHE\_Segementationen\_Gefaesse\_1000x  
Segment0\_LabelValue:=1  
Segment0\_Layer:=0  
Segment0\_Name:=EICHE\_Segementationen\_Gefaesse\_1000x  
Segment0\_NameAutoGenerated:=1  
Segment0\_Tags:=Segmentation.Status:inprogress|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segment1\_Color:=0.501961 0.682353 0.501961  
Segment1\_ColorAutoGenerated:=1  
Segment1\_Extent:=0 899 8 677 14 827  
Segment1\_ID:=Segment\_1  
Segment1\_LabelValue:=1  
Segment1\_Layer:=1  
Segment1\_Name:=SpÃ¤tholzgefaesse  
Segment1\_NameAutoGenerated:=0  
Segment1\_Tags:=Segmentation.Status:inprogress|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segment2\_Color:=0.717647 0.611765 0.862745  
Segment2\_ColorAutoGenerated:=1  
Segment2\_Extent:=0 906 0 687 0 827  
Segment2\_ID:=Segment\_36  
Segment2\_LabelValue:=1  
Segment2\_Layer:=2  
Segment2\_Name:=Final Holzstrahlen 0  
Segment2\_NameAutoGenerated:=0  
Segment2\_Tags:=Segmentation.Status:completed|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segment3\_Color:=0.498039 0.588235 0.345098  
Segment3\_ColorAutoGenerated:=1  
Segment3\_Extent:=0 906 0 687 14 827  
Segment3\_ID:=Segment\_29  
Segment3\_LabelValue:=1  
Segment3\_Layer:=3  
Segment3\_Name:=Final Holzstrahlen 1  
Segment3\_NameAutoGenerated:=0  
Segment3\_Tags:=Segmentation.Status:inprogress|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segment4\_Color:=0.305882 0.247059 0  
Segment4\_ColorAutoGenerated:=1  
Segment4\_Extent:=0 906 0 687 14 827  
Segment4\_ID:=Segment\_28  
Segment4\_LabelValue:=1  
Segment4\_Layer:=4  
Segment4\_Name:=Final Holzstrahlen 2  
Segment4\_NameAutoGenerated:=0  
Segment4\_Tags:=Segmentation.Status:inprogress|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segment5\_Color:=0.333333 0.737255 1  
Segment5\_ColorAutoGenerated:=1  
Segment5\_Extent:=0 906 0 687 12 827  
Segment5\_ID:=Segment\_43  
Segment5\_LabelValue:=1  
Segment5\_Layer:=5  
Segment5\_Name:=Final Holzstrahlen 3  
Segment5\_NameAutoGenerated:=1  
Segment5\_Tags:=Segmentation.Status:inprogress|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segment6\_Color:=0.501961 0.682353 0.501961  
Segment6\_ColorAutoGenerated:=1  
Segment6\_Extent:=0 899 8 677 14 827  
Segment6\_ID:=Segment\_10  
Segment6\_LabelValue:=2  
Segment6\_Layer:=1  
Segment6\_Name:=Complete  
Segment6\_NameAutoGenerated:=0  
Segment6\_Tags:=Segmentation.Status:inprogress|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segment7\_Color:=0.945098 0.839216 0.568627  
Segment7\_ColorAutoGenerated:=1  
Segment7\_Extent:=0 296 104 397 0 839  
Segment7\_ID:=Segment\_13  
Segment7\_LabelValue:=1  
Segment7\_Layer:=6  
Segment7\_Name:=Gefaesse\_Ausschnitt  
Segment7\_NameAutoGenerated:=0  
Segment7\_Tags:=Segmentation.Status:inprogress|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segment8\_Color:=0.694118 0.478431 0.396078  
Segment8\_ColorAutoGenerated:=1  
Segment8\_Extent:=0 906 0 687 0 839  
Segment8\_ID:=Segment\_14  
Segment8\_LabelValue:=2  
Segment8\_Layer:=0  
Segment8\_Name:=Segment\_14  
Segment8\_NameAutoGenerated:=1  
Segment8\_Tags:=Segmentation.Status:inprogress|TerminologyEntry:Segmentation category and type - 3D Slicer General Anatomy list~SCT^85756007^Tissue~SCT^85756007^Tissue~^^~Anatomic codes - DICOM master list~^^~^^|  
Segmentation\_ContainedRepresentationNames:=Binary labelmap|Closed surface|  
Segmentation\_ConversionParameters:=Decimation factor|0.0|Desired reduction in the total number of polygons. Range: 0.0 (no decimation) to 1.0 (as much simplification as possible). Value of 0.8 typically reduces data set size by 80% without losing too much details.&Smoothing factor|0.2|Smoothing factor. Range: 0.0 (no smoothing) to 1.0 (strong smoothing).&Compute surface normals|1|Compute surface normals. 1 (default) = surface normals are computed. 0 = surface normals are not computed (slightly faster but produces less smooth surface display).&Joint smoothing|0|Perform joint smoothing.&Reference image geometry|-1.0000000150184933;0;0;0;0;-1.0000000150184933;0;0;0;0;1;0;0;0;0;1;0;899;0;669;0;813;|Image geometry description string determining the geometry of the labelmap that is created in course of conversion. Can be copied from a volume, using the button.&Oversampling factor|1|Determines the oversampling of the reference image geometry. If it’s a number, then all segments are oversampled with the same value (value of 1 means no oversampling). If it has the value “A”, then automatic oversampling is calculated.&Crop to reference image geometry|0|Crop the model to the extent of reference geometry. 0 (default) = created labelmap will contain the entire model. 1 = created labelmap extent will be within reference image extent.&Collapse labelmaps|1|Merge the labelmaps into as few shared labelmaps as possible 1 = created labelmaps will be shared if possible without overwriting each other.&Fractional labelmap oversampling factor|1|Determines the oversampling of the reference image geometry. All segments are oversampled with the same value (value of 1 means no oversampling).&Threshold fraction|0.5|Determines the threshold that the closed surface is created at as a fractional value between 0 and 1.&  
Segmentation\_MasterRepresentation:=Binary labelmap  
Segmentation\_ReferenceImageExtentOffset:=0 -8 -14

There is a “Closed surface” Part…

---

<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:** [April 16, 2023, 8:58pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943/4 "2023-04-16T20:58:17Z")

</div>

I’ve run into this before too, you have to remove this text:

`Closed surface|`

from this line:

`Segmentation_ContainedRepresentationNames:=Binary labelmap|Closed surface|`

@lassoan I’d still vote not to have this state in the nrrd header, but if you want to keep it we should at least have a load option to bypass it.

---

<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:** [April 16, 2023, 9:14pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943/5 "2023-04-16T21:14:32Z")

</div>

Having an option to override it in the file reader options would be useful for sure.

@Joshua_Binswanger would you mind adding a post to the “Feature request” category for this? Thank you.

---

<div class="post-metadata">

**Author:** ![Joshua\_Binswanger](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joshua_binswanger/32/65531_2.png) [@Joshua\_Binswanger](https://discourse.slicer.org/u/Joshua_Binswanger)\
**Post date:** [April 18, 2023, 2:07pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943/6 "2023-04-18T14:07:31Z")

</div>

Hey,

Sorry for the late reply. Just got back to my machine. I created the changes suggest by @pieper  
Unfortunately now another Error is thrown:

Exception thrown in event: D:\D\S\S-0-build\ITK\Modules\IO\NRRD\src\itkNrrdImageIO.cxx:769:  
ITK ERROR: NrrdImageIO(000001C01D8D04C0): Read: Error reading C:/Users/Josh/Desktop/Detail\_Segmentation/EICHE\_Segementationen\_Gefaesse\_1000x\_1.seg.nrrd:  
[nrrd] nrrdLoad: trouble reading “C:/Users/Josh/Desktop/Detail\_Segmentation/EICHE\_Segementationen\_Gefaesse\_1000x\_1.seg.nrrd”  
[nrrd] nrrdRead: trouble  
[nrrd] \_nrrdRead: trouble reading NRRD file  
[nrrd] \_nrrdFormatNRRD\_read:  
[nrrd] \_nrrdEncodingGzip\_read: error reading from gzFile  
[nrrd] \_nrrdGzRead: data read error  
[nrrd] \_nrrdGzCheckHeader: gzip compression method is not deflate

I changed the suggested line to:

Segmentation\_ContainedRepresentationNames:=Binary labelmap

@lassoan : I will gladly make a feature request, once I am sure the above problem is just on my end… 🙂

---

<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:** [April 18, 2023, 3:34pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943/7 "2023-04-18T15:34:12Z")

</div>

Probably whatever tool you used to edit the header caused some other change to the file that changed the binary data (probably some automatic windows end of line conversion). I used vim to make the suggested edit on my machine. Also I believe the line should be like this, but I"m not sure if the ending `|` symbol is needed or not:

`Segmentation_ContainedRepresentationNames:=Binary labelmap|`

---

<div class="post-metadata">

**Author:** ![Joshua\_Binswanger](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joshua_binswanger/32/65531_2.png) [@Joshua\_Binswanger](https://discourse.slicer.org/u/Joshua_Binswanger)\
**Post date:** [April 18, 2023, 3:57pm UTC](https://discourse.slicer.org/t/nrrd-file-cannot-be-reopened-after-saving-it/28943/8 "2023-04-18T15:57:25Z")

</div>

Yeahy, got it to work. What a dumb mistake… Thanks so much for all the help!  
Create a feature request: [Removing "Closed Surface" from seg.nrrd image header Line: Segmentation\_ContainedRepresentationNames](https://discourse.slicer.org/t/removing-closed-surface-from-seg-nrrd-image-header-line-segmentation-containedrepresentationnames/28987)

Thanks for the support! you are all doing great work!
