How to use the slicer.app.applicationLogic 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 QIICR / QuantitativeReporting / QuantitativeReporting / QuantitativeReporting.py View on Github external
def _checkUserInformation(self):
    if not slicer.app.applicationLogic().GetUserInformation().GetName():
      if slicer.util.confirmYesNoDisplay("Slicer user name required to save measurement reports. \n\n"
                                         "Do you want to set it now?"):
        dialog = TextInformationRequestDialog("User Name:")
        if dialog.exec_():
          slicer.app.applicationLogic().GetUserInformation().SetName(dialog.getValue())
github QIICR / QuantitativeReporting / QuantitativeReporting / QuantitativeReporting.py View on Github external
def _checkUserInformation(self):
    if not slicer.app.applicationLogic().GetUserInformation().GetName():
      if slicer.util.confirmYesNoDisplay("Slicer user name required to save measurement reports. \n\n"
                                         "Do you want to set it now?"):
        dialog = TextInformationRequestDialog("User Name:")
        if dialog.exec_():
          slicer.app.applicationLogic().GetUserInformation().SetName(dialog.getValue())
github QIICR / SlicerDevelopmentToolbox / SlicerDevelopmentToolboxUtils / widgets.py View on Github external
def setupSliceWidget(self):
    try:
      black = slicer.util.getNode('Black')
      slicer.mrmlScene.RemoveNode(black)
    except slicer.util.MRMLNodeNotFoundException:
      pass
    self.sliceNode = slicer.vtkMRMLSliceNode()
    self.sliceNode.SetName("Black")
    self.sliceNode.SetLayoutName("Black")
    self.sliceNode.SetLayoutLabel("BL")
    self.sliceNode.SetOrientationToAxial()
    slicer.mrmlScene.AddNode(self.sliceNode)
    self.sliceWidget = self.layoutManager.viewWidget(self.sliceNode)
    self.sliceLogic = slicer.app.applicationLogic().GetSliceLogic(self.sliceNode)
    self.sliceNode.SetMappedInLayout(1)
github SlicerRt / SlicerRT / Segmentations / Testing / Python / SegmentationsModuleTest1.py View on Github external
downloaded = 0
      for url,filePath in downloads:
        if not os.path.exists(filePath) or os.stat(filePath).st_size == 0:
          if downloaded == 0:
            logging.info('Downloading input data to folder\n' + self.dicomZipFilePath)
          logging.info('Requesting download from %s...' % (url))
          urllib.urlretrieve(url, filePath)
          downloaded += 1
        else:
          logging.info('Input data has been found in folder ' + self.dicomZipFilePath)
      if downloaded > 0:
        logging.info('Downloading input data finished')

      numOfFilesInDicomDataDir = len([name for name in os.listdir(self.dicomDataDir) if os.path.isfile(self.dicomDataDir + '/' + name)])
      if (numOfFilesInDicomDataDir != self.expectedNumOfFilesInDicomDataDir):
        slicer.app.applicationLogic().Unzip(self.dicomZipFilePath, self.segmentationsModuleTestDir)
        logging.info("Unzipping done")

      numOfFilesInDicomDataDirTest = len([name for name in os.listdir(self.dicomDataDir) if os.path.isfile(self.dicomDataDir + '/' + name)])
      self.assertEqual( numOfFilesInDicomDataDirTest, self.expectedNumOfFilesInDicomDataDir )

    except Exception, e:
      import traceback
      traceback.print_exc()
      logging.error('Test caused exception!\n' + str(e))
github SlicerProstate / SliceTracker / SliceTracker.py View on Github external
def setupFourUpView(self, volume):
    self.disableTargetTable()
    self.setBackgroundToVolume(volume.GetID())
    self.layoutManager.setLayout(self.LAYOUT_FOUR_UP)
    slicer.app.applicationLogic().FitSliceToAll()
github SlicerDMRI / SlicerDMRI / Modules / Loadable / TractographyDisplay / Testing / Python / NsgPlanTracto.py View on Github external
self.delayDisplay("Getting Baseline volume")
    baselineVolume = sampleDataLogic.downloadWhiteMatterExplorationBaselineVolume()

    self.delayDisplay("Getting DTI volume")
    dtiVolume = sampleDataLogic.downloadWhiteMatterExplorationDTIVolume()

    self.takeScreenshot('NeurosurgicalPlanning-Loaded','Data loaded',-1)

    #
    # create a label map and set it for editing
    #
    volumesLogic = slicer.modules.volumes.logic()
    baselineVolumeLabel =  volumesLogic.CreateAndAddLabelVolume( slicer.mrmlScene, baselineVolume, baselineVolume.GetName() + '-label' )
    baselineDisplayNode = baselineVolumeLabel.GetDisplayNode()
    baselineDisplayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeFileGenericAnatomyColors.txt')
    selectionNode = slicer.app.applicationLogic().GetSelectionNode()
    selectionNode.SetReferenceActiveVolumeID(baselineVolume.GetID())
    selectionNode.SetReferenceActiveLabelVolumeID(baselineVolumeLabel.GetID())
    slicer.app.applicationLogic().PropagateVolumeSelection(0)

    data = slicer.util.array(baselineVolume.GetName() + "-label")
    data[6:15, 110:140, 130:160] = 293

    #
    # link the viewers
    #

    if self.enableScreenshots == 1:
      # for the tutorial, pop up the linking control
      sliceController = slicer.app.layoutManager().sliceWidget("Red").sliceController()
      popupWidget = sliceController.findChild("ctkPopupWidget")
      if popupWidget is not None: