def close(self): ScriptedConfigModuleMixin.close(self) # get rid of our reference del self._icp ModuleBase.close(self)
def __init__(self, module_manager): # call the parent constructor ModuleBase.__init__(self, module_manager) # this is our output self._transformStack = transformStackClass( self ) # module_utils.setup_vtk_object_progress(self, self._reader, # 'Fetching transformStack from database...') self._config.databaseFile = "" self._config.reconstructionName = "--- select a value ---" configList = [ ('Database:', 'databaseFile', 'base:str', 'filebrowser', 'Database from which to fetch a reconstruction''s transformStack.', {'fileMode' : wx.OPEN, 'fileMask' : 'MDB files (*.mdb)|*.mdb|All files (*.*)|*.*'}), ('Reconstruction:', 'reconstructionName', 'base:str', 'choice', 'Specific reconstruction to use.', ("--- select a value ---",) ) ] ScriptedConfigModuleMixin.__init__(self, configList) self._viewFrame = self._createViewFrame({'Module (self)' : self}) self.config_to_logic() self.syncViewWithLogic()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._tubeFilter = vtk.vtkTubeFilter() module_utils.setup_vtk_object_progress(self, self._tubeFilter, 'Generating tubes.') self._config.NumberOfSides = 3 self._config.Radius = 0.01 configList = [('Number of sides:', 'NumberOfSides', 'base:int', 'text', 'Number of sides that the tube should have.'), ('Tube radius:', 'Radius', 'base:float', 'text', 'Radius of the generated tube.')] ScriptedConfigModuleMixin.__init__(self, configList) self._viewFrame = self._createWindow({ 'Module (self)': self, 'vtkTubeFilter': self._tubeFilter }) # 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._image_logic = vtk.vtkImageLogic() module_utils.setup_vtk_object_progress(self, self._image_logic, 'Performing image logic') self._image_cast = vtk.vtkImageCast() module_utils.setup_vtk_object_progress( self, self._image_cast, 'Casting scalar type before image logic') self._config.operation = 0 self._config.output_true_value = 1.0 # 'choice' widget with 'base:int' type will automatically get cast # to index of selection that user makes. config_list = [ ('Operation:', 'operation', 'base:int', 'choice', 'The operation that should be performed.', tuple(self._operations)), ('Output true value:', 'output_true_value', 'base:float', 'text', 'Output voxels that are TRUE will get this value.') ] ScriptedConfigModuleMixin.__init__(self, config_list, { 'Module (self)': self, 'vtkImageLogic': self._image_logic }) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageSepConvolution = vtktud.vtkImageSepConvolution() # module_utils.setup_vtk_object_progress(self, self._clipper, # 'Reading PNG images.') # set information for ScriptedConfigModuleMixin self._config.axis = 0 # FIXME: include options for kernel normalisation? configList = [('Axis:', 'axis', 'base:int', 'choice', 'Axis over which convolution is to be performed.', ("X", "Y", "Z"))] ScriptedConfigModuleMixin.__init__(self, configList) self._viewFrame = self._createViewFrame({ 'Module (self)': self, 'vtkImageSepConvolution': self._imageSepConvolution }) # 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) self._histogram = vtkdevide.vtkImageHistogram2D() module_utils.setup_vtk_object_progress(self, self._histogram, 'Calculating 2D histogram') self._config.input1Bins = 256 self._config.input2Bins = 256 self._config.maxSamplesPerBin = 512 configList = [ ('Number of bins for input 1', 'input1Bins', 'base:int', 'text', 'The full range of input 1 values will be divided into this many ' 'classes.'), ('Number of bins for input 2', 'input2Bins', 'base:int', 'text', 'The full range of input 2 values will be divided into this many ' 'classes.'), ('Maximum samples per bin', 'maxSamplesPerBin', 'base:int', 'text', 'The number of samples per 2D bin/class will be truncated to ' 'this value.')] ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkImageHistogram2D' : self._histogram}) self.sync_module_logic_with_config() self._input0 = None self._input1 = None
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.numberOfIterations = 3 self._config.timeStep = 0.05 configList = [ ('Number of iterations:', 'numberOfIterations', 'base:int', 'text', 'Number of update iterations that will be performed.'), ('Timestep:', 'timeStep', 'base:float', 'text', 'Timestep between update iterations.') ] # setup the pipeline if3 = itk.Image[itk.F, 3] self._cfif = itk.CurvatureFlowImageFilter[if3, if3].New() itk_kit.utils.setupITKObjectProgress(self, self._cfif, 'itkCurvatureFlowImageFilter', 'Denoising data') ScriptedConfigModuleMixin.__init__( self, configList, { 'Module (self)': self, 'itkCurvatureFlowImageFilter': self._cfif }) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageSepConvolution = vtktud.vtkImageSepConvolution() # module_utils.setup_vtk_object_progress(self, self._clipper, # 'Reading PNG images.') # set information for ScriptedConfigModuleMixin self._config.axis = 0 # FIXME: include options for kernel normalisation? configList = [ ('Axis:', 'axis', 'base:int', 'choice', 'Axis over which convolution is to be performed.', ("X", "Y", "Z") ) ] ScriptedConfigModuleMixin.__init__(self, configList) self._viewFrame = self._createViewFrame( {'Module (self)' : self, 'vtkImageSepConvolution' : self._imageSepConvolution}) # 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._implicitModeller = vtk.vtkImplicitModeller() module_utils.setup_vtk_object_progress( self, self._implicitModeller, 'Converting surface to distance field') self._config.bounds = (-1, 1, -1, 1, -1, 1) self._config.dimensions = (64, 64, 64) self._config.maxDistance = 0.1 configList = [ ('Bounds:', 'bounds', 'tuple:float,6', 'text', 'The physical location of the sampled volume in space ' '(x0, x1, y0, y1, z0, z1)'), ('Dimensions:', 'dimensions', 'tuple:int,3', 'text', 'The number of points that should be sampled in each dimension.'), ('Maximum distance:', 'maxDistance', 'base:float', 'text', 'The distance will only be calculated up to this maximum.')] ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkImplicitModeller' : self._implicitModeller}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # call parent constructor ModuleBase.__init__(self, module_manager) # the decimator only works on triangle data, so we make sure # that it only gets triangle data self._triFilter = vtk.vtkTriangleFilter() self._decimate = vtk.vtkDecimatePro() self._decimate.PreserveTopologyOn() self._decimate.SetInput(self._triFilter.GetOutput()) module_utils.setup_vtk_object_progress(self, self._triFilter, 'Converting to triangles') module_utils.setup_vtk_object_progress(self, self._decimate, 'Decimating mesh') # now setup some defaults before our sync self._config.target_reduction = self._decimate.GetTargetReduction() \ * 100.0 config_list = [ ('Target reduction (%):', 'target_reduction', 'base:float', 'text', 'Decimate algorithm will attempt to reduce by this much.')] ScriptedConfigModuleMixin.__init__( self, config_list, {'Module (self)' : self, 'vtkDecimatePro' : self._decimate, 'vtkTriangleFilter' : self._triFilter}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) InputArrayChoiceMixin.__init__(self) self._config.scaleFactor = 1 configList = [ ('Scale factor:', 'scaleFactor', 'base:float', 'text', 'The warping will be scaled by this factor'), ('Vectors selection:', 'vectorsSelection', 'base:str', 'choice', 'The attribute that will be used as vectors for the warping.', (self._defaultVectorsSelectionString, self._userDefinedString))] self._warpVector = vtk.vtkWarpVector() ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkWarpVector' : self._warpVector}) module_utils.setup_vtk_object_progress(self, self._warpVector, 'Warping points.') self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.numberOfIterations = 3 self._config.timeStep = 0.05 configList = [ ('Number of iterations:', 'numberOfIterations', 'base:int', 'text', 'Number of update iterations that will be performed.'), ('Timestep:', 'timeStep', 'base:float', 'text', 'Timestep between update iterations.')] # setup the pipeline if3 = itk.Image[itk.F, 3] self._cfif = itk.CurvatureFlowImageFilter[if3, if3].New() itk_kit.utils.setupITKObjectProgress( self, self._cfif, 'itkCurvatureFlowImageFilter', 'Denoising data') ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'itkCurvatureFlowImageFilter' : self._cfif}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # call parent constructor ModuleBase.__init__(self, module_manager) self._imageInput = None self._meshInput = None self._flipper = vtk.vtkImageFlip() self._flipper.SetFilteredAxis(1) module_utils.setup_vtk_object_progress( self, self._flipper, 'Flipping Y axis.') self._config.cpt_driver_path = \ 'd:\\misc\\stuff\\driver.bat' #'/home/cpbotha/build/cpt/3d/driver/driver.exe' self._config.max_distance = 5 config_list = [ ('CPT driver path', 'cpt_driver_path', 'base:str', 'filebrowser', 'Path to CPT driver executable', {'fileMode' : module_mixins.wx.OPEN, 'fileMask' : 'All files (*.*)|*.*'}), ('Maximum distance', 'max_distance', 'base:float', 'text', 'The maximum (absolute) distance up to which the field is computed.')] ScriptedConfigModuleMixin.__init__( self, config_list, {'Module (self)' : self}) self.sync_module_logic_with_config()
def config_to_view(self): # first get our parent mixin to do its thing ScriptedConfigModuleMixin.config_to_view(self) # the vector choice is the second configTuple choice = self._getWidget(5) self.iac_config_to_view(choice)
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageDilate = vtk.vtkImageContinuousDilate3D() module_utils.setup_vtk_object_progress(self, self._imageDilate, 'Performing greyscale 3D dilation') self._config.kernelSize = (3, 3, 3) configList = [ ('Kernel size:', 'kernelSize', 'tuple:int,3', 'text', 'Size of the kernel in x,y,z dimensions.')] ScriptedConfigModuleMixin.__init__(self, configList) self._viewFrame = self._createWindow( {'Module (self)' : self, 'vtkImageContinuousDilate3D' : self._imageDilate}) # 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.logic_to_config() self.config_to_view()
def __init__(self, module_manager): # call parent constructor ModuleBase.__init__(self, module_manager) # ctor for this specific mixin # FilenameViewModuleMixin.__init__(self) self._input_image = None self._foreground_points = None self._background_points = None self._config.filename = '' configList = [ ('Result file name:', 'filename', 'base:str', 'filebrowser', 'Y/N result will be written to this file.', {'fileMode' : WX_SAVE, 'fileMask' : 'All files (*.*)|*.*'})] ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.gaussianSigma = 0.7 self._config.normaliseAcrossScale = False configList = [ ('Gaussian sigma', 'gaussianSigma', 'base:float', 'text', 'Sigma in terms of image spacing.'), ('Normalise across scale', 'normaliseAcrossScale', 'base:bool', 'checkbox', 'Determine normalisation factor.') ] ScriptedConfigModuleMixin.__init__(self, configList) # setup the pipeline g = itk.itkGradientMagnitudeRecursiveGaussianImageFilterF3F3_New() self._gradientMagnitude = g module_utilsITK.setupITKObjectProgress( self, g, 'itkGradientMagnitudeRecursiveGaussianImageFilter', 'Calculating gradient image') self._createWindow({ 'Module (self)': self, 'itkGradientMagnitudeRecursiveGaussianImageFilter': self._gradientMagnitude }) self.config_to_logic() self.syncViewWithLogic()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.scale = (1.0, 1.0, 1.0) self._config.orientation = (0.0, 0.0, 0.0) self._config.translation = (0.0, 0.0, 0.0) configList = [ ('Scaling:', 'scale', 'tuple:float,3', 'tupleText', 'Scale factor in the x, y and z directions in world units.'), ('Orientation:', 'orientation', 'tuple:float,3', 'tupleText', 'Rotation, in order, around the x, the new y and the new z axes ' 'in degrees.'), ('Translation:', 'translation', 'tuple:float,3', 'tupleText', 'Translation in the x,y,z directions.')] self._transform = vtk.vtkTransform() # we want changes here to happen AFTER the transformations # represented by the input self._transform.PostMultiply() # has no progress! ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkTransform' : self._transform}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # setup config self._config.order = 0 self._config.support = 4.0 self._config.B = 0.0 self._config.C = 0.5 # and then our scripted config configList = [('Order: ', 'order', 'base:int', 'text', 'The order of the cubic B-Spline kernel (0-2).'), ('B: ', 'B', 'base:float', 'text', 'B'), ('C: ', 'C', 'base:float', 'text', 'C'), ('Support: ', 'support', 'base:float', 'text', 'The support of the cubic B-Spline kernel.')] # mixin ctor ScriptedConfigModuleMixin.__init__(self, configList) # now create the necessary VTK modules self._cubicBCSplineKernel = vtktud.vtkCubicBCSplineKernel() # setup progress for the processObject # module_utils.setup_vtk_object_progress(self, self._superquadricSource, # "Synthesizing polydata.") self._createWindow({ 'Module (self)': self, 'vtkCubicBCSplineKernel': self._cubicBCSplineKernel }) self.config_to_logic() self.syncViewWithLogic()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) #for o in self._objectDict.values(): # # setup some config defaults self._config.threshold = 1250 self._config.interpolation = 0 # nearest # this is not in the interface yet, change by introspection self._config.mip_colour = (0.0, 0.0, 1.0) config_list = [ ('Threshold:', 'threshold', 'base:float', 'text', 'Used to generate transfer function if none is supplied'), ('Interpolation:', 'interpolation', 'base:int', 'choice', 'Linear (high quality, slower) or nearest neighbour (lower ' 'quality, faster) interpolation', ('Nearest Neighbour', 'Linear')) ] ScriptedConfigModuleMixin.__init__(self, config_list, {'Module (self)': self}) self._create_pipeline() self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._reader = vtk.vtkMetaImageReader() module_utils.setup_vtk_object_progress(self, self._reader, 'Reading MetaImage data.') self._config.filename = '' configList = [ ('File name:', 'filename', 'base:str', 'filebrowser', 'The name of the MetaImage file you want to load.', {'fileMode' : wx.OPEN, 'fileMask' : 'MetaImage single file (*.mha)|*.mha|MetaImage separate header ' '(*.mhd)|*.mhd|All files (*.*)|*.*'})] ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkMetaImageReader' : self._reader}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._tubeFilter = vtk.vtkTubeFilter() module_utils.setup_vtk_object_progress(self, self._tubeFilter, 'Generating tubes.') self._config.NumberOfSides = 3 self._config.Radius = 0.01 configList = [ ('Number of sides:', 'NumberOfSides', 'base:int', 'text', 'Number of sides that the tube should have.'), ('Tube radius:', 'Radius', 'base:float', 'text', 'Radius of the generated tube.')] ScriptedConfigModuleMixin.__init__(self, configList) self._viewFrame = self._createWindow( {'Module (self)' : self, 'vtkTubeFilter' : self._tubeFilter}) # 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 config self._config.resolution = 40 # and then our scripted config configList = [ ('Resolution: ', 'resolution', 'base:int', 'text', 'x, y and z resolution of sampled volume. ' 'According to the article, should be 40 to be ' 'at Nyquist.')] # now create the necessary VTK modules self._es = vtk.vtkImageEllipsoidSource() self._es.SetOutputScalarTypeToFloat() self._ic = vtk.vtkImageChangeInformation() self._ic.SetInputConnection(self._es.GetOutputPort()) self._output = vtk.vtkImageData() # mixin ctor ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.scale = (1.0, 1.0, 1.0) self._config.orientation = (0.0, 0.0, 0.0) self._config.translation = (0.0, 0.0, 0.0) configList = [ ('Scaling:', 'scale', 'tuple:float,3', 'tupleText', 'Scale factor in the x, y and z directions in world units.'), ('Orientation:', 'orientation', 'tuple:float,3', 'tupleText', 'Rotation, in order, around the x, the new y and the new z axes ' 'in degrees.'), ('Translation:', 'translation', 'tuple:float,3', 'tupleText', 'Translation in the x,y,z directions.') ] self._transform = vtk.vtkTransform() # we want changes here to happen AFTER the transformations # represented by the input self._transform.PostMultiply() # has no progress! ScriptedConfigModuleMixin.__init__(self, configList, { 'Module (self)': self, 'vtkTransform': self._transform }) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageMath = vtk.vtkImageMathematics() self._imageMath.SetInput1(None) self._imageMath.SetInput2(None) module_utils.setup_vtk_object_progress(self, self._imageMath, 'Performing image math') self._config.operation = 'subtract' self._config.constantC = 0.0 self._config.constantK = 1.0 configList = [ ('Operation:', 'operation', 'base:str', 'choice', 'The operation that should be performed.', tuple(OPS_DICT.keys())), ('Constant C:', 'constantC', 'base:float', 'text', 'The constant C used in some operations.'), ('Constant K:', 'constantK', 'base:float', 'text', 'The constant C used in some operations.')] ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkImageMathematics' : self._imageMath}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # call parent constructor ModuleBase.__init__(self, module_manager) self._writer = vtk.vtkMetaImageWriter() module_utils.setup_vtk_object_progress( self, self._writer, 'Writing VTK ImageData') # set up some defaults self._config.filename = '' self._config.compression = True config_list = [ ('Filename:', 'filename', 'base:str', 'filebrowser', 'Output filename for MetaImage file.', {'fileMode' : wx.SAVE, 'fileMask' : 'MetaImage single file (*.mha)|*.mha|MetaImage separate header/(z)raw files (*.mhd)|*.mhd|All files (*)|*', 'defaultExt' : '.mha'} ), ('Compression:', 'compression', 'base:bool', 'checkbox', 'Compress the image / volume data') ] ScriptedConfigModuleMixin.__init__(self, config_list, {'Module (self)' : self})
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._input_points = [None, None] self._source_landmarks = None self._target_landmarks = None self._config.mode = 'Rigid' configList = [('Transformation mode:', 'mode', 'base:str', 'choice', 'Rigid: rotation + translation;\n' 'Similarity: rigid + isotropic scaling\n' 'Affine: rigid + scaling + shear', ('Rigid', 'Similarity', 'Affine'))] self._landmark_transform = vtk.vtkLandmarkTransform() ScriptedConfigModuleMixin.__init__( self, configList, { 'Module (self)': self, 'vtkLandmarkTransform': self._landmark_transform }) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.numberOfIterations = 5 self._config.conductanceParameter = 3.0 configList = [ ('Number of iterations:', 'numberOfIterations', 'base:int', 'text', 'Number of time-step updates (iterations) the solver will ' 'perform.'), ('Conductance parameter:', 'conductanceParameter', 'base:float', 'text', 'Sensitivity of the conductance term. Lower == more ' 'preservation of image features.')] # setup the pipeline if3 = itk.Image[itk.F, 3] d = itk.CurvatureAnisotropicDiffusionImageFilter[if3, if3].New() d.SetTimeStep(0.0625) # standard for 3D self._diffuse = d itk_kit.utils.setupITKObjectProgress( self, self._diffuse, 'itkCurvatureAnisotropicDiffusionImageFilter', 'Smoothing data') ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'itkCurvatureAnisotropicDiffusion' : self._diffuse}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageMath = vtk.vtkImageMathematics() self._imageMath.SetInput1(None) self._imageMath.SetInput2(None) module_utils.setup_vtk_object_progress(self, self._imageMath, 'Performing image math') self._config.operation = 'subtract' self._config.constantC = 0.0 self._config.constantK = 1.0 configList = [('Operation:', 'operation', 'base:str', 'choice', 'The operation that should be performed.', tuple(OPS_DICT.keys())), ('Constant C:', 'constantC', 'base:float', 'text', 'The constant C used in some operations.'), ('Constant K:', 'constantK', 'base:float', 'text', 'The constant C used in some operations.')] ScriptedConfigModuleMixin.__init__( self, configList, { 'Module (self)': self, 'vtkImageMathematics': self._imageMath }) self.sync_module_logic_with_config()
def __init__(self, module_manager): # call parent constructor ModuleBase.__init__(self, module_manager) # ctor for this specific mixin # FilenameViewModuleMixin.__init__(self) self._input_image = None self._foreground_points = None self._background_points = None self._config.filename = '' configList = [ ('Result file name:', 'filename', 'base:str', 'filebrowser', 'Y/N result will be written to this file.', { 'fileMode': WX_SAVE, 'fileMask': 'All files (*.*)|*.*' }) ] ScriptedConfigModuleMixin.__init__(self, configList, {'Module (self)': self}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # setup config self._config.resolution = 40 # and then our scripted config configList = [('Resolution: ', 'resolution', 'base:int', 'text', 'x, y and z resolution of sampled volume. ' 'According to the article, should be 40 to be ' 'at Nyquist.')] # now create the necessary VTK modules self._es = vtk.vtkImageEllipsoidSource() self._es.SetOutputScalarTypeToFloat() self._ic = vtk.vtkImageChangeInformation() self._ic.SetInputConnection(self._es.GetOutputPort()) self._output = vtk.vtkImageData() # mixin ctor ScriptedConfigModuleMixin.__init__(self, configList, {'Module (self)': self}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._glyph3d = vtktud.vtkMyGlyph3D() module_utils.setup_vtk_object_progress(self, self._glyph3d, 'Making 3D glyphs') self._config.scaling = 1.0 self._config.scalemode = 1.0 configList = [ ('Scaling:', 'scaling', 'base:float', 'text', 'Glyphs will be scaled by this factor.'), ('Scalemode:', 'scalemode', 'base:int', 'text', 'Scaling will occur by scalar, vector direction or magnitude.')] ScriptedConfigModuleMixin.__init__(self, configList) self._viewFrame = self._createWindow( {'Module (self)' : self, 'vtkMyGlyph3D' : self._glyph3d}) # 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.logic_to_config() self.config_to_view()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) #for o in self._objectDict.values(): # # setup some config defaults self._config.threshold = 1250 self._config.interpolation = 0 # nearest # this is not in the interface yet, change by introspection self._config.mip_colour = (0.0, 0.0, 1.0) config_list = [ ('Threshold:', 'threshold', 'base:float', 'text', 'Used to generate transfer function if none is supplied'), ('Interpolation:', 'interpolation', 'base:int', 'choice', 'Linear (high quality, slower) or nearest neighbour (lower ' 'quality, faster) interpolation', ('Nearest Neighbour', 'Linear'))] ScriptedConfigModuleMixin.__init__( self, config_list, {'Module (self)' : self}) self._create_pipeline() self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.gaussianSigma = 0.7 self._config.normaliseAcrossScale = False configList = [ ('Gaussian sigma', 'gaussianSigma', 'base:float', 'text', 'Sigma in terms of image spacing.'), ('Normalise across scale', 'normaliseAcrossScale', 'base:bool', 'checkbox', 'Determine normalisation factor.')] ScriptedConfigModuleMixin.__init__(self, configList) # setup the pipeline g = itk.itkGradientMagnitudeRecursiveGaussianImageFilterF3F3_New() self._gradientMagnitude = g module_utilsITK.setupITKObjectProgress( self, g, 'itkGradientMagnitudeRecursiveGaussianImageFilter', 'Calculating gradient image') self._createWindow( {'Module (self)' : self, 'itkGradientMagnitudeRecursiveGaussianImageFilter' : self._gradientMagnitude}) self.config_to_logic() self.syncViewWithLogic()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # setup config self._config.order = 0 self._config.standardDeviation = 1.0 self._config.support = 3.0 * self._config.standardDeviation # and then our scripted config configList = [ ("Order: ", "order", "base:int", "text", "The order of the gaussian kernel (0-2)."), ( "Standard deviation: ", "standardDeviation", "base:float", "text", "The standard deviation (width) of the gaussian kernel.", ), ("Support: ", "support", "base:float", "text", "The support of the gaussian kernel."), ] # mixin ctor ScriptedConfigModuleMixin.__init__(self, configList) # now create the necessary VTK modules self._gaussianKernel = vtktud.vtkGaussianKernel() # setup progress for the processObject # module_utils.setup_vtk_object_progress(self, self._superquadricSource, # "Synthesizing polydata.") self._createWindow({"Module (self)": self, "vtkGaussianKernel": self._gaussianKernel}) self.config_to_logic() self.syncViewWithLogic()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.alpha = - 0.5 self._config.beta = 3.0 self._config.min = 0.0 self._config.max = 1.0 configList = [ ('Alpha:', 'alpha', 'base:float', 'text', 'Alpha parameter for the sigmoid filter'), ('Beta:', 'beta', 'base:float', 'text', 'Beta parameter for the sigmoid filter'), ('Minimum:', 'min', 'base:float', 'text', 'Minimum output of sigmoid transform'), ('Maximum:', 'max', 'base:float', 'text', 'Maximum output of sigmoid transform')] if3 = itk.Image[itk.F, 3] self._sigmoid = itk.SigmoidImageFilter[if3,if3].New() itk_kit.utils.setupITKObjectProgress( self, self._sigmoid, 'itkSigmoidImageFilter', 'Performing sigmoid transformation') ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'itkSigmoidImageFilter' : self._sigmoid}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # this has no progress feedback self._icp = vtk.vtkIterativeClosestPointTransform() self._config.max_iterations = 50 self._config.mode = 'RigidBody' self._config.align_centroids = True config_list = [ ('Transformation mode:', 'mode', 'base:str', 'choice', 'Rigid: rotation + translation;\n' 'Similarity: rigid + isotropic scaling\n' 'Affine: rigid + scaling + shear', ('RigidBody', 'Similarity', 'Affine')), ('Maximum number of iterations:', 'max_iterations', 'base:int', 'text', 'Maximum number of iterations for ICP.'), ('Align centroids before start', 'align_centroids', 'base:bool', 'checkbox', 'Align centroids before iteratively optimizing closest points? (required for large relative translations)' ) ] ScriptedConfigModuleMixin.__init__( self, config_list, { 'Module (self)': self, 'vtkIterativeClosestPointTransform': self._icp }) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # setup defaults self._config.propagationScaling = 1.0 self._config.curvatureScaling = 1.0 self._config.advectionScaling = 1.0 self._config.numberOfIterations = 100 configList = [ ('Propagation scaling:', 'propagationScaling', 'base:float', 'text', 'Propagation scaling parameter for the geodesic active ' 'contour, ' 'i.e. balloon force. Positive for outwards, negative for ' 'inwards.'), ('Curvature scaling:', 'curvatureScaling', 'base:float', 'text', 'Curvature scaling term weighting.'), ('Advection scaling:', 'advectionScaling', 'base:float', 'text', 'Advection scaling term weighting.'), ('Number of iterations:', 'numberOfIterations', 'base:int', 'text', 'Number of iterations that the algorithm should be run for') ] ScriptedConfigModuleMixin.__init__(self, configList, {'Module (self)': self}) # create all pipeline thingies self._createITKPipeline() self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._input = None self._image_cast = vtk.vtkImageCast() self._vtk2itk = None # this stores the short_string of the current converter, e.g. # F3 or US3, etc. self._vtk2itk_short_string = None self._config.autotype = False # this will store the current type as full text, e.g. "unsigned char" self._config.type = 'float' config_list = [ ('AutoType:', 'autotype', 'base:bool', 'checkbox', 'If activated, output data type is set to ' 'input type.'), ('Data type:', 'type', 'base:str', 'choice', 'Data will be cast to this type if AutoType is not used.', [ 'float', 'signed short', 'unsigned short', 'unsigned char', 'unsigned long' ]) ] ScriptedConfigModuleMixin.__init__(self, config_list, {'Module (self)': self}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._shepardFilter = vtk.vtkShepardMethod() module_utils.setup_vtk_object_progress(self, self._shepardFilter, 'Applying Shepard Method.') self._config.maximum_distance = 1.0 configList = [ ('Kernel size:', 'kernelSize', 'tuple:int,3', 'text', 'Size of the kernel in x,y,z dimensions.')] ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkImageContinuousDilate3D' : self._imageDilate}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._histogram = vtkdevide.vtkImageHistogram2D() module_utils.setup_vtk_object_progress(self, self._histogram, 'Calculating 2D histogram') self._config.input1Bins = 256 self._config.input2Bins = 256 self._config.maxSamplesPerBin = 512 configList = [ ('Number of bins for input 1', 'input1Bins', 'base:int', 'text', 'The full range of input 1 values will be divided into this many ' 'classes.'), ('Number of bins for input 2', 'input2Bins', 'base:int', 'text', 'The full range of input 2 values will be divided into this many ' 'classes.'), ('Maximum samples per bin', 'maxSamplesPerBin', 'base:int', 'text', 'The number of samples per 2D bin/class will be truncated to ' 'this value.') ] ScriptedConfigModuleMixin.__init__( self, configList, { 'Module (self)': self, 'vtkImageHistogram2D': self._histogram }) self.sync_module_logic_with_config() self._input0 = None self._input1 = None
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._reader = vtk.vtkMetaImageReader() module_utils.setup_vtk_object_progress(self, self._reader, 'Reading MetaImage data.') self._config.filename = '' configList = [( 'File name:', 'filename', 'base:str', 'filebrowser', 'The name of the MetaImage file you want to load.', { 'fileMode': wx.OPEN, 'fileMask': 'MetaImage single file (*.mha)|*.mha|MetaImage separate header ' '(*.mhd)|*.mhd|All files (*.*)|*.*' })] ScriptedConfigModuleMixin.__init__(self, configList, { 'Module (self)': self, 'vtkMetaImageReader': self._reader }) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # setup defaults self._config.propagationScaling = 1.0 self._config.advectionScaling = 1.0 self._config.curvatureScaling = 1.0 self._config.numberOfIterations = 500 configList = [ ( "Propagation scaling:", "propagationScaling", "base:float", "text", "Weight factor for the propagation term", ), ("Advection scaling:", "advectionScaling", "base:float", "text", "Weight factor for the advection term"), ("Curvature scaling:", "curvatureScaling", "base:float", "text", "Weight factor for the curvature term"), ( "Number of iterations:", "numberOfIterations", "base:int", "text", "Number of iterations that the algorithm should be run for", ), ] ScriptedConfigModuleMixin.__init__(self, configList, {"Module (self)": self}) # create all pipeline thingies self._createITKPipeline() self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._reslicer = vtk.vtkImageReslice() self._probefilter = vtk.vtkProbeFilter() self._config.paddingValue = 0.0 #This is 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() configList = [ ('Padding value:', 'paddingValue', 'base:float', 'text', 'The value used to pad regions that are outside the supplied volume.')] # initialise any mixins we might have ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)': self, 'vtkImageReslice': self._reslicer, 'vtkProbeFilter': self._probefilter, 'vtkImageConstantPad': self._padder}) module_utils.setup_vtk_object_progress(self, self._reslicer, 'Transforming image (Image Reslice)') module_utils.setup_vtk_object_progress(self, self._probefilter, 'Performing remapping (Probe Filter)') self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._extract = vtk.vtkImageExtractComponents() module_utils.setup_vtk_object_progress(self, self._extract, 'Extracting components.') self._config.component1 = 0 self._config.component2 = 1 self._config.component3 = 2 self._config.numberOfComponents = 1 self._config.fileLowerLeft = False configList = [ ('Component 1:', 'component1', 'base:int', 'text', 'Zero-based index of first component to extract.'), ('Component 2:', 'component2', 'base:int', 'text', 'Zero-based index of second component to extract.'), ('Component 3:', 'component3', 'base:int', 'text', 'Zero-based index of third component to extract.'), ('Number of components:', 'numberOfComponents', 'base:int', 'choice', 'Number of components to extract. Only this number of the ' 'above-specified component indices will be used.', ('1', '2', '3'))] ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkImageExtractComponents' : self._extract}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._reslicer = vtk.vtkImageReslice() self._probefilter = vtk.vtkProbeFilter() self._config.paddingValue = 0.0 #This is 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() configList = [( 'Padding value:', 'paddingValue', 'base:float', 'text', 'The value used to pad regions that are outside the supplied volume.' )] # initialise any mixins we might have ScriptedConfigModuleMixin.__init__( self, configList, { 'Module (self)': self, 'vtkImageReslice': self._reslicer, 'vtkProbeFilter': self._probefilter, 'vtkImageConstantPad': self._padder }) module_utils.setup_vtk_object_progress( self, self._reslicer, 'Transforming image (Image Reslice)') module_utils.setup_vtk_object_progress( self, self._probefilter, 'Performing remapping (Probe Filter)') self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.squared_distance = False self._config.binary_input = True self._config.image_spacing = True configList = [ ('Squared distance:', 'squared_distance', 'base:bool', 'checkbox', 'Should the distance output be squared (faster) or true.'), ('Use image spacing:', 'image_spacing', 'base:bool', 'checkbox', 'Use image spacing in distance calculation.'), ('Binary input:', 'binary_input', 'base:bool', 'checkbox', 'Does the input contain marked objects, or binary (yes/no) ' 'objects.')] # setup the pipeline imageF3 = itk.Image[itk.F, 3] self._dist_filter = None self._create_pipeline(imageF3) # THIS HAS TO BE ON. SO THERE. #self._dist_filter.SetUseImageSpacing(True) ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'itkDanielssonDistanceMapImageFilter' : self._dist_filter}) self.sync_module_logic_with_config()
def __init__(self, module_manager): # initialise our base class ModuleBase.__init__(self, module_manager) self._imageDilate = vtk.vtkImageContinuousDilate3D() self._imageErode = vtk.vtkImageContinuousErode3D() self._imageErode.SetInput(self._imageDilate.GetOutput()) module_utils.setup_vtk_object_progress(self, self._imageDilate, 'Performing greyscale 3D dilation') module_utils.setup_vtk_object_progress(self, self._imageErode, 'Performing greyscale 3D erosion') self._config.kernelSize = (3, 3, 3) configList = [ ('Kernel size:', 'kernelSize', 'tuple:int,3', 'text', 'Size of the kernel in x,y,z dimensions.')] ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'vtkImageContinuousDilate3D' : self._imageDilate, 'vtkImageContinuousErode3D' : self._imageErode}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.numberOfIterations = 5 self._config.conductanceParameter = 3.0 configList = [ ('Number of iterations:', 'numberOfIterations', 'base:int', 'text', 'Number of time-step updates (iterations) the solver will ' 'perform.'), ('Conductance parameter:', 'conductanceParameter', 'base:float', 'text', 'Sensitivity of the conductance term. Lower == more ' 'preservation of image features.') ] # setup the pipeline if3 = itk.Image[itk.F, 3] d = itk.GradientAnisotropicDiffusionImageFilter[if3, if3].New() d.SetTimeStep(0.0625) # standard for 3D self._diffuse = d module_kits.itk_kit.utils.setupITKObjectProgress( self, self._diffuse, 'itkGradientAnisotropicDiffusionImageFilter', 'Smoothing data') ScriptedConfigModuleMixin.__init__( self, configList, { 'Module (self)': self, 'itkGradientAnisotropicDiffusion': self._diffuse }) self.sync_module_logic_with_config()
def __init__(self, module_manager): # call parent constructor ModuleBase.__init__(self, module_manager) self._imageInput = None self._meshInput = None self._flipper = vtk.vtkImageFlip() self._flipper.SetFilteredAxis(1) module_utils.setup_vtk_object_progress(self, self._flipper, 'Flipping Y axis.') self._config.cpt_driver_path = \ 'd:\\misc\\stuff\\driver.bat' #'/home/cpbotha/build/cpt/3d/driver/driver.exe' self._config.max_distance = 5 config_list = [ ('CPT driver path', 'cpt_driver_path', 'base:str', 'filebrowser', 'Path to CPT driver executable', { 'fileMode': module_mixins.wx.OPEN, 'fileMask': 'All files (*.*)|*.*' }), ('Maximum distance', 'max_distance', 'base:float', 'text', 'The maximum (absolute) distance up to which the field is computed.' ) ] ScriptedConfigModuleMixin.__init__(self, config_list, {'Module (self)': self}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.gaussianSigma = 0.7 self._config.normaliseAcrossScale = False configList = [ ('Gaussian sigma', 'gaussianSigma', 'base:float', 'text', 'Sigma in terms of image spacing.'), ('Normalise across scale', 'normaliseAcrossScale', 'base:bool', 'checkbox', 'Determine normalisation factor.') ] # setup the pipeline self._gradientMagnitude = None img_type = itk.Image.F3 self._create_pipeline(img_type) ScriptedConfigModuleMixin.__init__( self, configList, { 'Module (self)': self, 'itkGradientMagnitudeRecursiveGaussianImageFilter': self._gradientMagnitude }) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) InputArrayChoiceMixin.__init__(self) # 0 = RK2 # 1 = RK4 # 2 = RK45 self._config.integrator = INTEG_TYPE.index('RK2') self._config.max_prop = 5.0 self._config.integration_direction = INTEG_DIR.index('FORWARD') configList = [ ('Vectors selection:', 'vectorsSelection', 'base:str', 'choice', 'The attribute that will be used as vectors for the warping.', (input_array_choice_mixin.DEFAULT_SELECTION_STRING, )), ('Max propagation:', 'max_prop', 'base:float', 'text', 'The streamline will propagate up to this lenth.'), ('Integration direction:', 'integration_direction', 'base:int', 'choice', 'Select an integration direction.', INTEG_DIR_TEXTS), ('Integrator type:', 'integrator', 'base:int', 'choice', 'Select an integrator for the streamlines.', INTEG_TYPE_TEXTS) ] self._streamTracer = vtk.vtkStreamTracer() ScriptedConfigModuleMixin.__init__( self, configList, { 'Module (self)': self, 'vtkStreamTracer': self._streamTracer }) module_utils.setup_vtk_object_progress(self, self._streamTracer, 'Tracing stream lines.') self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) self._config.gaussianSigma = 0.7 self._config.normaliseAcrossScale = False configList = [ ('Gaussian sigma', 'gaussianSigma', 'base:float', 'text', 'Sigma in terms of image spacing.'), ('Normalise across scale', 'normaliseAcrossScale', 'base:bool', 'checkbox', 'Determine normalisation factor.')] # setup the pipeline self._gradientMagnitude = None img_type = itk.Image.F3 self._create_pipeline(img_type) ScriptedConfigModuleMixin.__init__( self, configList, {'Module (self)' : self, 'itkGradientMagnitudeRecursiveGaussianImageFilter' : self._gradientMagnitude}) self.sync_module_logic_with_config()
def __init__(self, module_manager): ModuleBase.__init__(self, module_manager) # this has no progress feedback self._icp = vtk.vtkIterativeClosestPointTransform() self._config.max_iterations = 50 self._config.mode = 'RigidBody' self._config.align_centroids = True config_list = [ ('Transformation mode:', 'mode', 'base:str', 'choice', 'Rigid: rotation + translation;\n' 'Similarity: rigid + isotropic scaling\n' 'Affine: rigid + scaling + shear', ('RigidBody', 'Similarity', 'Affine')), ('Maximum number of iterations:', 'max_iterations', 'base:int', 'text', 'Maximum number of iterations for ICP.'), ('Align centroids before start', 'align_centroids', 'base:bool', 'checkbox', 'Align centroids before iteratively optimizing closest points? (required for large relative translations)') ] ScriptedConfigModuleMixin.__init__( self, config_list, {'Module (self)' : self, 'vtkIterativeClosestPointTransform' : self._icp}) self.sync_module_logic_with_config()