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

**URL:** <https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499>\
**Category:** Development\
**Tags:** python\
**Created:** [March 12, 2021, 5:04pm UTC](https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499 "2021-03-12T17:04:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [March 12, 2021, 5:04pm UTC](https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499/1 "2021-03-12T17:04:18Z")

</div>

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?

---

<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:** [March 14, 2021, 3:48pm UTC](https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499/2 "2021-03-14T15:48:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [March 15, 2021, 7:36pm UTC](https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499/3 "2021-03-15T19:36:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [March 16, 2021, 2:58pm UTC](https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499/4 "2021-03-16T14:58:01Z")

</div>

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

---

<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:** [March 16, 2021, 3:51pm UTC](https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499/5 "2021-03-16T15:51:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [March 26, 2021, 3:37pm UTC](https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499/6 "2021-03-26T15:37:51Z")

</div>

> [@lassoan](#):
>
> mething similar as SegmentEditorSmoothingEffect, which is based on AbstractScriptedSegmentEditorPaintEffect to

@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’

---

<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:** [March 29, 2021, 1:41pm UTC](https://discourse.slicer.org/t/how-can-i-create-a-copy-of-the-segment-editor-erase-effect-and-rename-it/16499/7 "2021-03-29T13:41:20Z")

</div>

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.
