Irregular shaped ROI and conversion to mask

How can I create a 3D ROI of irregular shape (not rectangular prism)? Is the Closed Curve option in the Create and Place menu the only way to do this?
I also want to be able to use this sort of irregular 3D ROI to create a mask within a scripted module that has the same shape as the input image, and has value 0 inside the 3D ROI and 1 outside of it. What would be the syntax for doing this?
Rohan Nadkarni

There are lots of options for defining 3D ROIs. What shape are you creating? What is your overall goal?

I would like some tool that gives the user a lot of flexibility about how to define the shape – irregular contour.
For my application, the 3D ROI, which is defined using a vtkMRMLAnnotationROINode, may contain some unwanted parts of the body in addition to the tumor we are interested in. The irregular shaped 3D region should overlap with the ROI, and this overlapping region is the omit region. For all feature maps computed from the 3D ROI, voxels within the omit region should have a value of 0, so that the feature map doesn’t compute feature values for the unwanted body parts.

Do you want to segment tumors? Then the most suitable tool is probably Segment Editor.

If there is visible brightness difference between the tumor and surrounding region then probably the fastest is to use “Grow from seeds” (see “Tumor segmentation” section of Neurosurgical planning tutorial for step-by-step instructions).

You can also segment tumors fully automatically using Nvidia AI-based segmentation tool.

If you need quick, intraoperative tumor segmentation on a touch screen then you may use Surface Cut effect with a custom user interface (large buttons that makes it easy to use Slicer on a touchscreen).

There are many other tools and approaches implemented in Slicer. If you tell us more about what exactly you are trying to achieve then we can give more targeted advice.

Thanks for the comment, but segmentation is not the issue I’m concerned with. In fact, the whole purpose of my module is to perform a specific method of tumor segmentation within the region that the user specifies as containing tumor.

The problem I’m concerned with is related to ROI selection. Specifically, how to define a smaller region within the ROI that should have a value of 0 within the tumor mask.

Please look at this image. My module computes a tumor mask within the region defined by the vtkMRMLAnnotationROINode. However, if we do not have an “omit region”, the heart (in bottom left of ROI) will be labeled incorrectly as tumor (value 1) in the tumor mask created by my module. I want to allow the user to define an omit region (shown in the image as the red shape) so that the module knows that the region of overlap between the red shape and the vtkMRMLAnnotationROINode should have value of 0 in the tumor mask. I’m asking how to make a 3D omit region of arbitrary shape.

I hope this is clear now.

Thanks for your help,

For quick approximate segmentation (to create include/exclude regions) you can use Surface Cut effect:

You can also add/remove entire regions using Scissors effect in slice views.

You may also be able to create mask from a single click, by combination of Thresholding and Island effects.

It all depends on what are your constraints. If you just need to create training data set for deep learning based segmentation then using a combination of effects in Segment Editor effects should be good. After you segmented a few dozen images, you should be able to create your mask within a minute using existing tools.


Is there a way that we can create a cylinder and a cube by defining points in slicer view like in the case,

Manipulating objects in the slice viewer in the 3D slicer scrip repository which creates a sphere.

  • How to define/edit a circular region of interest in a slice

Yes, instead of a vtkSphereSource, you can use a vtkCylinderSource or vtkCubeSource.


found this searching for the same exact point .
i want to create ROI around a mandible " very irregular shape" so i can do different rendering for the mandible only , then segment a lesion within the mandible .

with the regular cube , i have to include maxilla and part of temporal bone .

if possible to create a ROI with a selection then render it as a volume would be great

You should be able to use the Mask Volume effect for that:

How to replace it, I know a little about python

You don’t need to use Python, you can do everything via the graphical user interface.

To render the mandible differently, do as @pieper suggested above: go to Segment Editor module, segment the mandible, then use Mask volume effect to blank out (set to -1000) everything outside the mandible segment. You can then use volume rendering to display just the mandible.

Are you planning to resect tumor and reconstruct the mandible using fibula free flap?