How can I create a copy of the segment editor erase effect and rename it?

Operating system:windows 10
Slicer version:4.11

I want to create a copy of the erase effect in segment editor. I want to rename it as eraser or something like that, but I want both erase and eraser(which is a copy of erase) to exist in the segment editor module.
How can I do that?

Since Erase effect is implemented in C++, you can only change its name by building Slicer and adding a C++ loadable module that registers a variant of the Erase effect.

Alternatively, you can create a new scripted effect, based on AbstractScriptedSegmentEditorPaintEffect.py, which reproduces the same behavior as the Erase effect - similarly to SegmentEditorSmoothingEffect (just simpler, because you don’t need to do any smoothing).

In the future, we’ll probably make displayed name of the Segment Editor effect translatable to different languages, which may make it easier to rename the effect on the GUI.

1 Like

@lassoan I’m going to try the alternative method first as I haven’t built slicer. Where can I find AbstractScriptedSegmentEditorPaintEffect.py?

I found AbstractScriptedSegmentEditorPaintEffect.py. But I wanted to know what you meant by creating a new scripted effect?

You could do something similar as SegmentEditorSmoothingEffect, which is based on AbstractScriptedSegmentEditorPaintEffect to allow users to paint in views.

@lassoan I created a copy of SegmentEditorSmoothingEffect and changed its name. But this does not create a copy of the effect in slicer. Where do I need to add the files to make it appear in Slicer? I have edited the init files to include the copy as well.

I am also getting an error like this: File “C:\Users\pilht4\AppData\Local\NA-MIC\Slicer 4.11.20200930\lib\Slicer-4.11\qt-scripted-modules\SegmentEditorEffects_init_.py”, line 48, in registerEffects
instance.self().register()
AttributeError: ‘NoneType’ object has no attribute ‘register’

You can use Extension Wizard module to create
a new Segment Editor effect with a chosen name. It takes care of proper registration of the effect.