I am trying to specify the output of the “Mask Volume” effect
how can I specify the input and output volumes ?
assuming I don’t want to use the master as input and I don’t know how to set the output?
A good method for figuring out how to set code for items in the widget that you are using(SegmentEditorWidget in this case) is calling .children(), .findChildren(…) if you know the object type, or the more specific .findChild(…) if you know object type and object name.
From the slicer python interactive you can always do something like SegmentEditorWidget.[tab] to see what members are available to use.
It should be possible to set the input and output volume by modifying the segment editor node, but unfortunately this effect is not storing this information in MRML. This is a mistake, and this kind of mistakes are the reason why this effect is not yet integrated into Slicer core but still in this extension.
However, you can easily perform the Masking operation by calling maskVolumeWithSegment method of the effect.
Basically it’s easier to just replicate the method maskVolumeWithSegment without the use of the widget as its pretty simply using vtkImageToImageStencil.
Yes, maskVolumeWithSegment method is all you need, so you can copy-paste as is into your script. The only disadvantage of cloning the code is that if there are any fixes or improvements then you don’t get those automatically, but since the amount of code is very small, most likely this won’t be an issue.