# How set output volume from segmentation effects

**URL:** <https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [October 26, 2018, 6:55pm UTC](https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548 "2018-10-26T18:55:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kayarre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kayarre/32/3606_2.png) [@kayarre](https://discourse.slicer.org/u/kayarre)\
**Post date:** [October 26, 2018, 6:55pm UTC](https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548/1 "2018-10-26T18:55:56Z")

</div>

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?

e.g.

```auto
segmentEditorWidget.setActiveEffectByName('Mask volume')
maskEffect = segmentEditorWidget.activeEffect()
maskEffect.setParameter('FillValue', -1)
maskEffect.setParameter('Operation', 'FILL_OUTSIDE')

```

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 26, 2018, 7:15pm UTC](https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548/2 "2018-10-26T19:15:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 26, 2018, 9:41pm UTC](https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548/3 "2018-10-26T21:41:11Z")

</div>

Have a look at the source code of this effect: [https://github.com/lassoan/SlicerSegmentEditorExtraEffects/blob/master/SegmentEditorMaskVolume/SegmentEditorMaskVolumeLib/SegmentEditorEffect.py](https://github.com/lassoan/SlicerSegmentEditorExtraEffects/blob/master/SegmentEditorMaskVolume/SegmentEditorMaskVolumeLib/SegmentEditorEffect.py)

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.

---

<div class="post-metadata">

**Author:** ![kayarre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kayarre/32/3606_2.png) [@kayarre](https://discourse.slicer.org/u/kayarre)\
**Post date:** [October 29, 2018, 5:36pm UTC](https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548/4 "2018-10-29T17:36:36Z")

</div>

@jamesobutler I have looked at those attributes but didn’t find a helpful clue. I see now how to use the .children()

@lassoan i looked through the source but can do some more investigation. how do I access maskVolumeWithSegment?

What would it take for the effect to be slicer core ready?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 29, 2018, 7:04pm UTC](https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548/5 "2018-10-29T19:04:07Z")

</div>

> [@kayarre](#):
>
> how do I access maskVolumeWithSegment

qMRMLSegmentEditorWidget::effectByName method should work.

> [@kayarre](#):
>
> What would it take for the effect to be slicer core ready?

See [Move Mask Volume effect to Slicer core · Issue #10 · lassoan/SlicerSegmentEditorExtraEffects · GitHub](https://github.com/lassoan/SlicerSegmentEditorExtraEffects/issues/10)

---

<div class="post-metadata">

**Author:** ![kayarre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kayarre/32/3606_2.png) [@kayarre](https://discourse.slicer.org/u/kayarre)\
**Post date:** [October 29, 2018, 7:18pm UTC](https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548/6 "2018-10-29T19:18:38Z")

</div>

Basically it’s easier to just replicate the method maskVolumeWithSegment without the use of the widget as its pretty simply using vtkImageToImageStencil.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 29, 2018, 7:24pm UTC](https://discourse.slicer.org/t/how-set-output-volume-from-segmentation-effects/4548/7 "2018-10-29T19:24:32Z")

</div>

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.
