# New Segment Editor effect: Local threshold

**URL:** <https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233>\
**Category:** Support\
**Tags:** feature, segmentation\
**Created:** [November 20, 2019, 5:01pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233 "2019-11-20T17:01:15Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Nora](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nora/32/4866_2.png) [@Nora](https://discourse.slicer.org/u/Nora)\
**Post date:** [November 5, 2020, 11:12am UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/21 "2020-11-05T11:12:13Z")

</div>

> [@lassoan](#):
>
> added to the segment. If nothing is added then it means that the region found at the clicked positio

Hi all,

This extension sounds promising.

I have few issues though.  
So first, I draw a circle around my ROI then I edit the threshold of the local histogram. But how can I save the segment? I tried Ctrl + left click, the area keep blinking.

Another question please, is there any way to use fixed threshold (like 40% of SUVmax in PET)?

Appreciate your help,

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [November 5, 2020, 11:34am UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/22 "2020-11-05T11:34:56Z")

</div>

Sounds like you might be on a Mac - it is command + left click for MacOS.

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 7:09am UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/23 "2021-01-05T07:09:43Z")

</div>

There seems to be a problem with the installation of the SegmentEditorExtraEffects extension on my Slicer (v. 4.11.20200930). Once installed the “Local Thresholding” tool does not apear amongst my new segmenting tools.

I have already tried:

- re-installing the program after complete deletion of the program and its files
- re-installing the extension
- restarting my pc
- installing older versions of Slicer

Nothing worked…

Can someone help me to obtain the Local Threshold tool?

 ![Screenshot 2021-01-05 080555](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/2/52bc864d09136f3007429540d727b07a6e459155.jpeg)

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [January 5, 2021, 3:27pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/24 "2021-01-05T15:27:32Z")

</div>

I just tried installing SegmentEditorExtraEffects on the stable release and didn’t encounter any issues. You seem to be missing two segment editor effects: Local Threshold, and Split Volume.

Can you check to see if there are any errors in the log?

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 6:10pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/25 "2021-01-05T18:10:02Z")

</div>

There are indeed error remarks, what can I do to fix this?

Thanks in advance!

```auto
[CRITICAL][Stream] 05.01.2021 19:02:10 [] (unknown:0) - File "C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorLocalThresholdLib/SegmentEditorEffect.py", line 6, in <module>

[CRITICAL][Qt] 05.01.2021 19:02:10 [] (unknown:0) - loadSourceAsModule - Failed to load file "C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorLocalThresholdLib/SegmentEditorEffect.py" as module "SegmentEditorLocalThresholdLib" !

[CRITICAL][Stream] 05.01.2021 19:02:10 [] (unknown:0) - File "C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorLocalThreshold.py", line 27, in registerEditorEffect

[CRITICAL][Stream] 05.01.2021 19:02:10 [] (unknown:0) - File "C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorSplitVolumeLib/SegmentEditorEffect.py", line 10, in <module>

[CRITICAL][Qt] 05.01.2021 19:02:10 [] (unknown:0) - loadSourceAsModule - Failed to load file "C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorSplitVolumeLib/SegmentEditorEffect.py" as module "SegmentEditorSplitVolumeLib" !

[CRITICAL][Stream] 05.01.2021 19:02:10 [] (unknown:0) - File "C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorSplitVolume.py", line 34, in registerEditorEffect

```

---

<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:** [January 5, 2021, 7:04pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/26 "2021-01-05T19:04:57Z")

</div>

Probably the python files cannot be loaded because Slicer is installed in a folder that contains special characters (F **é** lix). This should not be a problem on recent Windows10 versions. Could you copy here the first 15 lines of the application log (menu: Help/Report a bug) to confirm that your Windows version is too old? If that is indeed the issue then you can either upgrade Windows or install Slicer in a folder that does not have special characters in its path.

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 7:28pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/27 "2021-01-05T19:28:56Z")

</div>

Here is the code:

[DEBUG][Qt] 05.01.2021 20:27:39 [] (unknown:0) - Session start time …: 2021-01-05 20:27:39

