def examineForExport(self, subjectHierarchyItemID): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ import vtkSlicerRtCommonPython as vtkSlicerRtCommon exportable = None shn = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode( slicer.mrmlScene) dataNode = shn.GetItemDataNode(subjectHierarchyItemID) # RT dose volume #if dataNode and vtkSlicerRtCommon.SlicerRtCommon.IsDoseVolumeNode(dataNode): #TODO: Workaround until VTK8 can wrap SlicerRtCommon class https://issues.slicer.org/view.php?id=4462 if dataNode and dataNode.IsA('vtkMRMLScalarVolumeNode') \ and dataNode.GetAttribute('DicomRtImport.DoseVolume') is not None: exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'RTDOSE') # RT structure set elif dataNode and dataNode.IsA('vtkMRMLSegmentationNode'): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'RTSTRUCT') # Potential anatomical image for an RT study elif dataNode and dataNode.IsA('vtkMRMLScalarVolumeNode'): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 0.3 # Might be some other kind of scalar volume, but also anatomical volume in an RT study # Define type-specific required tags and default values exportable.setTag('Modality', 'CT') exportable.setTag('Manufacturer', 'Unknown manufacturer') exportable.setTag('Model', 'Unknown model') exportable.setTag('SeriesUID', 'XXXXXXX') # Node is exportable as RT series if exportable is not None: # Set common properties for RT exportable exportable.name = self.loadType exportable.tooltip = "Create DICOM files from RT study" exportable.subjectHierarchyItemID = subjectHierarchyItemID exportable.pluginClass = self.__module__ # Define common required tags and default values exportable.setTag('SeriesDescription', 'No series description') exportable.setTag('SeriesNumber', '1') return [exportable] # Not recognized as potential RT object return []
def examineForExport(self,subjectHierarchyItemID): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ import vtkSlicerRtCommonPython as vtkSlicerRtCommon exportable = None shn = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene) dataNode = shn.GetItemDataNode(subjectHierarchyItemID) # RT dose volume #if dataNode and vtkSlicerRtCommon.SlicerRtCommon.IsDoseVolumeNode(dataNode): #TODO: Workaround until VTK8 can wrap SlicerRtCommon class https://issues.slicer.org/view.php?id=4462 if dataNode and dataNode.IsA('vtkMRMLScalarVolumeNode') \ and dataNode.GetAttribute('DicomRtImport.DoseVolume') is not None: exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'RTDOSE') # RT structure set elif dataNode and dataNode.IsA('vtkMRMLSegmentationNode'): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'RTSTRUCT') # Potential anatomical image for an RT study elif dataNode and dataNode.IsA('vtkMRMLScalarVolumeNode'): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 0.3 # Might be some other kind of scalar volume, but also anatomical volume in an RT study # Define type-specific required tags and default values exportable.setTag('Modality', 'CT') exportable.setTag('Manufacturer', 'Unknown manufacturer') exportable.setTag('Model', 'Unknown model') exportable.setTag('SeriesUID', 'XXXXXXX') # Node is exportable as RT series if exportable is not None: # Set common properties for RT exportable exportable.name = self.loadType exportable.tooltip = "Create DICOM files from RT study" exportable.subjectHierarchyItemID = subjectHierarchyItemID exportable.pluginClass = self.__module__ # Define common required tags and default values exportable.setTag('SeriesDescription', 'No series description') exportable.setTag('SeriesNumber', '1') return [exportable] # Not recognized as potential RT object return []
def examineForExport(self, subjectHierarchyItemID): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ shn = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode( slicer.mrmlScene) transformNode = shn.GetItemDataNode(subjectHierarchyItemID) if transformNode is None or not transformNode.IsA( 'vtkMRMLTransformNode'): return [] # Get moving and fixed volumes involved in the registration movingVolumeNode = transformNode.GetNodeReference( slicer.vtkMRMLTransformNode.GetMovingNodeReferenceRole()) fixedVolumeNode = transformNode.GetNodeReference( slicer.vtkMRMLTransformNode.GetFixedNodeReferenceRole()) if movingVolumeNode is None or fixedVolumeNode is None: logging.error('Failed to find moving and/or fixed image for transform ' + transformNode.GetName() \ + '. These references are needed in order to export the transform into DICOM SRO. Please make sure the transform is created by a registration module.') return [] exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'REG') exportable.name = self.loadType exportable.tooltip = "Create DICOM file from registration result" exportable.subjectHierarchyItemID = subjectHierarchyItemID exportable.pluginClass = self.__module__ # Define common required tags and default values exportable.setTag('SeriesDescription', 'No series description') exportable.setTag('SeriesNumber', '1') return [exportable]
def examineForExport(self,subjectHierarchyItemID): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ # cannot export if there is no data node or the data node is not a volume shn = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene) dataNode = shn.GetItemDataNode(subjectHierarchyItemID) if dataNode is None or not dataNode.IsA('vtkMRMLScalarVolumeNode'): return [] # Define basic properties of the exportable exportable = slicer.qSlicerDICOMExportable() exportable.name = self.loadType exportable.tooltip = "Creates a series of DICOM files from scalar volumes" exportable.subjectHierarchyItemID = subjectHierarchyItemID exportable.pluginClass = self.__module__ exportable.confidence = 0.5 # There could be more specialized volume types # Define required tags and default values exportable.setTag('SeriesDescription', 'No series description') exportable.setTag('Modality', 'CT') exportable.setTag('Manufacturer', 'Unknown manufacturer') exportable.setTag('Model', 'Unknown model') exportable.setTag('SeriesNumber', '1') return [exportable]
def examineForExport(self, node): exportable = None if node.GetAssociatedNode() and node.GetAssociatedNode().IsA('vtkMRMLSegmentationNode'): # Check to make sure all referenced UIDs exist in the database. instanceUIDs = node.GetAttribute("DICOM.ReferencedInstanceUIDs").split() if instanceUIDs == "": return [] for instanceUID in instanceUIDs: inputDICOMImageFileName = slicer.dicomDatabase.fileForInstance(instanceUID) if inputDICOMImageFileName == "": return [] exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 exportable.setTag('Modality', 'SEG') if exportable != None: exportable.name = self.loadType exportable.tooltip = "Create DICOM files from segmentation" exportable.nodeID = node.GetID() exportable.pluginClass = self.__module__ # Define common required tags and default values exportable.setTag('SeriesDescription', 'No series description') exportable.setTag('SeriesNumber', '1') return [exportable] return []
def examineForExport(self, node): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ # cannot export if there is no data node or the data node is not a volume if node.GetAssociatedNode() == None or not node.GetAssociatedNode().IsA("vtkMRMLScalarVolumeNode"): return [] # Define basic properties of the exportable exportable = slicer.qSlicerDICOMExportable() exportable.name = self.loadType exportable.tooltip = "Creates a series of DICOM files from scalar volumes" exportable.nodeID = node.GetID() exportable.pluginClass = self.__module__ exportable.confidence = 0.5 # There could be more specialized volume types # Define required tags and default values exportable.setTag("SeriesDescription", "No series description") exportable.setTag("Modality", "CT") exportable.setTag("Manufacturer", "Unknown manufacturer") exportable.setTag("Model", "Unknown model") exportable.setTag("SeriesNumber", "1") return [exportable]
def examineForExport(self, node): exportable = None if node.GetAssociatedNode() and node.GetAssociatedNode().IsA( 'vtkMRMLSegmentationNode'): # Check to make sure all referenced UIDs exist in the database. instanceUIDs = node.GetAttribute( "DICOM.ReferencedInstanceUIDs").split() if instanceUIDs == "": return [] for instanceUID in instanceUIDs: inputDICOMImageFileName = slicer.dicomDatabase.fileForInstance( instanceUID) if inputDICOMImageFileName == "": return [] exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 exportable.setTag('Modality', 'SEG') if exportable is not None: exportable.name = self.loadType exportable.tooltip = "Create DICOM files from segmentation" exportable.nodeID = node.GetID() exportable.pluginClass = self.__module__ # Define common required tags and default values exportable.setTag('SeriesDescription', 'No series description') exportable.setTag('SeriesNumber', '1') return [exportable] return []
def examineForExport(self, node): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ import vtkSlicerRtCommonPython as vtkSlicerRtCommon exportable = None # RT dose volume if node.GetAssociatedNode() and vtkSlicerRtCommon.SlicerRtCommon.IsDoseVolumeNode(node.GetAssociatedNode()): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag("Modality", "RTDOSE") # RT structure set elif node.GetAssociatedNode() and node.GetAssociatedNode().IsA("vtkMRMLSegmentationNode"): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag("Modality", "RTSTRUCT") # Potential anatomical image for an RT study elif node.GetAssociatedNode() and node.GetAssociatedNode().IsA("vtkMRMLScalarVolumeNode"): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = ( 0.3 ) # Might be some other kind of scalar volume, but also anatomical volume in an RT study # Define type-specific required tags and default values exportable.setTag("Modality", "CT") exportable.setTag("Manufacturer", "Unknown manufacturer") exportable.setTag("Model", "Unknown model") exportable.setTag("SeriesUID", "XXXXXXX") # Node is exportable as RT series if exportable != None: # Set common properties for RT exportable exportable.name = self.loadType exportable.tooltip = "Create DICOM files from RT study" exportable.nodeID = node.GetID() exportable.pluginClass = self.__module__ # Define common required tags and default values exportable.setTag("SeriesDescription", "No series description") exportable.setTag("SeriesNumber", "1") return [exportable] # Not recognized as potential RT object return []
def examineForExport(self,node): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ from vtkSlicerRtCommon import SlicerRtCommon from vtkSlicerSubjectHierarchyModuleMRMLPython import vtkMRMLSubjectHierarchyConstants exportable = None # RT dose volume if node.GetAssociatedNode() and SlicerRtCommon.IsDoseVolumeNode(node.GetAssociatedNode()): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'RTDOSE') # RT structure set elif node.GetAssociatedNode() and node.GetAssociatedNode().IsA('vtkMRMLSegmentationNode'): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'RTSTRUCT') # Potential anatomical image for an RT study elif node.GetAssociatedNode() and node.GetAssociatedNode().IsA('vtkMRMLScalarVolumeNode'): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 0.3 # Might be some other kind of scalar volume, but also anatomical volume in an RT study # Define type-specific required tags and default values exportable.setTag('Modality', 'CT') exportable.setTag('Manufacturer', 'Unknown manufacturer') exportable.setTag('Model', 'Unknown model') exportable.setTag('SeriesUID', 'XXXXXXX') # Node is exportable as RT series if exportable != None: # Set common properties for RT exportable exportable.name = self.loadType exportable.tooltip = "Create DICOM files from RT study" exportable.nodeID = node.GetID() exportable.pluginClass = self.__module__ # Define common required tags and default values exportable.setTag('SeriesDescription', 'No series description') exportable.setTag('SeriesNumber', '1') return [exportable] # Not recognized as potential RT object return []
def examineForExport(self,node): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ import vtkSlicerRtCommonPython as vtkSlicerRtCommon exportable = None # RT dose volume if node.GetAssociatedNode() and vtkSlicerRtCommon.SlicerRtCommon.IsDoseVolumeNode(node.GetAssociatedNode()): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'RTDOSE') # RT structure set elif node.GetAssociatedNode() and node.GetAssociatedNode().IsA('vtkMRMLSegmentationNode'): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 # Define type-specific required tags and default values exportable.setTag('Modality', 'RTSTRUCT') # Potential anatomical image for an RT study elif node.GetAssociatedNode() and node.GetAssociatedNode().IsA('vtkMRMLScalarVolumeNode'): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 0.3 # Might be some other kind of scalar volume, but also anatomical volume in an RT study # Define type-specific required tags and default values exportable.setTag('Modality', 'CT') exportable.setTag('Manufacturer', 'Unknown manufacturer') exportable.setTag('Model', 'Unknown model') exportable.setTag('SeriesUID', 'XXXXXXX') # Node is exportable as RT series if exportable != None: # Set common properties for RT exportable exportable.name = self.loadType exportable.tooltip = "Create DICOM files from RT study" exportable.nodeID = node.GetID() exportable.pluginClass = self.__module__ # Define common required tags and default values exportable.setTag('SeriesDescription', 'No series description') exportable.setTag('SeriesNumber', '1') return [exportable] # Not recognized as potential RT object return []
def examineForExport(self, subjectHierarchyItemID): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ # Check if setting of DICOM UIDs is supported (if not, then we cannot export to sequence) dicomUIDSettingSupported = False createDicomSeriesParameterNode = slicer.modules.createdicomseries.cliModuleLogic().CreateNode() # CreateNode() factory method incremented the reference count, we decrement now prevent memory leaks # (a reference is still kept by createDicomSeriesParameterNode Python variable). createDicomSeriesParameterNode.UnRegister(None) for groupIndex in range(createDicomSeriesParameterNode.GetNumberOfParameterGroups()): if createDicomSeriesParameterNode.GetParameterGroupLabel(groupIndex) == "Unique Identifiers (UIDs)": dicomUIDSettingSupported = True if not dicomUIDSettingSupported: # This version of Slicer does not allow setting DICOM UIDs for export return [] # cannot export if there is no data node or the data node is not a volume shn = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene) dataNode = shn.GetItemDataNode(subjectHierarchyItemID) if dataNode is None or not dataNode.IsA('vtkMRMLScalarVolumeNode'): # not a volume node return [] sequenceBrowserNode = self.getSequenceBrowserNodeForMasterOutputNode(dataNode) if not sequenceBrowserNode: # this seems to be a simple volume node (not a proxy node of a volume # sequence). This plugin only deals with volume sequences. return [] sequenceItemCount = sequenceBrowserNode.GetMasterSequenceNode().GetNumberOfDataNodes() if sequenceItemCount <= 1: # this plugin is only relevant if there are multiple items in the sequence return [] # Define basic properties of the exportable exportable = slicer.qSlicerDICOMExportable() exportable.name = self.loadType exportable.tooltip = "Creates a series of DICOM files from volume sequences" exportable.subjectHierarchyItemID = subjectHierarchyItemID exportable.pluginClass = self.__module__ exportable.confidence = 0.6 # Simple volume has confidence of 0.5, use a slightly higher value here # Define required tags and default values exportable.setTag('SeriesDescription', f'Volume sequence of {sequenceItemCount} frames') exportable.setTag('Modality', 'CT') exportable.setTag('Manufacturer', 'Unknown manufacturer') exportable.setTag('Model', 'Unknown model') exportable.setTag('StudyID', '1') exportable.setTag('SeriesNumber', '1') exportable.setTag('SeriesDate', '') exportable.setTag('SeriesTime', '') return [exportable]
def _examineExportableForSegmentationNode(self, shNode, subjectHierarchyItemID): dataNode = shNode.GetItemDataNode(subjectHierarchyItemID) exportable = None if dataNode and dataNode.IsA('vtkMRMLSegmentationNode'): # Check to make sure all referenced UIDs exist in the database. instanceUIDs = shNode.GetItemAttribute(subjectHierarchyItemID, "DICOM.ReferencedInstanceUIDs").split() if instanceUIDs != "" and all(slicer.dicomDatabase.fileForInstance(uid) != "" for uid in instanceUIDs): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 exportable.setTag('Modality', 'SEG') return exportable
def _examineExportableForSegmentationNode(self, shNode, subjectHierarchyItemID): dataNode = shNode.GetItemDataNode(subjectHierarchyItemID) exportable = None if dataNode and dataNode.IsA('vtkMRMLSegmentationNode'): # Check to make sure all referenced UIDs exist in the database. instanceUIDs = shNode.GetItemAttribute( subjectHierarchyItemID, "DICOM.ReferencedInstanceUIDs").split() if instanceUIDs != "" and all( slicer.dicomDatabase.fileForInstance(uid) != "" for uid in instanceUIDs): exportable = slicer.qSlicerDICOMExportable() exportable.confidence = 1.0 exportable.setTag('Modality', 'SEG') return exportable
def examineForExport(self, subjectHierarchyItemID): """Return a list of DICOMExportable instances that describe the available techniques that this plugin offers to convert MRML data into DICOM data """ # Define basic properties of the exportable exportable = slicer.qSlicerDICOMExportable() exportable.name = "Slicer data bundle" exportable.tooltip = "Creates a series that embeds the entire Slicer scene in a private DICOM tag" exportable.subjectHierarchyItemID = subjectHierarchyItemID exportable.pluginClass = self.__module__ exportable.confidence = 0.1 # There could be more specialized volume types # Do not define tags (exportable.setTag) because they would overwrite values in the reference series return [exportable]