Apologies if this has been answered elsewhere, but my search can only find answers regarding NON-overlapping segmentations.
I have segmented a DICOM image and have 4 different segmentations. These all overlap.
I need to export as NIFTI (as that is the only filetype compatible with my colleagues Radiomics software). If I “export to file” as NIFTI some data is obviously lost due to the overlap. I have been able to compensate for this by hiding all layers but one, exporting to file, change to another layer, export to file and repeat for the 4 layers.
Is it possible to reduce the number of steps, i.e. export each segmentation to a separate NIFTI file rather than hiding/unhiding each one and manually saving?
Nifti is a very rigid neuroimaging file format. There is no clean way of encoding 4D segmentations and metadata in it. On the other hand, nrrd is a simple, much more flexible, general-purpose file format that can store all the necessary metadata. Unless there is a very very strong community pressure to improve Nifti support (and preferably accompanied by improvement of the Nifti file format), we will probably not invest time into it.
Since .nrrd file readers are available in all development environments (and due to simplicity of the file format, parsers can be implemented with very small effort, if additional dependencies to existing nrrd readers are unacceptable), it should be no problem to add nrrd support to your colleagues radiomics software. What programming language that software is implemented in and what libraries it is using already?
You can of course write a Python script that saves each segment in a separate volume (it would probably take 3-4 lines of code). You can find all the code pieces that you need in the Slicer script repository.
Many thanks, that does export to a new Labelmap, but it is still a combined one. I am trying to get it to export each segment (single and multi) to their own Labelmap so I can then export them easily as separate files. Sorry if I am being stupid.
Great, that was a big help. I have it exporting to file using ExportSegmentsBinaryLabelmapRepresentationToFiles as you suggested. It always saves the file as Segmentation.nii.gz. Is there a way to specify the file name, so I can run the script more than once to export individual segments as their segment name or ID? Meaning it won’t overwrite itself