[DEBUG][Qt] 05.01.2021 20:27:39 [] (unknown:0) - Slicer version …: 4.11.20200930 (revision 29402 / 002be18) win-amd64 - installed release

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - Operating system …: Windows / Personal / (Build 19041, Code Page 65001) - 64-bit

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - Memory …: 8102 MB physical, 16038 MB virtual

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - CPU …: GenuineIntel , 4 cores, 4 logical processors

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - VTK configuration …: OpenGL2 rendering, TBB threading

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - Qt configuration …: version 5.15.1, with SSL, requested OpenGL 3.2 (compatibility profile)

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - Developer mode enabled …: no

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - Prefer executable CLI …: yes

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - Application path …: C:/Users/Félix/AppData/Local/NA-MIC/Slicer 4.11.20200930/bin

[DEBUG][Qt] 05.01.2021 20:27:40 [] (unknown:0) - Additional module paths …: C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules, C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SlicerVMTK/lib/Slicer-4.11/qt-loadable-modules, C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules, C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/Sandbox/lib/Slicer-4.11/qt-scripted-modules

[DEBUG][Python] 05.01.2021 20:27:45 [Python] (C:\Users\Félix\AppData\Local\NA-MIC\Slicer 4.11.20200930\lib\Python\Lib\site-packages\pydicom\datadict.py:432) - Reversing DICOM dictionary so can look up tag from a keyword…

[CRITICAL][Qt] 05.01.2021 20:27:48 [] (unknown:0) - Error(s):

CLI executable: C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SlicerVMTK/lib/Slicer-4.11/qt-loadable-modules/vtkvmtk.py

The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.

---

<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:** [January 5, 2021, 7:39pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/28 "2021-01-05T19:39:36Z")

</div>

This Windows version should be sufficient.

Does this file exist and contains Python code?  
`C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorLocalThresholdLib/SegmentEditorEffect.py`

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 7:45pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/29 "2021-01-05T19:45:06Z")

</div>

It appears the folder does contain Python code!

 ![Screenshot 2021-01-05 204448](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/5/a596602f8c6d91e3d06072d6cc55019e7e3d7ae3.png)

---

<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:** [January 5, 2021, 8:01pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/30 "2021-01-05T20:01:07Z")

</div>

Can you compare the file content with this file [https://github.com/lassoan/SlicerSegmentEditorExtraEffects/blob/master/SegmentEditorLocalThreshold/SegmentEditorLocalThresholdLib/SegmentEditorEffect.py](https://github.com/lassoan/SlicerSegmentEditorExtraEffects/blob/master/SegmentEditorLocalThreshold/SegmentEditorLocalThresholdLib/SegmentEditorEffect.py)

---

<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:** [January 5, 2021, 8:12pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/31 "2021-01-05T20:12:27Z")

</div>

It is probably not a coincidence that only Local Threshold and Split Volume effects use SimpleITK and they are the ones that cannot be loaded.

Could you try typing this into the Python console (Ctrl-3) and see if you get an error message?

```
import SimpleITK as sitk
```

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 8:14pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/32 "2021-01-05T20:14:26Z")

</div>

This is the responce:

