# Threshold bug in slicer preview release

**URL:** <https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [November 15, 2024, 8:20am UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214 "2024-11-15T08:20:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![alientex](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@alientex](https://discourse.slicer.org/u/alientex)\
**Post date:** [November 15, 2024, 8:20am UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/1 "2024-11-15T08:20:03Z")

</div>

Hello,

The threshold preview and apply operations do not work after following the steps below:

1. Open the DICOM module, import, and load a DICOM directory.
2. Go to the Segment Editor and add a segment.
3. Open the threshold effect (do not apply the threshold yet) and press **Ctrl + S** to save the scene as an MRB file.
4. Close and reopen Slicer.
5. Load the saved MRB file.
6. Go to the Segment Editor. You should see the threshold effect open, but no preview is visible in 2D.
7. Nonetheless, try applying the threshold. However, the threshold does not apply.

Can anyone confirm if this is a bug and suggest how to resolve it?

Slicer version 5.7 preview.

---

<div class="post-metadata">

**Author:** ![alientex](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@alientex](https://discourse.slicer.org/u/alientex)\
**Post date:** [November 19, 2024, 5:45am UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/2 "2024-11-19T05:45:44Z")

</div>

@pieper @lassoan @cpinter @muratmaga @jcfr Any idea?

---

<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:** [November 19, 2024, 5:59am UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/3 "2024-11-19T05:59:10Z")

</div>

Please share a log file where you reproduce this.

---

<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:** [November 19, 2024, 6:05am UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/4 "2024-11-19T06:05:07Z")

</div>

I can reproduce this, you don;t need dicom. It definitely reproduces with sample MRHead data as you described.

I suspect this has something to do with saving an empty segmentation object. Because I delete the segmentaiton, and recreate it, threshold tool starts working again.

I think it does qualify as a bug. And I am not seeing any errors in the log file.

---

<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:** [November 19, 2024, 1:46pm UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/5 "2024-11-19T13:46:17Z")

</div>

> [@alientex](#):
>
> Open the threshold effect (do not apply the threshold yet) and press **Ctrl + S** to save the scene as an MRB file.

This is probably the issue, because a transient ‘preview’ of the threshold is not intended to be saved and restored. It’s sort of like a popup menu that you wouldn’t expect to be back when you reload the scene.

> [@alientex](#):
>
> Nonetheless, try applying the threshold. However, the threshold does not apply.

This probably is a problem, in that the state of the scene becomes inconsistent. I guess that save operations should trigger an even that the segment editor (and other modules) can respond to and put the scene into a consistent state.

---

<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:** [November 19, 2024, 5:41pm UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/6 "2024-11-19T17:41:57Z")

</div>

Should we open an issue or do you consider this a corner care?

---

<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:** [November 19, 2024, 6:59pm UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/7 "2024-11-19T18:59:36Z")

</div>

Yes, I think it’s a corner case, but it should be tracked anyway so thanks if you can file an issue. @lassoan showed us an in-progress fix that he thinks would address this.

---

<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:** [November 19, 2024, 7:25pm UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/8 "2024-11-19T19:25:18Z")

</div>

OK create a brief report to track this:

> <https://github.com/Slicer/Slicer/issues/8057>
>
> \## Summary
> If someone activates the threshold tool, but not use it, and then pr…oceeds to save scene in that state, and reloads, the threshold tool cannot be activated. I have not tested whether other effects from the same problem 
> \## Steps to reproduce
> Specifics are discussed in this thread: 
> https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/7
> 
> \## Environment
> \- Slicer version: Slicer-5.7 preview

---

<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:** [November 20, 2024, 9:20pm UTC](https://discourse.slicer.org/t/threshold-bug-in-slicer-preview-release/40214/9 "2024-11-20T21:20:22Z")

</div>

The issue is fixed now. It is available in Slicer Preview Releases that you download tomorrow or later.
