Extract/Save ROI from seg.nrrd (segmentations file) using Python packages SimpleITK or Slicerio

Hello!

I have a .nii scan file and have successfully created segments, saving them in a .seg.nrrd file. My goal now is to extract ROIs based on label names and save them as new .nii files. To achieve this, I am exploring the use of SimpleITK and the SlicerIO package.

i want to perform the multiplication between an ROI mask (based on Label Name) and the original scan file, resulting in an extracted ROI region. without broadcast error or shape mismatch error.

and does the seg.nrrd file contain the voxels from scan file for each ROI or just ROI masks?

Thank You!

You mean you want to save the contents of each segment as a separate volume? If that’s the case, it is already available as part of the SegmentEditorExtraEffects extension It is called SplitVolume.

Once your subvolumes are added to your scene, you can save them in nifti or nrrd format…

2 Likes

Just the masks. The files .seg.nrrd are labelmaps, 3D or 4D depending on whether there are overlapping segments. The content is only the segment binary labelmaps.

1 Like

should I utilize the SegmentEditorExtraEffects from the slicer API and use SplitVolume or is it included in the segment editor interface in the 3D Slicer application? is there a way to add SplitVolume to the effects section of the Segment Editor using 3D slicer startup code?

Thanks!

my bad :sweat_smile:, found SegmentEditorExtraEffects in extensions manager.

Thank you!