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