Hello,
I would love some help understanding the effect changing the source volume has on the SegmentEditorWidget
. I recently ran into an issue where, after changing the source volume with setSourceVolumeNode()
, the Threshold effect didn’t update its default MaximumThreshold
parameter to the maximum voxel intensity of the new volume. I know that I could identify the new maximum intensity and set it programmatically, but I wondered if there was a method by which I could make sure all default parameters similar to MaximumThreshold
would update as soon as I changed the source volume. I’ve seen the sourceVolumeNodeChanged()
function pop up in a couple places in the documentation, but I don’t really know how that might factor into this.
For context, here’s a bit of my code:
Initially Defining the SegmentEditorWidget
## Define master volume node
masterVolumeNode = slicer.mrmlScene.GetFirstNodeByClass("vtkMRMLScalarVolumeNode")
## Create segmentation
segmentation = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
segmentation.CreateDefaultDisplayNodes()
segmentation.SetReferenceImageGeometryParameterFromVolumeNode(masterVolumeNode)
# Prepare to edit the segment
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
segmentEditorNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentEditorNode")
segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode)
segmentEditorWidget.setSegmentationNode(segmentation)
segmentEditorWidget.setSourceVolumeNode(masterVolumeNode)
Later, I create a new volume with the exact same features as the masterVolumeNode
except that I’ve squared (or otherwise transformed) its voxel intensities.
Setting the New Source Volume
newSourceVolume = slicer.mrmlScene.GetFirstNodeByName(newVolumeName)
segmentEditorWidget.setSourceVolumeNode(newSourceVolume)
Then, I check the MaximumThreshold
parameter:
Checking MaximumThreshold
segmentEditorWidget.setActiveEffectByName("Threshold")
effect = segmentEditorWidget.activeEffect()
effect.parameter("MaximumThreshold")
But it ends up being the old maximum intensity.
Any help understanding if I could add something after setting the new volume that would cause the MaximumThreshold
parameter to update on its own would be very much appreciated.
Thanks!