Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SegmentEditorFillBetweenSlicesEffect.py
Go to the documentation of this file.
1import os
2
3import qt
4import vtk
5
6from slicer.i18n import tr as _
7
8from SegmentEditorEffects import *
9
10
12 """AutoCompleteEffect is an effect that can create a full segmentation
13 from a partial segmentation (not all slices are segmented or only
14 part of the target structures are painted).
15 """
16
17 def __init__(self, scriptedEffect):
18 AbstractScriptedSegmentEditorAutoCompleteEffect.__init__(self, scriptedEffect)
19 scriptedEffect.name = "Fill between slices" # no tr (don't translate it because modules find effects by name)
20 scriptedEffect.title = _("Fill between slices")
21
22 def clone(self):
23 import qSlicerSegmentationsEditorEffectsPythonQt as effects
24
25 clonedEffect = effects.qSlicerSegmentEditorScriptedEffect(None)
26 clonedEffect.setPythonSource(__file__.replace("\\", "/"))
27 return clonedEffect
28
29 def icon(self):
30 iconPath = os.path.join(os.path.dirname(__file__), "Resources/Icons/FillBetweenSlices.png")
31 if os.path.exists(iconPath):
32 return qt.QIcon(iconPath)
33 return qt.QIcon()
34
35 def helpText(self):
36 return "<html>" + _("""Interpolate segmentation between slices<br>. Instructions:
37<p><ul>
38<li>Create complete segmentation on selected slices using any editor effect.
39Segmentation will only expanded if a slice is segmented but none of the direct neighbors are segmented, therefore
40do not use sphere brush with Paint effect and always leave at least one empty slice between segmented slices.
41<li>All visible segments will be interpolated, not just the selected segment.
42<li>The complete segmentation will be created by interpolating segmentations in empty slices.
43</ul><p>
44Masking settings are ignored. If segments overlap, segment higher in the segments table will have priority.
45The effect uses <a href="https://insight-journal.org/browse/publication/977">morphological contour interpolation method</a>.
46<p>""")
47
48 def computePreviewLabelmap(self, mergedImage, outputLabelmap):
49 import vtkITK
50
51 interpolator = vtkITK.vtkITKMorphologicalContourInterpolator()
52 interpolator.SetInputData(mergedImage)
53 interpolator.Update()
54 outputLabelmap.DeepCopy(interpolator.GetOutput())
55 imageToWorld = vtk.vtkMatrix4x4()
56 mergedImage.GetImageToWorldMatrix(imageToWorld)
57 outputLabelmap.SetImageToWorldMatrix(imageToWorld)