# Please add cropping and padding options to maskVolume effect in ExtraEffect tools

**URL:** <https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691>\
**Category:** Feature requests\
**Tags:** segmentation\
**Created:** [May 4, 2019, 4:47am UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691 "2019-05-04T04:47:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [May 4, 2019, 4:47am UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/1 "2019-05-04T04:47:15Z")

</div>

It is common in our field to stuff whole bunch of genetically samples into the same scan to cut down the scanning costs/time (eg 10-15 zebrafish from the same clutch).

We are training our folks to use Slicer to do a quick segmentation to mask and save these specimen as individual datasets for further analysis.

Grow from the seeds and masking works really well in this context. What is missing is an option to cut down the original volume size to the largest extends of the mask and add an option to pad the cropped image. Of course this can be done with already existing tools in Slicer, but from a workflow point of view this might be a useful addition to the existing maskVolume functionality in the SegmentEditorExtraEffects extension.

---

<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:** [May 7, 2019, 11:28pm UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/2 "2019-05-07T23:28:30Z")

</div>

I see how such a Segment Editor effect could be useful. It is quite a niche use case, so I don’t think I could allocate time to work on it but maybe you could give it a try and implement it. [“Mask volume” effect](https://github.com/lassoan/SlicerSegmentEditorExtraEffects/tree/master/SegmentEditorMaskVolume) in SegmentEditorExtraEffects extension is quite similar. You just need to modify it to compute the extent from the segment (similarly to how it is done [here](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/EditorEffects/Python/AbstractScriptedSegmentEditorAutoCompleteEffect.py#L373-L391)).

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 24, 2019, 5:38pm UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/3 "2019-05-24T17:38:04Z")

</div>

@muratmaga maybe if you provided a sample dataset with scan and segmentations so we could get an idea what it would look like. It sounds like this could be just a few lines of numpy code.

-Steve

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [May 24, 2019, 8:11pm UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/4 "2019-05-24T20:11:18Z")

</div>

I think @smrolfe is close getting ready for a pull request to add this as an CropSegment effective to segementeditorextraeffects i believe.

---

<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:** [May 24, 2019, 10:23pm UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/5 "2019-05-24T22:23:05Z")

</div>

Great! If it’s a completely generic tool then SegmentEditorExtraEffects is a good home for it. If this new effect is tailored for needs of morpho community then you may distribute it in SlicerMorpho extension.

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [May 25, 2019, 1:18am UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/6 "2019-05-25T01:18:41Z")

</div>

Hi @lassoan, its a completely generic tool that uses the current segment to mask and crop to the segment extent, with an option to add padding.

@muratmaga , I’ve uploaded the extension to your repository for testing.

---

<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:** [May 25, 2019, 2:05am UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/7 "2019-05-25T02:05:08Z")

</div>

Sounds like a good fit for SegmentEditorExtraEffects extension then!

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [May 25, 2019, 10:05pm UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/8 "2019-05-25T22:05:38Z")

</div>

Thanks @lassoan, I have just submitted the pull request.

---

<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:** [March 21, 2023, 3:10am UTC](https://discourse.slicer.org/t/please-add-cropping-and-padding-options-to-maskvolume-effect-in-extraeffect-tools/6691/9 "2023-03-21T03:10:37Z")

</div>


