def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # initialise any mixins we might have NoConfigModuleMixin.__init__(self) # we'll be playing around with some vtk objects, this could # be anything self._thresh = vtk.vtkThresholdPoints() # this is wacked syntax! self._thresh.ThresholdByUpper(1) self._reconstructionFilter = vtk.vtkSurfaceReconstructionFilter() self._reconstructionFilter.SetInput(self._thresh.GetOutput()) self._mc = vtk.vtkMarchingCubes() self._mc.SetInput(self._reconstructionFilter.GetOutput()) self._mc.SetValue(0, 0.0) module_utils.setup_vtk_object_progress(self, self._thresh, 'Extracting points...') module_utils.setup_vtk_object_progress(self, self._reconstructionFilter, 'Reconstructing...') module_utils.setup_vtk_object_progress(self, self._mc, 'Extracting surface...') self._iObj = self._thresh self._oObj = self._mc self._viewFrame = self._createViewFrame({'threshold' : self._thresh, 'reconstructionFilter' : self._reconstructionFilter, 'marchingCubes' : self._mc})
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # initialise any mixins we might have NoConfigModuleMixin.__init__(self) self._imageReslice = vtk.vtkImageReslice() self._imageReslice.SetInterpolationModeToCubic() self._matrixToHT = vtk.vtkMatrixToHomogeneousTransform() self._matrixToHT.Inverse() module_utils.setup_vtk_object_progress(self, self._imageReslice, 'Resampling volume') self._viewFrame = self._createViewFrame({ 'Module (self)': self, 'vtkImageReslice': self._imageReslice }) # pass the data down to the underlying logic self.config_to_logic() # and all the way up from logic -> config -> view to make sure self.syncViewWithLogic()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # initialise any mixins we might have NoConfigModuleMixin.__init__(self) self._imageReslice = vtk.vtkImageReslice() self._imageReslice.SetInterpolationModeToCubic() self._matrixToHT = vtk.vtkMatrixToHomogeneousTransform() self._matrixToHT.Inverse() module_utils.setup_vtk_object_progress(self, self._imageReslice, 'Resampling volume') self._viewFrame = self._createViewFrame( {'Module (self)' : self, 'vtkImageReslice' : self._imageReslice}) # pass the data down to the underlying logic self.config_to_logic() # and all the way up from logic -> config -> view to make sure self.syncViewWithLogic()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # we'll be playing around with some vtk objects, this could # be anything self._triangleFilter = vtk.vtkTriangleFilter() self._curvatures = vtk.vtkCurvatures() self._curvatures.SetCurvatureTypeToMaximum() self._curvatures.SetInput(self._triangleFilter.GetOutput()) # initialise any mixins we might have NoConfigModuleMixin.__init__(self, {'Module (self)' : self, 'vtkTriangleFilter' : self._triangleFilter, 'vtkCurvatures' : self._curvatures}) module_utils.setup_vtk_object_progress(self, self._triangleFilter, 'Triangle filtering...') module_utils.setup_vtk_object_progress(self, self._curvatures, 'Calculating curvatures...') self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__(self, {'Module (self)': self}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # we'll be playing around with some vtk objects, this could # be anything self._triangleFilter = vtk.vtkTriangleFilter() self._curvatures = vtk.vtkCurvatures() self._curvatures.SetCurvatureTypeToMaximum() self._curvatures.SetInput(self._triangleFilter.GetOutput()) # initialise any mixins we might have NoConfigModuleMixin.__init__( self, { 'Module (self)': self, 'vtkTriangleFilter': self._triangleFilter, 'vtkCurvatures': self._curvatures }) module_utils.setup_vtk_object_progress(self, self._triangleFilter, 'Triangle filtering...') module_utils.setup_vtk_object_progress(self, self._curvatures, 'Calculating curvatures...') self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # what a lame-assed filter, we have to make dummy inputs! # if we don't have a dummy input (but instead a None input) it # bitterly complains when we do a GetOutput() (it needs the input # to know the type of the output) - and GetPolyDataOutput() also # doesn't work. # NB: this does mean that our probeFilter NEEDS a PolyData as # probe geometry! ss = vtk.vtkSphereSource() ss.SetRadius(0) self._dummyInput = ss.GetOutput() #This is also retarded - we (sometimes, see below) need the "padder" #to get the image extent big enough to satisfy the probe filter. #No apparent logical reason, but it throws an exception if we don't. self._padder = vtk.vtkImageConstantPad() self._source = None self._input = None self._probeFilter = vtk.vtkProbeFilter() self._probeFilter.SetInput(self._dummyInput) NoConfigModuleMixin.__init__( self, {'Module (self)' : self, 'vtkProbeFilter' : self._probeFilter}) module_utils.setup_vtk_object_progress(self, self._probeFilter, 'Mapping source on input') self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__( self, {'Module (self)' : self}) self.sync_module_logic_with_config()
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # this will take care of all display thingies NoConfigModuleMixin.close(self)
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # this will take care of GUI NoConfigModuleMixin.close(self)
def close(self): # disconnect all inputs self.set_input(0, None) self.set_input(1, None) # take care of critical instances self._outputPolyData = None # mixin close NoConfigModuleMixin.close(self)
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__(self, {'Module (self)': self}) self.sync_module_logic_with_config() self._ir = vtk.vtkImageReslice() self._ici = vtk.vtkImageChangeInformation()
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # don't forget to call the close() method of the vtkPipeline mixin NoConfigModuleMixin.close(self) # get rid of our reference del self._imageReslice
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) self.set_input(0, None) self.set_input(1, None) # don't forget to call the close() method of the vtkPipeline mixin NoConfigModuleMixin.close(self) # take out our view interface del self._imageBacktracker ModuleBase.close(self)
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__( self, {'Module (self)' : self}) self.sync_module_logic_with_config() self._ir = vtk.vtkImageReslice() self._ici = vtk.vtkImageChangeInformation()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # initialise any mixins we might have NoConfigModuleMixin.__init__(self) self._distance = vtk.vtkImageEuclideanDistance() # this seems to yield more accurate results in this case # it would probably be better to calculate only 2d distance fields self._distance.ConsiderAnisotropyOff() self._xEndPoints = [] self._noFlipXes = [] self._pf1 = vtk.vtkProgrammableFilter() # yeah self._pf1.SetInput(self._distance.GetOutput()) self._pf1.SetExecuteMethod(self.pf1Execute) self._pf2 = vtk.vtkProgrammableFilter() self._pf2.SetInput(self._pf1.GetOutput()) self._pf2.SetExecuteMethod(self.pf2Execute) self._mc = vtk.vtkMarchingCubes() self._mc.SetInput(self._pf1.GetOutput()) self._mc.SetValue(0, 0.1) self._iv = vtk.vtkImplicitVolume() self._iv.SetVolume(self._pf2.GetOutput()) self._cpd = vtk.vtkClipPolyData() self._cpd.SetClipFunction(self._iv) self._cpd.SetInput(self._mc.GetOutput()) #self._cpd.InsideOutOn() module_utils.setup_vtk_object_progress( self, self._distance, 'Calculating distance field...') module_utils.setup_vtk_object_progress(self, self._pf1, 'Signing distance field...') module_utils.setup_vtk_object_progress(self, self._pf2, 'Creating implicit volume...') module_utils.setup_vtk_object_progress(self, self._mc, 'Extracting isosurface...') module_utils.setup_vtk_object_progress(self, self._cpd, 'Clipping isosurface...') self._iObj = self._distance self._oObj = self._cpd #self._oObj = self._pf2 self._viewFrame = self._createViewFrame({ 'distance': self._distance, 'pf1': self._pf1, 'pf2': self._pf2, 'mc': self._mc, 'cpd': self._cpd })
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # this will take care of all display thingies NoConfigModuleMixin.close(self) # get rid of our reference del self._imageFlip
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # this will take care of all display thingies NoConfigModuleMixin.close(self) # get rid of our reference del self._imageGradientStructureTensor
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._clipPolyData = vtk.vtkClipPolyData() module_utils.setup_vtk_object_progress(self, self._clipPolyData, 'Calculating normals') NoConfigModuleMixin.__init__(self, {'vtkClipPolyData': self._clipPolyData}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__(self) # these will be our markers self._inputPoints = None # we can't connect the image input directly to the masksource, # so we have to keep track of it separately. self._inputImage = None self._inputImageObserverID = None # we need to modify the mask (I) as well. The problem with a # ProgrammableFilter is that you can't request GetOutput() before # the input has been set... self._maskSource = vtk.vtkProgrammableSource() self._maskSource.SetExecuteMethod(self._maskSourceExecute) # we'll use this to synthesise a volume according to the seed points self._markerSource = vtk.vtkProgrammableSource() self._markerSource.SetExecuteMethod(self._markerSourceExecute) # second input is J (the marker) # we'll use this to change the markerImage into something we can use self._imageThreshold = vtk.vtkImageThreshold() # everything equal to or above 1.0 will be "on" self._imageThreshold.ThresholdByUpper(1.0) self._imageThresholdObserverID = self._imageThreshold.AddObserver( 'EndEvent', self._observerImageThreshold) self._viewFrame = self._createViewFrame( {'Module (self)' : self}) # we're not going to give imageErode any input... that's going to # to happen manually in the execute_module function :) self._imageErode = vtk.vtkImageContinuousErode3D() self._imageErode.SetKernelSize(3,3,3) module_utils.setup_vtk_object_progress(self, self._imageErode, 'Performing greyscale 3D erosion') self._sup = vtk.vtkImageMathematics() self._sup.SetOperationToMax() self._sup.SetInput1(self._imageErode.GetOutput()) self._sup.SetInput2(self._maskSource.GetStructuredPointsOutput()) # pass the data down to the underlying logic self.config_to_logic() # and all the way up from logic -> config -> view to make sure self.syncViewWithLogic()
def close(self): # just in case self.set_input(0, None) self.set_input(1, None) # take care of our refs so that things can disappear self._destroyPipelines() del self._itkExporterStack del self._imageAppend NoConfigModuleMixin.close(self) ModuleBase.close(self)
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._transformPolyData = vtk.vtkTransformPolyDataFilter() NoConfigModuleMixin.__init__( self, {'vtkTransformPolyDataFilter' : self._transformPolyData}) module_utils.setup_vtk_object_progress(self, self._transformPolyData, 'Transforming geometry') self.sync_module_logic_with_config()
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # this will take care of all display thingies NoConfigModuleMixin.close(self) # and the baseclass close ModuleBase.close(self) # remove all bindings del self._laplacian
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._input = None self._itk2vtk = None NoConfigModuleMixin.__init__( self, {'Module (self)' : self, 'ImageToVTKImageFilter' : self._itk2vtk}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._pdNormals = vtk.vtkPolyDataNormals() module_utils.setup_vtk_object_progress(self, self._pdNormals, 'Calculating normals') NoConfigModuleMixin.__init__( self, {'vtkPolyDataNormals' : self._pdNormals}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # initialise any mixins we might have NoConfigModuleMixin.__init__(self) mm = self._module_manager self._cleaner = vtk.vtkCleanPolyData() self._tf = vtk.vtkTriangleFilter() self._tf.SetInput(self._cleaner.GetOutput()) self._wspdf = vtk.vtkWindowedSincPolyDataFilter() #self._wspdf.SetNumberOfIterations(50) self._wspdf.SetInput(self._tf.GetOutput()) self._wspdf.SetProgressText('smoothing') self._wspdf.SetProgressMethod( lambda s=self, mm=mm: mm.vtk_progress_cb(s._wspdf)) self._cleaner2 = vtk.vtkCleanPolyData() self._cleaner2.SetInput(self._wspdf.GetOutput()) self._curvatures = vtk.vtkCurvatures() self._curvatures.SetCurvatureTypeToMean() self._curvatures.SetInput(self._cleaner2.GetOutput()) self._tf.SetProgressText('triangulating') self._tf.SetProgressMethod( lambda s=self, mm=mm: mm.vtk_progress_cb(s._tf)) self._curvatures.SetProgressText('calculating curvatures') self._curvatures.SetProgressMethod( lambda s=self, mm=mm: mm.vtk_progress_cb(s._curvatures)) self._inputFilter = self._tf self._inputPoints = None self._inputPointsOID = None self._giaGlenoid = None self._outsidePoints = None self._outputPolyDataARB = vtk.vtkPolyData() self._outputPolyDataHM = vtk.vtkPolyData() self._createViewFrame('Test Module View', { 'vtkTriangleFilter': self._tf, 'vtkCurvatures': self._curvatures }) self._viewFrame.Show(True)
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__(self) # these will be our markers self._inputPoints = None # we can't connect the image input directly to the masksource, # so we have to keep track of it separately. self._inputImage = None self._inputImageObserverID = None # we need to modify the mask (I) as well. The problem with a # ProgrammableFilter is that you can't request GetOutput() before # the input has been set... self._maskSource = vtk.vtkProgrammableSource() self._maskSource.SetExecuteMethod(self._maskSourceExecute) # we'll use this to synthesise a volume according to the seed points self._markerSource = vtk.vtkProgrammableSource() self._markerSource.SetExecuteMethod(self._markerSourceExecute) # second input is J (the marker) # we'll use this to change the markerImage into something we can use self._imageThreshold = vtk.vtkImageThreshold() # everything equal to or above 1.0 will be "on" self._imageThreshold.ThresholdByUpper(1.0) self._imageThresholdObserverID = self._imageThreshold.AddObserver( 'EndEvent', self._observerImageThreshold) self._viewFrame = self._createViewFrame({'Module (self)': self}) # we're not going to give imageErode any input... that's going to # to happen manually in the execute_module function :) self._imageErode = vtk.vtkImageContinuousErode3D() self._imageErode.SetKernelSize(3, 3, 3) module_utils.setup_vtk_object_progress( self, self._imageErode, 'Performing greyscale 3D erosion') self._sup = vtk.vtkImageMathematics() self._sup.SetOperationToMax() self._sup.SetInput1(self._imageErode.GetOutput()) self._sup.SetInput2(self._maskSource.GetStructuredPointsOutput()) # pass the data down to the underlying logic self.config_to_logic() # and all the way up from logic -> config -> view to make sure self.syncViewWithLogic()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageFlip = vtk.vtkImageFlip() self._imageFlip.SetFilteredAxis(2) self._imageFlip.GetOutput().SetUpdateExtentToWholeExtent() module_utils.setup_vtk_object_progress(self, self._imageFlip, 'Flipping image') NoConfigModuleMixin.__init__(self, {'vtkImageFlip': self._imageFlip}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # these will be our markers self._inputPoints = None # we can't connect the image input directly to the masksource, # so we have to keep track of it separately. self._inputImage = None self._inputImageObserverID = None # we need to modify the mask (I) as well. The problem with a # ProgrammableFilter is that you can't request GetOutput() before # the input has been set... self._maskSource = vtk.vtkProgrammableSource() self._maskSource.SetExecuteMethod(self._maskSourceExecute) self._dualGreyReconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D() # first input is I (the modified mask) self._dualGreyReconstruct.SetDual(1) self._dualGreyReconstruct.SetInput1( self._maskSource.GetStructuredPointsOutput()) # we'll use this to synthesise a volume according to the seed points self._markerSource = vtk.vtkProgrammableSource() self._markerSource.SetExecuteMethod(self._markerSourceExecute) # second input is J (the marker) self._dualGreyReconstruct.SetInput2( self._markerSource.GetStructuredPointsOutput()) # we'll use this to change the markerImage into something we can use self._imageThreshold = vtk.vtkImageThreshold() # everything equal to or above 1.0 will be "on" self._imageThreshold.ThresholdByUpper(1.0) self._imageThresholdObserverID = self._imageThreshold.AddObserver( 'EndEvent', self._observerImageThreshold) module_utils.setup_vtk_object_progress( self, self._dualGreyReconstruct, 'Performing dual greyscale reconstruction') NoConfigModuleMixin.__init__( self, { 'Module (self)': self, 'vtkImageGreyscaleReconstruct3D': self._dualGreyReconstruct }) self.sync_module_logic_with_config()
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # this will take care of all display thingies NoConfigModuleMixin.close(self) # get rid of our reference del self._probeFilter del self._dummyInput del self._padder del self._source del self._input
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # setup the pipeline self._imageCast = vtk.vtkImageCast() self._imageCast.SetOutputScalarTypeToFloat() self._vtk2itk = itk.VTKImageToImageFilter[itk.Image[itk.F, 3]].New() self._vtk2itk.SetInput(self._imageCast.GetOutput()) NoConfigModuleMixin.__init__( self, {"Module (self)": self, "vtkImageCast": self._imageCast, "VTKImageToImageFilter": self._vtk2itk} ) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # underlying VTK thingy self._appendPolyData = vtk.vtkAppendPolyData() # our own list of inputs self._inputStreams = self._numInputs * [None] module_utils.setup_vtk_object_progress(self, self._appendPolyData, 'Appending PolyData') NoConfigModuleMixin.__init__( self, {'vtkAppendPolyData': self._appendPolyData}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__(self) self._imageEigenvectors = vtktud.vtkImageEigenvectors() # module_utils.setup_vtk_object_progress(self, self._clipPolyData, # 'Calculating normals') self._viewFrame = self._createViewFrame({"ImageEigenvectors": self._imageEigenvectors}) # pass the data down to the underlying logic self.config_to_logic() # and all the way up from logic -> config -> view to make sure self.syncViewWithLogic()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._greyReconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D() NoConfigModuleMixin.__init__( self, {'Module (self)' : self, 'vtkImageGreyscaleReconstruct3D' : self._greyReconstruct}) module_utils.setup_vtk_object_progress( self, self._greyReconstruct, 'Performing greyscale reconstruction') self.sync_module_logic_with_config()
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # don't forget to call the close() method of the vtkPipeline mixin NoConfigModuleMixin.close(self) # get rid of our reference del self._cleaner del self._cleaner2 del self._wspdf del self._curvatures del self._tf del self._inputPoints del self._outputPolyDataARB del self._outputPolyDataHM
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__(self) self._imageCurvature = vtktud.vtkImageCurvature() # module_utils.setup_vtk_object_progress(self, self._clipPolyData, # 'Calculating normals') self._viewFrame = self._createViewFrame( {'ImageCurvature' : self._imageCurvature}) # pass the data down to the underlying logic self.config_to_logic() # and all the way up from logic -> config -> view to make sure self.syncViewWithLogic()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # setup the pipeline if3 = itk.Image[itk.F, 3] self._laplacian = itk.LaplacianImageFilter[if3, if3].New() itk_kit.utils.setupITKObjectProgress(self, self._laplacian, 'itkLaplacianImageFilter', 'Calculating Laplacian') NoConfigModuleMixin.__init__(self, { 'Module (self)': self, 'itkLaplacianImageFilter': self._laplacian }) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__(self) self._imageStack = None self._transformStack = None # self._itkExporterStack = [] self._imageAppend = vtk.vtkImageAppend() # stack of images should become volume self._imageAppend.SetAppendAxis(2) self._viewFrame = self._createViewFrame({'Module (self)': self}) self.config_to_logic() self.logic_to_config() self.config_to_view()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageGradientMagnitude = vtk.vtkImageGradientMagnitude() self._imageGradientMagnitude.SetDimensionality(3) module_utils.setup_vtk_object_progress(self, self._imageGradientMagnitude, 'Calculating gradient magnitude') NoConfigModuleMixin.__init__( self, {'Module (self)' : self, 'vtkImageGradientMagnitude' : self._imageGradientMagnitude}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._image_data_streamer = vtk.vtkImageDataStreamer() self._poly_data_streamer = vtk.vtkPolyDataStreamer() NoConfigModuleMixin.__init__(self, {'module (self)' : self, 'vtkImageDataStreamer' : self._image_data_streamer, 'vtkPolyDataStreamer' : self._poly_data_streamer}) module_utils.setup_vtk_object_progress(self, self._image_data_streamer, 'Streaming image data') self._current_mode = None self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # underlying VTK thingy self._appendPolyData = vtk.vtkAppendPolyData() # our own list of inputs self._inputStreams = self._numInputs * [None] module_utils.setup_vtk_object_progress(self, self._appendPolyData, 'Appending PolyData') NoConfigModuleMixin.__init__( self, {'vtkAppendPolyData' : self._appendPolyData}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageFlip = vtk.vtkImageFlip() self._imageFlip.SetFilteredAxis(2) self._imageFlip.GetOutput().SetUpdateExtentToWholeExtent() module_utils.setup_vtk_object_progress(self, self._imageFlip, 'Flipping image') NoConfigModuleMixin.__init__( self, {'vtkImageFlip' : self._imageFlip}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # setup the pipeline self._imageCast = vtk.vtkImageCast() self._imageCast.SetOutputScalarTypeToFloat() self._vtk2itk = itk.VTKImageToImageFilter[itk.Image[itk.F, 3]].New() self._vtk2itk.SetInput(self._imageCast.GetOutput()) NoConfigModuleMixin.__init__( self, {'Module (self)' : self, 'vtkImageCast' : self._imageCast, 'VTKImageToImageFilter' : self._vtk2itk}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # call parent constructor ModuleBase.__init__(self, module_manager) # and mixin NoConfigModuleMixin.__init__(self) self._inputPolyData = None self._inputPoints = None self._inputPointsOID = None self._giaGlenoid = None self._giaHumerus = None self._glenoidEdge = None self._outputPolyData = vtk.vtkPolyData() # create the frame and display it proudly! self._viewFrame = self._createViewFrame( {'Output Polydata': self._outputPolyData})
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageGradientMagnitude = vtk.vtkImageGradientMagnitude() self._imageGradientMagnitude.SetDimensionality(3) module_utils.setup_vtk_object_progress( self, self._imageGradientMagnitude, 'Calculating gradient magnitude') NoConfigModuleMixin.__init__( self, { 'Module (self)': self, 'vtkImageGradientMagnitude': self._imageGradientMagnitude }) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) NoConfigModuleMixin.__init__(self) self._imageStack = None self._transformStack = None # self._itkExporterStack = [] self._imageAppend = vtk.vtkImageAppend() # stack of images should become volume self._imageAppend.SetAppendAxis(2) self._viewFrame = self._createViewFrame( {'Module (self)' : self}) self.config_to_logic() self.logic_to_config() self.config_to_view()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageReslice = vtk.vtkImageReslice() self._imageReslice.SetInterpolationModeToCubic() self._imageReslice.SetAutoCropOutput(1) # initialise any mixins we might have NoConfigModuleMixin.__init__(self, { 'Module (self)': self, 'vtkImageReslice': self._imageReslice }) module_utils.setup_vtk_object_progress(self, self._imageReslice, 'Resampling volume') self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # initialise any mixins we might have NoConfigModuleMixin.__init__(self) mm = self._module_manager self._cleaner = vtk.vtkCleanPolyData() self._tf = vtk.vtkTriangleFilter() self._tf.SetInput(self._cleaner.GetOutput()) self._wspdf = vtk.vtkWindowedSincPolyDataFilter() # self._wspdf.SetNumberOfIterations(50) self._wspdf.SetInput(self._tf.GetOutput()) self._wspdf.SetProgressText("smoothing") self._wspdf.SetProgressMethod(lambda s=self, mm=mm: mm.vtk_progress_cb(s._wspdf)) self._cleaner2 = vtk.vtkCleanPolyData() self._cleaner2.SetInput(self._wspdf.GetOutput()) self._curvatures = vtk.vtkCurvatures() self._curvatures.SetCurvatureTypeToMean() self._curvatures.SetInput(self._cleaner2.GetOutput()) self._tf.SetProgressText("triangulating") self._tf.SetProgressMethod(lambda s=self, mm=mm: mm.vtk_progress_cb(s._tf)) self._curvatures.SetProgressText("calculating curvatures") self._curvatures.SetProgressMethod(lambda s=self, mm=mm: mm.vtk_progress_cb(s._curvatures)) self._inputFilter = self._tf self._inputPoints = None self._inputPointsOID = None self._giaGlenoid = None self._outsidePoints = None self._outputPolyDataARB = vtk.vtkPolyData() self._outputPolyDataHM = vtk.vtkPolyData() self._createViewFrame("Test Module View", {"vtkTriangleFilter": self._tf, "vtkCurvatures": self._curvatures}) self._viewFrame.Show(True)
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) # these will be our markers self._inputPoints = None # we can't connect the image input directly to the masksource, # so we have to keep track of it separately. self._inputImage = None self._inputImageObserverID = None # we need to modify the mask (I) as well. The problem with a # ProgrammableFilter is that you can't request GetOutput() before # the input has been set... self._maskSource = vtk.vtkProgrammableSource() self._maskSource.SetExecuteMethod(self._maskSourceExecute) self._dualGreyReconstruct = vtkdevide.vtkImageGreyscaleReconstruct3D() # first input is I (the modified mask) self._dualGreyReconstruct.SetDual(1) self._dualGreyReconstruct.SetInput1(self._maskSource.GetStructuredPointsOutput()) # we'll use this to synthesise a volume according to the seed points self._markerSource = vtk.vtkProgrammableSource() self._markerSource.SetExecuteMethod(self._markerSourceExecute) # second input is J (the marker) self._dualGreyReconstruct.SetInput2(self._markerSource.GetStructuredPointsOutput()) # we'll use this to change the markerImage into something we can use self._imageThreshold = vtk.vtkImageThreshold() # everything equal to or above 1.0 will be "on" self._imageThreshold.ThresholdByUpper(1.0) self._imageThresholdObserverID = self._imageThreshold.AddObserver("EndEvent", self._observerImageThreshold) module_utils.setup_vtk_object_progress( self, self._dualGreyReconstruct, "Performing dual greyscale reconstruction" ) NoConfigModuleMixin.__init__( self, {"Module (self)": self, "vtkImageGreyscaleReconstruct3D": self._dualGreyReconstruct} ) self.sync_module_logic_with_config()
def close(self): # we play it safe... (the graph_editor/module_manager should have # disconnected us by now) for input_idx in range(len(self.get_input_descriptions())): self.set_input(input_idx, None) # this will take care of all display thingies NoConfigModuleMixin.close(self) ModuleBase.close(self) # self._imageThreshold.RemoveObserver(self._imageThresholdObserverID) # get rid of our reference del self._dualGreyReconstruct del self._markerSource del self._maskSource del self._imageThreshold