Example #1
0
 def load(self, loadable):
     """Load the selection as a diffusion volume
 using the dicom to nrrd converter module
 """
     if not hasattr(slicer.modules, 'dwiconvert'):
         print('No diffusion dicom importer module available')
         return False
     # create an output diffusion node as a target
     nodeFactory = slicer.qMRMLNodeFactory()
     nodeFactory.setMRMLScene(slicer.mrmlScene)
     diffusionNode = nodeFactory.createNode(
         'vtkMRMLDiffusionWeightedVolumeNode')
     diffusionNode.SetName(loadable.name)
     # set up the parameters
     parameters = {}
     parameters['inputDicomDirectory'] = os.path.dirname(loadable.files[0])
     parameters['outputDirectory'] = slicer.app.temporaryPath
     parameters['outputVolume'] = diffusionNode.GetID()
     # run the module
     dicomDWIConverter = slicer.modules.dwiconvert
     cliNode = slicer.cli.run(dicomDWIConverter,
                              None,
                              parameters,
                              wait_for_completion=True)
     success = False
     if cliNode.GetStatusString(
     ) == "Completing" or cliNode.GetStatusString() == "Completed":
         if diffusionNode.GetImageData():
             success = True
     return success
  def load(self,loadable):
    """Load the selection as a diffusion volume
    using the dicom to nrrd converter module
    """
    if not hasattr(slicer.modules, 'dwiconvert'):
      print('No diffusion dicom importer module available')
      return False
    # create an output diffusion node as a target
    nodeFactory = slicer.qMRMLNodeFactory()
    nodeFactory.setMRMLScene(slicer.mrmlScene)
    diffusionNode = nodeFactory.createNode('vtkMRMLDiffusionWeightedVolumeNode')
    diffusionNode.SetName(loadable.name)
    # set up the parameters
    parameters = {}
    parameters['inputDicomDirectory'] = os.path.dirname(loadable.files[0])
    parameters['outputDirectory'] = slicer.app.temporaryPath
    parameters['outputVolume'] = diffusionNode.GetID()
    # run the module
    dicomDWIConverter = slicer.modules.dwiconvert
    cliNode = slicer.cli.run(dicomDWIConverter, None, parameters, wait_for_completion = True)
    success = False
    if cliNode.GetStatusString() == "Completing" or cliNode.GetStatusString() == "Completed":
      if diffusionNode.GetImageData():
        success = True

    # create Subject Hierarchy nodes for the loaded series
    self.addSeriesInSubjectHierarchy(loadable,diffusionNode)

    return success
Example #3
0
    def load(self, loadable):
        """Load the selection as a diffusion volume
    using the dicom to nrrd converter module
    """
        if not hasattr(slicer.modules, 'dwiconvert'):
            print('No diffusion dicom importer module available')
            return False
        # create an output diffusion node as a target
        nodeFactory = slicer.qMRMLNodeFactory()
        nodeFactory.setMRMLScene(slicer.mrmlScene)
        diffusionNode = nodeFactory.createNode(
            'vtkMRMLDiffusionWeightedVolumeNode')
        diffusionNode.SetName(loadable.name)
        # set up the parameters
        parameters = {}
        tempDir = slicer.util.tempDirectory()
        import shutil
        for filePath in loadable.files:
            base = os.path.basename(filePath)
            shutil.copy(filePath, os.path.join(tempDir, base))
        parameters['inputDicomDirectory'] = tempDir
        parameters['outputDirectory'] = slicer.app.temporaryPath
        parameters['outputVolume'] = diffusionNode.GetID()
        # run the module
        dicomDWIConverter = slicer.modules.dwiconvert
        cliNode = slicer.cli.run(dicomDWIConverter,
                                 None,
                                 parameters,
                                 wait_for_completion=True)
        success = False
        if cliNode.GetStatusString(
        ) == "Completing" or cliNode.GetStatusString() == "Completed":
            if diffusionNode.GetImageData():
                success = True

        # create Subject Hierarchy nodes for the loaded series
        self.addSeriesInSubjectHierarchy(loadable, diffusionNode)

        # remove temp directory of dwi series
        shutil.rmtree(tempDir)

        return success
Example #4
0
  def registerVolumes(self, targetVol, movingVol):
 
    # Set up transformations
    tfmName = movingVol.GetName() + " ---TO--- " + targetVol.GetName()
    tfmNode = movingVol.GetParentTransformNode()
    if tfmNode == None or (tfmNode != None and tfmNode.GetName() != tfmName):
      nodeFactory = slicer.qMRMLNodeFactory()
      nodeFactory.setMRMLScene(slicer.mrmlScene)
      tfmNode = nodeFactory.createNode('vtkMRMLLinearTransformNode')
      tfmNode.SetName(tfmName)
      movingVol.SetAndObserveTransformNodeID(tfmNode.GetID())
    
    # Brainsfit parameters
    parameters = {}
    parameters['fixedVolume'] = targetVol
    parameters['movingVolume'] = movingVol
    parameters['outputTransform'] = tfmNode.GetID()
    parameters['initializeTransformMode'] = 'useMomentsAlign'
    parameters['useRigid'] = True
    
    brainsFit = slicer.modules.brainsfit
    cliNode = slicer.cli.run(brainsFit, None, parameters, wait_for_completion = True)