Exemplo n.º 1
0
    def load(self, loadable):
        """Load the selection as a diffusion volume
    using the dicom to nrrd converter module
    """

        if not hasattr(slicermodules, 'tractiocli'):
            raise Exception(
                "No TractIOCLI module available to perform load operation!")

        # create an output diffusion node as a target
        nodeFactory = slicer.qMRMLNodeFactory()
        nodeFactory.setMRMLScene(slicer.mrmlScene)
        diffusionNode = nodeFactory.createNode('vtkMRMLFiberBundleNode')
        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
        tractIOCLI = slicer.modules.tractiocli
        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
  def load(self,loadable):
    """Load the selection as a diffusion volume
    using the dicom to nrrd converter module
    """

    if not hasattr(slicermodules, 'tractiocli')
        raise Exception("No TractIOCLI module available to perform load operation!")

    # create an output diffusion node as a target
    nodeFactory = slicer.qMRMLNodeFactory()
    nodeFactory.setMRMLScene(slicer.mrmlScene)
    diffusionNode = nodeFactory.createNode('vtkMRMLFiberBundleNode')
    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
    tractIOCLI = slicer.modules.tractiocli
    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