How to use the slicer.mrmlScene.GetNodeByID 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 SlicerProstate / SliceTracker / SliceTracker / SliceTrackerRegistration.py View on Github external
result = self.registrationResult
    result.volumes.fixed = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('FixedImageNodeID'))
    result.labels.fixed = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('FixedLabelNodeID'))
    result.labels.moving = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('MovingLabelNodeID'))
    movingVolume = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('MovingImageNodeID'))
    result.volumes.moving = self.volumesLogic.CloneVolume(slicer.mrmlScene, movingVolume,
                                                          "temp-movingVolume_" + str(self.counter))
    self.counter += 1

    logging.debug("Fixed Image Name: %s" % result.volumes.fixed.GetName())
    logging.debug("Fixed Label Name: %s" % result.labels.fixed.GetName())
    logging.debug("Moving Image Name: %s" % movingVolume.GetName())
    logging.debug("Moving Label Name: %s" % result.labels.moving.GetName())
    initialTransform = parameterNode.GetAttribute('InitialTransformNodeID')
    if initialTransform:
      initialTransform = slicer.mrmlScene.GetNodeByID(initialTransform)
      logging.debug("Initial Registration Name: %s" % initialTransform.GetName())
    return result
github SlicerProstate / SliceTracker / SliceTracker / SliceTrackerRegistration.py View on Github external
def _processParameterNode(self, parameterNode):
    if not self.registrationResult:
      self.registrationResult = RegistrationResult("01: RegistrationResult")
    result = self.registrationResult
    result.fixedVolume = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('FixedImageNodeID'))
    result.fixedLabel = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('FixedLabelNodeID'))
    result.movingLabel = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('MovingLabelNodeID'))
    movingVolume = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('MovingImageNodeID'))
    result.movingVolume = self.volumesLogic.CloneVolume(slicer.mrmlScene, movingVolume, "temp-movingVolume_" + str(self.counter))
    self.counter += 1

    logging.debug("Fixed Image Name: %s" % result.fixedVolume.GetName())
    logging.debug("Fixed Label Name: %s" % result.fixedLabel.GetName())
    logging.debug("Moving Image Name: %s" % movingVolume.GetName())
    logging.debug("Moving Label Name: %s" % result.movingLabel.GetName())
    initialTransform = parameterNode.GetAttribute('InitialTransformNodeID')
    if initialTransform:
      initialTransform = slicer.mrmlScene.GetNodeByID(initialTransform)
      logging.debug("Initial Registration Name: %s" % initialTransform.GetName())
    return result
github SlicerProstate / SliceTracker / SliceTracker.py View on Github external
def resetToRegularViewMode(self):
    interactionNode = slicer.mrmlScene.GetNodeByID("vtkMRMLInteractionNodeSingleton")
    interactionNode.SwitchToViewTransformMode()
    interactionNode.SetPlaceModePersistence(0)
github SlicerProstate / SliceTracker / SliceTracker / SliceTrackerUtils / steps / segmentation.py View on Github external
def _centerLabelsOnVisibleSliceWidgets(self):
    for widget in self.getAllVisibleWidgets():
      compositeNode = widget.mrmlSliceCompositeNode()
      sliceNode = widget.sliceLogic().GetSliceNode()
      labelID = compositeNode.GetLabelVolumeID()
      if labelID:
        label = slicer.mrmlScene.GetNodeByID(labelID)
        centroid = self.logic.getCentroidForLabel(label, self.session.segmentedLabelValue)
        if centroid:
          sliceNode.JumpSliceByCentering(centroid[0], centroid[1], centroid[2])
github SlicerProstate / SliceTracker / SliceTracker / SliceTrackerRegistration.py View on Github external
def run(self, parameterNode, progressCallback=None):
    self.progressCallback = progressCallback
    result = self._processParameterNode(parameterNode)

    registrationTypes = ['rigid', 'affine', 'bSpline']
    self.createVolumeAndTransformNodes(registrationTypes, prefix=str(result.seriesNumber), suffix=result.suffix)

    self.doRigidRegistration(movingBinaryVolume=result.movingLabel, initializeTransformMode="useCenterOfROIAlign")
    self.doAffineRegistration()
    self.doBSplineRegistration(initialTransform=result.affineTransform)

    targetsNodeID = parameterNode.GetAttribute('TargetsNodeID')
    if targetsNodeID:
      result.originalTargets = slicer.mrmlScene.GetNodeByID(targetsNodeID)
      self.transformTargets(registrationTypes, result.originalTargets, str(result.seriesNumber), suffix=result.suffix)
    result.movingVolume = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('MovingImageNodeID'))
github SlicerDMRI / SlicerDMRI / Modules / Scripted / DICOM2FullBrainTractography / DICOM2FullBrainTractographyLib / full_tractography_workflow.py View on Github external
elif data[step_object.id()]['NRRDDWIRadioButton']:
            result_status, node = slicer.util.loadVolume(
                data[step_object.id()]['inputNRRDVolume'],
                {},
                True
            )

            if result_status:
                self.dwi_node = node
                self.dwi_node_name = node.GetID()

        elif data[step_object.id()]['MRMLDWIRadioButton']:
            result_status = True
            self.dwi_node_name = data[step_object.id()]['inputNRRDMRMLNode']
            self.dwi_node = slicer.mrmlScene.GetNodeByID(self.dwi_node_name)

        if not result_status:
            display_error("Error in DICOM to NRRD conversion, please see log")

        return result_status
github SlicerProstate / SliceTracker / SliceTracker / SliceTrackerRegistration.py View on Github external
def run(self, parameterNode, progressCallback=None):
    self.progressCallback = progressCallback
    result = self._processParameterNode(parameterNode)

    registrationTypes = ['rigid', 'affine', 'bSpline']
    self.createVolumeAndTransformNodes(registrationTypes, prefix=str(result.seriesNumber), suffix=result.suffix)

    self.doRigidRegistration(movingBinaryVolume=result.labels.moving, initializeTransformMode="useCenterOfROIAlign")
    self.doAffineRegistration()
    self.doBSplineRegistration(initialTransform=result.transforms.affine)

    targetsNodeID = parameterNode.GetAttribute('TargetsNodeID')
    if targetsNodeID:
      result.targets.original = slicer.mrmlScene.GetNodeByID(targetsNodeID)
      self.transformTargets(registrationTypes, result.targets.original, str(result.seriesNumber), suffix=result.suffix)
    result.volumes.moving = slicer.mrmlScene.GetNodeByID(parameterNode.GetAttribute('MovingImageNodeID'))