Mask Volume Logic

Hi everyone,
I’m using a 3D Slicer instance without GUI (headless representation) on my Apache2 server.
In my Python script, I can’t use the widget representation, so I need to directly call the logic functions of the modules I’m using.

I need to create an independent volume for my “liver” segment obtained after segmentation with TotalSegmentator.
I use the “Mask Volume” effect of the Segment Editor module. Is it possible to know which logic functions (not widget) should be called from Python to execute it and obtain my ScalarVolumeNode “liver Masked”?

I thought this was the correct code:

fillValue = 0
SegmentEditorEffects.SegmentEditorMaskVolumeEffect.maskVolumeWithSegment(
    segmentationNode, segmentID, "FILL_OUTSIDE", [fillValue], inputVolume, outputVolume
)

But when I call it, I get a LabelMapVolumeNode, which is different from what happens when I execute the command from the GUI, where I correctly get a new ScalarvolumeNode.
I want to retain the original pixel values of my “liver,” not the binary mask.

If

Any help is appreciated.

You provide the node for outputVolume. The maskVolumeWithSegment function cannot change the type of this object, it will remain the type that you chose when you created that node.

1 Like