parameters: (self,loadable)
return_statement: return outputSequenceNodes[-1]
docstring: Load the selection
docstring_summary: Load the selection
docstring_tokens: Load the selection
function: def load(self,loadable):
      """Load the selection
      """
  
      outputSequenceNodes = []
  
      if loadable.singleSequence:
        outputSequenceNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSequenceNode")
        outputSequenceNode.SetName(loadable.name)
        outputSequenceNode.SetIndexName("instance number")
        outputSequenceNode.SetIndexUnit("")
        playbackRateFps = 10
        outputSequenceNodes.append(outputSequenceNode)
  
      # Create a temporary volume node that will be used to insert volume nodes in the sequence
      if loadable.grayscale:
        tempFrameVolume = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeNode")
      else:
        tempFrameVolume = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLVectorVolumeNode")
  
      for fileIndex, filePath in enumerate(loadable.files):
        imageData, ijkToRas = self.loadImageData(filePath, loadable.grayscale, tempFrameVolume)
        if loadable.singleSequence:
          # each file is a frame (cine-MRI)
          imageData.SetSpacing(1.0, 1.0, 1.0)
          imageData.SetOrigin(0.0, 0.0, 0.0)
          tempFrameVolume.SetIJKToRASMatrix(ijkToRas)
          tempFrameVolume.SetAndObserveImageData(imageData)
          instanceNumber = loadable.instanceNumbers[fileIndex]
          # Save DICOM SOP instance UID into the sequence so DICOM metadata can be retrieved later if needed
          tempFrameVolume.SetAttribute('DICOM.instanceUIDs', slicer.dicomDatabase.instanceForFile(filePath))
          # Save trigger time, because it may be needed for 4D cine-MRI volume reconstruction
          triggerTime = slicer.dicomDatabase.fileValue(filePath, self.tags['triggerTime'])
          if triggerTime:
            tempFrameVolume.SetAttribute('DICOM.triggerTime', triggerTime)
          outputSequenceNode.SetDataNodeAtValue(tempFrameVolume, str(instanceNumber))
        else:
          # each file is a new sequence
          outputSequenceNode, playbackRateFps = self.addSequenceFromImageData(
            imageData, tempFrameVolume, filePath, loadable.name, (len(loadable.files) == 1))
          outputSequenceNodes.append(outputSequenceNode)
  
      # Delete temporary volume node
      slicer.mrmlScene.RemoveNode(tempFrameVolume)
  
      if not hasattr(loadable, 'createBrowserNode') or loadable.createBrowserNode:
        self.addSequenceBrowserNode(loadable.name, outputSequenceNodes, playbackRateFps, loadable)
  
      # Return the last loaded sequence node (that is the one currently displayed in slice views)
      return outputSequenceNodes[-1]
function_tokens: def load ( self , loadable ) : outputSequenceNodes = [ ] if loadable . singleSequence : outputSequenceNode = slicer . mrmlScene . AddNewNodeByClass ( "vtkMRMLSequenceNode" ) outputSequenceNode . SetName ( loadable . name ) outputSequenceNode . SetIndexName ( "instance number" ) outputSequenceNode . SetIndexUnit ( "" ) playbackRateFps = 10 outputSequenceNodes . append ( outputSequenceNode ) # Create a temporary volume node that will be used to insert volume nodes in the sequence if loadable . grayscale : tempFrameVolume = slicer . mrmlScene . AddNewNodeByClass ( "vtkMRMLScalarVolumeNode" ) else : tempFrameVolume = slicer . mrmlScene . AddNewNodeByClass ( "vtkMRMLVectorVolumeNode" ) for fileIndex , filePath in enumerate ( loadable . files ) : imageData , ijkToRas = self . loadImageData ( filePath , loadable . grayscale , tempFrameVolume ) if loadable . singleSequence : # each file is a frame (cine-MRI) imageData . SetSpacing ( 1.0 , 1.0 , 1.0 ) imageData . SetOrigin ( 0.0 , 0.0 , 0.0 ) tempFrameVolume . SetIJKToRASMatrix ( ijkToRas ) tempFrameVolume . SetAndObserveImageData ( imageData ) instanceNumber = loadable . instanceNumbers [ fileIndex ] # Save DICOM SOP instance UID into the sequence so DICOM metadata can be retrieved later if needed tempFrameVolume . SetAttribute ( 'DICOM.instanceUIDs' , slicer . dicomDatabase . instanceForFile ( filePath ) ) # Save trigger time, because it may be needed for 4D cine-MRI volume reconstruction triggerTime = slicer . dicomDatabase . fileValue ( filePath , self . tags [ 'triggerTime' ] ) if triggerTime : tempFrameVolume . SetAttribute ( 'DICOM.triggerTime' , triggerTime ) outputSequenceNode . SetDataNodeAtValue ( tempFrameVolume , str ( instanceNumber ) ) else : # each file is a new sequence outputSequenceNode , playbackRateFps = self . addSequenceFromImageData ( imageData , tempFrameVolume , filePath , loadable . name , ( len ( loadable . files ) == 1 ) ) outputSequenceNodes . append ( outputSequenceNode ) # Delete temporary volume node slicer . mrmlScene . RemoveNode ( tempFrameVolume ) if not hasattr ( loadable , 'createBrowserNode' ) or loadable . createBrowserNode : self . addSequenceBrowserNode ( loadable . name , outputSequenceNodes , playbackRateFps , loadable ) # Return the last loaded sequence node (that is the one currently displayed in slice views) return outputSequenceNodes [ - 1 ]