# Disable Histogram Brush in Segment Editor Threshold effect

**URL:** https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501
**Category:** Development
**Tags:** segmentation, python
**Created:** [May 7, 2021, 7:07am UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501 "2021-05-07T07:07:17Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![pll\_llq](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pll_llq/32/9408_2.png) [@pll\_llq](https://discourse.slicer.org/u/pll_llq)
#### Post date: [May 7, 2021, 7:07am UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/1 "2021-05-07T07:07:17Z")

</div>

Hi 👋

I’m using the segment editor threshold effect in a custom UI to segment a CT. The effect conveniently handles all the nodes that are required for visualization and gives me python access to processing functions. To accomplish this I’ve used the [references from the script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#how-to-run-segment-editor-effects-from-a-script).

I like the sliders and the python interface to setting threshold values and I like how the segment editor handles the display. My problem is that when I set active effect in the temporary `qMRMLSegmentEditorWidget` it hijacks the interaction mode to the HistogramBrush (circle ROI for threshold values selection by default).  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/3/7372a98b0f0f2059192b09bb8264fbb360c0d316.jpeg)

Is there a way to disable the interactive functionality related to clicking the slice views?

---

<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 10, 2021, 3:57am UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/2 "2021-05-10T03:57:24Z")

</div>

You can add an effect parameter (without a GUI widget) to enable/disable local histogram region drawing and send a pull request to integrate this option into Slicer core.

> [@pll\_llq](#):
>
> My problem is that when I set active effect in the temporary `qMRMLSegmentEditorWidget` it hijacks the interaction mode to the HistogramBrush

Why is this a problem?

---

<div class="post-metadata">

### Author: ![pll\_llq](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pll_llq/32/9408_2.png) [@pll\_llq](https://discourse.slicer.org/u/pll_llq)
#### Post date: [May 10, 2021, 12:38pm UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/3 "2021-05-10T12:38:19Z")

</div>

Thanks for the advice. I’ll look into the segment editor source code to see if I can add this parameter.

> [@lassoan](#):
>
> Why is this a problem?

- no visual feedback that the interaction mode has changed (it was a surprize to me that there is an interaction mode)
- inability to use window/level interaction mode while the unconfirmed segmentation is on screen (my use case)

So, when I choose the threshold segmentation I get no feedback that the interaction mode has changed. Other segmentation effects (draw, erase etc) change the mouse pointer.  
Since the module panel shows the threshold sliders my assumption was that this is the way the tool works.

---

<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 11, 2021, 5:36am UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/4 "2021-05-11T05:36:20Z")

</div>

> [@pll\_llq](#):
>
> no visual feedback that the interaction mode has changed (it was a surprize to me that there is an interaction mode)

Good point. I’ll enable custom view cursor for threshold effect.

> [@pll\_llq](#):
>
> inability to use window/level interaction mode while the unconfirmed segmentation is on screen (my use case)

Several keyboard&mouse gestures would clash between window/level interaction mode and interactive segmentation, so the two mouse modes are mutually exclusive.

> [@pll\_llq](#):
>
> So, when I choose the threshold segmentation I get no feedback that the interaction mode has changed.

You can see the current interaction mode on the toolbar. If you switch to a segment editor effect then it exits from point placement or window/level adjustment.

---

<div class="post-metadata">

### Author: ![pll\_llq](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pll_llq/32/9408_2.png) [@pll\_llq](https://discourse.slicer.org/u/pll_llq)
#### Post date: [May 11, 2021, 5:40am UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/5 "2021-05-11T05:40:23Z")

</div>

> [@lassoan](#):
>
> Good point. I’ll enable custom view cursor for threshold effect.

I was thinking about this and actually if the cursor change was there I would not have any expectations about the interaction with the effect and thus no problems integrating it into the workflow.  
So yeah, the adding a custom cursor is the best solution.

---

<div class="post-metadata">

### Author: ![pll\_llq](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pll_llq/32/9408_2.png) [@pll\_llq](https://discourse.slicer.org/u/pll_llq)
#### Post date: [May 11, 2021, 5:41am UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/6 "2021-05-11T05:41:42Z")

</div>

> [@lassoan](#):
>
> custom view cursor

Shall I create an icon for it?

---

<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 11, 2021, 5:41am UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/7 "2021-05-11T05:41:59Z")

</div>

> [@pll\_llq](#):
>
> So yeah, the adding a custom cursor is the best solution.

Done. See [here](https://github.com/Slicer/Slicer/commit/5b02b00ea3cb618c74e3e21485c8a0f61bc739a9).

---

<div class="post-metadata">

### Author: ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)
#### Post date: [January 13, 2022, 12:24pm UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/8 "2022-01-13T12:24:33Z")

</div>

Hi. I would like to disable the histogram cursor and functionality completely on localThreshold effect because it is not needed as the segmentation parameters are selected with GUI. So I can have the previsualization of segmentation without been possible to change it via the mouse.

I tried with this line but it doesn’t work:

```auto
localThreshold.self().histogramFunctionItem.removeEventFilter(localThreshold.self().histogramEventFilter)

```

Also it would be interesting to me to be able to place a fiducial over the sliceView while the preview of segmentation is on. Changing to fiducial placement mode, disables the previsualization of segmentation

---

<div class="post-metadata">

### Author: ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)
#### Post date: [January 14, 2022, 1:06pm UTC](https://discourse.slicer.org/t/disable-histogram-brush-in-segment-editor-threshold-effect/17501/9 "2022-01-14T13:06:16Z")

</div>

I solved it by creating a copy of LocalThreshold effect and overriding _processInteractionEvents_ to this:

```auto
  def processInteractionEvents(self, callerInteractor, eventId, viewWidget):
    return False

```

Hope it helps someone
