# Error using SegmentEditorExtraEffects with Python script

**URL:** <https://discourse.slicer.org/t/error-using-segmenteditorextraeffects-with-python-script/6560>\
**Category:** Support\
**Created:** [April 22, 2019, 9:56pm UTC](https://discourse.slicer.org/t/error-using-segmenteditorextraeffects-with-python-script/6560 "2019-04-22T21:56:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [April 22, 2019, 9:56pm UTC](https://discourse.slicer.org/t/error-using-segmenteditorextraeffects-with-python-script/6560/1 "2019-04-22T21:56:14Z")

</div>

Hello,  
I’m getting an error when I set SegmentEditorExtraEffects using Python. The code is still functional, as it looks like the error is generated when the GUI is updated from the scene. Other segment editor effects work just fine using the same syntax. With any segmentation and volume loaded, this code will produce an error:

```auto
segmentationNode=slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLSegmentationNode')
masterVolumeNode=slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLScalarVolumeNode')
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
segmentEditorNode = slicer.vtkMRMLSegmentEditorNode()
slicer.mrmlScene.AddNode(segmentEditorNode)
segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode)
segmentEditorWidget.setSegmentationNode(segmentationNode)
segmentEditorWidget.setMasterVolumeNode(masterVolumeNode)
segmentEditorWidget.setActiveEffectByName("Mask volume")

```

Here’s the error:

> Traceback (most recent call last):  
> File “C:/Users/srolfe/AppData/Roaming/NA-MIC/Extensions-28152/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules/SegmentEditorMaskVolumeLib/SegmentEditorEffect.py”, line 181, in updateGUIFromMRML  
> operationButton = [key for key, value in self.buttonToOperationNameMap.iteritems() if value == self.scriptedEffect.parameter(“Operation”)][0]  
> AttributeError: ‘dict’ object has no attribute ‘iteritems’

Any advice is appreciated, thanks.

---

<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:** [April 22, 2019, 10:35pm UTC](https://discourse.slicer.org/t/error-using-segmenteditorextraeffects-with-python-script/6560/2 "2019-04-22T22:35:18Z")

</div>

> [@smrolfe](#):
>
> AttributeError: ‘dict’ object has no attribute ‘iteritems’

In Python3, `iteritems` is removed from `dict`, so you need to replace it by `items`. I’ll push a fix soon.

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [April 22, 2019, 10:43pm UTC](https://discourse.slicer.org/t/error-using-segmenteditorextraeffects-with-python-script/6560/3 "2019-04-22T22:43:56Z")

</div>

Great, thanks for your help @lassoan!
