How to use the slicer.app function in slicer

To help you get started, we’ve selected a few slicer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SlicerDMRI / SlicerDMRI / Modules / Scripted / DMRIPlugins / DICOMDiffusionVolumePlugin.py View on Github external
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
github SlicerProstate / SliceTracker / SliceTracker / SliceTrackerUtils / sessionData.py View on Github external
def loadResults(self, data, directory):
    if len(data["results"]):
      self.customProgressBar.maximum = len(data["results"])
    for index, jsonResult in enumerate(data["results"], start=1):
      name = jsonResult["name"]
      logging.debug("processing %s" % name)
      result = self.createResult(name, invokeEvent=False)
      self.customProgressBar.updateStatus("Loading series registration result %s" % result.name, index)
      slicer.app.processEvents()

      for attribute, value in jsonResult.iteritems():
        logging.debug("found %s: %s" % (attribute, value))
        if attribute == 'volumes':
          self._loadResultFileData(value, directory, slicer.util.loadVolume, result.setVolume)
        elif attribute == 'transforms':
          self._loadResultFileData(value, directory, slicer.util.loadTransform, result.setTransform)
        elif attribute == 'targets':
          approved = value.pop('approved', None)
          original = value.pop('original', None)
          self._loadResultFileData(value, directory, slicer.util.loadMarkupsFiducialList, result.setTargets)
          if approved:
            approvedTargets = self._loadOrGetFileData(directory, approved["fileName"], slicer.util.loadMarkupsFiducialList)
            setattr(result.targets, 'approved', approvedTargets)
            result.targets.modifiedTargets[jsonResult["status"]["registrationType"]] = approved["userModified"]
          if original: