Error with maskvolumewithsegment with python


Slicer 4.10.2 , Windows

I’ve been trying to access the mask volume effect with python and keep running into the following problem:

This is the relevant code for segment labeled “Tumor”:

segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
segmentEditorNode = slicer.vtkMRMLSegmentEditorNode()

segmentEditorWidget.setActiveEffectByName(“Mask volume”)
effect = segmentEditorWidget.activeEffect()
maskedVolume = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLScalarVolumeNode”, “masked volume”)

This is the error I get:

Traceback (most recent call last):
File “”, line 1, in
File “C:/Users/Neeraja/AppData/Roaming/NA-MIC/Extensions-28257/SegmentEditorExtraEffects/lib/Slicer-4.10/qt-scripted-modules/SegmentEditorMaskVolumeLib/”, line 400, in maskVolumeWithSegment
TypeError: ‘int’ object has no attribute ‘getitem

I’ve checked each of the inputs for maskVolumeWithSegment and reviewed the source code( but can’t seem to figure out what is wrong.

If I switch to “FILL_INSIDE” the error shifts to Line 390 but is otherwise the same.

I would appreciate any suggestions/ideas.

Thank you!

As you can see here, maskVolumeWithSegment method now expects a list of one or two values. Where did you find the example code snippet that still used a number instead of a list?

Thank you!

I used the same linked script but did not see that it had to be a list.

Thanks again.