.nrrd file cannot be reopened after saving it

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 :slight_smile:

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

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ā€¦ :slight_smile:

Best
Joshua

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.

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ā€¦ :slight_smile:

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

NRRD0004

Complete NRRD file format specification at:

Teem: nrrd: Definition of NRRD File Format

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ā€¦

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.

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.

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ā€¦ :slight_smile:

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|

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

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