> > > import SimpleITK as sitk  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > File “C:\Users\Félix\AppData\Local\NA-MIC\Slicer 4.11.20200930\lib\Python\Lib\imp.py”, line 170, in load\_source  
> > > module = \_exec(spec, sys.modules[name])  
> > > File “”, line 618, in \_exec  
> > > File “”, line 678, in exec\_module  
> > > File “”, line 219, in \_call\_with\_frames\_removed  
> > > File “C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorLocalThresholdLib/SegmentEditorEffect.py”, line 6, in   
> > > import SimpleITK as sitk  
> > > ModuleNotFoundError: No module named ‘SimpleITK’  
> > > Traceback (most recent call last):  
> > > File “C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorLocalThreshold.py”, line 27, in registerEditorEffect  
> > > instance.self().register()  
> > > AttributeError: ‘NoneType’ object has no attribute ‘register’  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > File “C:\Users\Félix\AppData\Local\NA-MIC\Slicer 4.11.20200930\lib\Python\Lib\imp.py”, line 170, in load\_source  
> > > module = \_exec(spec, sys.modules[name])  
> > > File “”, line 618, in \_exec  
> > > File “”, line 678, in exec\_module  
> > > File “”, line 219, in \_call\_with\_frames\_removed  
> > > File “C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorSplitVolumeLib/SegmentEditorEffect.py”, line 10, in   
> > > import sitkUtils  
> > > File “C:\Users\Félix\AppData\Local\NA-MIC\Slicer 4.11.20200930\bin\Python\sitkUtils.py”, line 4, in   
> > > import SimpleITK as sitk  
> > > ModuleNotFoundError: No module named ‘SimpleITK’  
> > > Traceback (most recent call last):  
> > > File “C:/Users/Félix/AppData/Roaming/NA-MIC/Extensions-29402/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorSplitVolume.py”, line 34, in registerEditorEffect  
> > > instance.self().register()  
> > > AttributeError: ‘NoneType’ object has no attribute ‘register’  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > ModuleNotFoundError: No module named ‘SimpleITK’

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 8:21pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/33 "2021-01-05T20:21:29Z")

</div>

There is no difference between the file on my pc and that from github.

---

<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:** [January 5, 2021, 8:22pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/34 "2021-01-05T20:22:57Z")

</div>

The problem is that SimpleITK is not found. Can you try if it makes a difference if you copy the entire Slicer folder to a path without special characters (for example “c:\tmp\Slicer 4.11.20200930”) and run Slicer from there?

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 8:31pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/35 "2021-01-05T20:31:21Z")

</div>

> [@lassoan](#):
>
> c:\tmp

It doesn’t chage anything. The program re-installed the extension in the C:\Users\Félix\AppData\Roaming folder and keeps on bugging…

---

<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:** [January 5, 2021, 8:36pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/36 "2021-01-05T20:36:13Z")

</div>

Could you try removing all the .ini files in [Slicer settings folder](https://slicer.readthedocs.io/en/latest/user_guide/settings.html#settings-file-location) and then start Slicer and see if `import SimpleITK as sitk` succeeds?

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 8:41pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/37 "2021-01-05T20:41:49Z")

</div>

> [@lassoan](#):
>
> `import SimpleITK as sitk`

I only have .init\_cpython files, the response of slicer was the following:

> > > import SimpleITK as sitk

Traceback (most recent call last):

File “”, line 1, in

ModuleNotFoundError: No module named ‘SimpleITK’

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/d/eded49e0caf6b05693f95a553fe5b928916d7e9a.png)

---

<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:** [January 5, 2021, 8:45pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/38 "2021-01-05T20:45:53Z")

</div>

I meant deleting all files and folders in your Slicer settings folder. Probably it is in `C:\Users\Félix\AppData\Roaming\NA-MIC`.

I also see that you have some things installed in `C:\Users\Public\NA-MIC`, which may be the root cause of all issues. Delete the content of that folder, too.

If you don’t want to delete these then you can just move somewhere else (for example, C:\tmp).

---

<div class="post-metadata">

**Author:** ![Buyck](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Buyck](https://discourse.slicer.org/u/Buyck)\
**Post date:** [January 5, 2021, 8:51pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/39 "2021-01-05T20:51:31Z")

</div>

> [@lassoan](#):
>
> `C:\Users\Félix\AppData\Roaming\NA-MIC` .

Still the same problem

---

<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:** [January 5, 2021, 8:56pm UTC](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233/40 "2021-01-05T20:56:38Z")

</div>

We can do a remote debugging session on your computer, write me your availability in a private message. We can probably find and fix the issue in a 10-20 minutes.

[Previous page](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233.md?page=1)

[Next page](https://discourse.slicer.org/t/new-segment-editor-effect-local-threshold/9233.md?page=3)
