# Segmentation in Jupyter notebook

**URL:** https://discourse.slicer.org/t/segmentation-in-jupyter-notebook/13583
**Category:** Development
**Tags:** segmentation, python, jupyter
**Created:** [September 21, 2020, 9:41am UTC](https://discourse.slicer.org/t/segmentation-in-jupyter-notebook/13583 "2020-09-21T09:41:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://discourse.slicer.org/u/Hugo)
#### Post date: [September 21, 2020, 9:41am UTC](https://discourse.slicer.org/t/segmentation-in-jupyter-notebook/13583/1 "2020-09-21T09:41:05Z")

</div>

Hello everyone,

I’m trying to make a simply version of 3d slicer using the Jupyter notebook.  
I would like to enable the « sphere » brush option and be able to choose the % of the brush in my def paint but didn’t find a way to do it properly.

![image002](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/d/ad37288b660decda0fdb13ed885e6cc047ca8aaf.png)

For now the brush is working find but only in 2d.

Thank you

---

<div class="post-metadata">

### Author: ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://discourse.slicer.org/u/Hugo)
#### Post date: [September 21, 2020, 9:52am UTC](https://discourse.slicer.org/t/segmentation-in-jupyter-notebook/13583/2 "2020-09-21T09:52:14Z")

</div>

I’ve managed to resolve my issue by adding this line:

```
    segmentEditorWidget.effectByName("Paint").setCommonParameter("BrushSphere", 1)
```

---

<div class="post-metadata">

### Author: ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://discourse.slicer.org/u/Hugo)
#### Post date: [September 21, 2020, 2:25pm UTC](https://discourse.slicer.org/t/segmentation-in-jupyter-notebook/13583/3 "2020-09-21T14:25:51Z")

</div>

Hello everyone,

I’m currently coding in a 3d slicer Jupyter notebook in order to make a simplify version of 3d slicer with only the tools I need.  
I would like to enable the « sphere » brush option and be able to choose the % of the brush in my def paint but didn’t find a way to do it properly.

 ![GraphiqueCollé-1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/0/50bbe52391f4b4e6fd1997fba73f439e33cd00e4.png)

For now the brush is working find but only in 2d.

Thank you!

Hugo

---

<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: [September 21, 2020, 2:27pm UTC](https://discourse.slicer.org/t/segmentation-in-jupyter-notebook/13583/4 "2020-09-21T14:27:04Z")

</div>

This topic should help:

> [@Shortcut for Sphere brush](https://discourse.slicer.org/t/shortcut-for-sphere-brush/13460/2):
>
> Instead of creating a new widget, refer to the Segment Editor module’s widget: segmentEditorWidget = slicer.modules.segmenteditor.widgetRepresentation().self().editor paintEffect = segmentEditorWidget.effectByName("Paint") paintEffect.setCommonParameter("BrushSphere", 1) # enable paintEffect.setCommonParameter("BrushSphere", 0) # disable

---

<div class="post-metadata">

### Author: ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://discourse.slicer.org/u/Hugo)
#### Post date: [September 22, 2020, 8:26am UTC](https://discourse.slicer.org/t/segmentation-in-jupyter-notebook/13583/5 "2020-09-22T08:26:25Z")

</div>

It worked for me thanks a lot!  
I’m now trying to do the same thing with the diameter of the brush

---

<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: [September 22, 2020, 12:18pm UTC](https://discourse.slicer.org/t/segmentation-in-jupyter-notebook/13583/6 "2020-09-22T12:18:38Z")

</div>

This topic should help:

> [@Controlling brush diameter increment when using Shift+Scroll](https://discourse.slicer.org/t/controlling-brush-diameter-increment-when-using-shift-scroll/4247/10):
>
> Good. I guess not re-creating the segment editor widget fixed the selection reset issue. Brush parameters are shared between paint and erase effects, so it is a common parameter, which need to be set by using setCommonParameter method: effect.setCommonParameter("BrushDiameterIsRelative", "0") effect.setCommonParameter("BrushAbsoluteDiameter", newDiam)
