Export segmentation scene (mrml) and segmentations (nrrd) into Nifti format for dropbox viewing

Hi! I am trying to export my segmentation scene and its segmentations as a nifti file for my PI to be shared and downloaded from dropbox. However, the entire scene can only be saved as a mrml file and the segmentations can only be saved in nrrd format with only the original unsegmented template able to be saved in Nifti format (See attached photo). My PI says that they can only access nifti files and since my entire scene and segmentations cannot be saved in the nifti format as nifti format is not an option in their menu (first two files), how can I save them both in nifti format so that my PI can view them properly? Thank You!

Are you working with brain images? If yes, then using nifti file format may make sense (otherwise I would recommend nrrd). To save segmentation result as nifti, right-click on the segmentation node in Data module to export to labelmap node.

Thank you! I am working with segmenting and entire brain so it does make sense for nifti. I have gone to the Segmentations module where export and export to labelmap is located and cannot seem to find the nodes that you are talking about. Right clicking on segmentations in save also does not do anything. Can you show me how to get there?

To convert segmentation to labelmap: right-click on segmentation node in Data module and choose “Export visible segments to binary labelmap” (or use Segmentations module).

Thank you for the advice! I was able to get my file into nifti format. However, as I am performing an entire brain segmentation (both hemispheres), it appears that the new nifti file (after exported to binary labelmap) when opened in a new slicer tab has its spatial position slightly altered and the right hemisphere is completely dark with only left hemisphere segmentations visible. How can I go about correcting this?

Here are my original (with Freesurfer label colors) and nifti. The nifti appears to be spatially disoriented (acccording to my PI) as well as missing the right hemisphere even though I created it by simply right clicking on segmentation node and choosing exporting to binary labelmap. Hope you can let me know what is wrong, thanks!

When you load the nifti file, you need to indicate in “Add data” window that the nifti file contains a segmentation or labelmap volume, by selecting “Segmentation” in the description column; or selecting “Volume” in the description and check “Show options” and check “LabelMap”.

Thank you for the information! I have been able to get colors now by selecting “volume” in the description. However, my colors are in Freesurfer labels as needed for my project and when I upload the new nifti, I also do select Freesurfer labels in the description after checking “Show options” and my segmentations end up an entirely different color (bottom) as the original (top). I am wondering how I can fix this. Going to volumes and changing to freesurfer or just generic colors also does not seem to help. Thank you so far!

To identify segments, FreeSurfer relies on hardcoded label values, while segmentation relies on names (or standard DICOM terminology).

Could you please describe your data processing workflow? Would you like to fix automatic FreeSurfer segmentation in Slicer’s Segment Editor?

@Sunderlandkyl Can you help here? Maybe we would need a FreeSurfer export, which would create labelmap with FreeSurfer label values, with a similar script to this.

Also there is this project that may help:

We could add the functionality in SlicerFreeSurfer to export the Segmentations with the correct label values directly to nifti.
Exporting the segmentations to labelmap using the color node would also solve this issue.

1 Like

Sounds good. For now maybe just add an issue to SlicerFreeSurfer so that we remember this.

1 Like

Thank you for all the feedback. I will indeed try it. In response to Dr. Lasso @lassoan , my processing workflow has simply been to use the segmentations editor and manually color them in, using automated tools such as thresholding only occasionally, as my project requires manual segmentation. I also label my segmentations simply with freesurfer colors. How would I export using color node? The link does not seem to inform me how to do so but I would appreciate it!

We haven’t implemented export with label values taken from color table. The idea is tracked in this issue. We don’t plan to work on it before releasing Slicer5, but if many people request it and/or Slicer5 release is delayed then it might fit in.

Until then, you can use this code snippet to relabel a segmentation:
https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_information_from_segmentation_nrrd_file_header

1 Like