# Downstream Effects of Changing SegmentEditorWidget Source Volume

**URL:** <https://discourse.slicer.org/t/downstream-effects-of-changing-segmenteditorwidget-source-volume/37020>\
**Category:** Development\
**Tags:** segmentation, python, segmentations, segment-editor\
**Created:** [June 25, 2024, 9:13pm UTC](https://discourse.slicer.org/t/downstream-effects-of-changing-segmenteditorwidget-source-volume/37020 "2024-06-25T21:13:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![parikhmn](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/parikhmn/32/76885_2.png) [@parikhmn](https://discourse.slicer.org/u/parikhmn)\
**Post date:** [June 25, 2024, 9:13pm UTC](https://discourse.slicer.org/t/downstream-effects-of-changing-segmenteditorwidget-source-volume/37020/1 "2024-06-25T21:13:09Z")

</div>

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

```auto
## 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

```auto
newSourceVolume = slicer.mrmlScene.GetFirstNodeByName(newVolumeName)
segmentEditorWidget.setSourceVolumeNode(newSourceVolume)

```

Then, I check the `MaximumThreshold` parameter:

#### Checking MaximumThreshold

```auto
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!
