def generateJSON4DcmSR(self, dcmSegmentationFile, sourceVolumeNode): measurements = [] sourceImageSeriesUID = ModuleLogicMixin.getDICOMValue(sourceVolumeNode, "0020,000E") logging.debug("SourceImageSeriesUID: {}".format(sourceImageSeriesUID)) segmentationSOPInstanceUID = ModuleLogicMixin.getDICOMValue(dcmSegmentationFile, "0008,0018") logging.debug("SegmentationSOPInstanceUID: {}".format(segmentationSOPInstanceUID)) for segmentID in self.statistics["SegmentIDs"]: if not self.isSegmentValid(segmentID): continue data = dict() data["TrackingIdentifier"] = self.statistics[segmentID, "Segment"] data["ReferencedSegment"] = len(measurements)+1 data["SourceSeriesForImageSegmentation"] = sourceImageSeriesUID data["segmentationSOPInstanceUID"] = segmentationSOPInstanceUID segment = self.segmentationNode.GetSegmentation().GetSegment(segmentID) terminologyEntry = DICOMSegmentationExporter.getDeserializedTerminologyEntry(segment) data["Finding"] = self.createJSONFromTerminologyContext(terminologyEntry)["SegmentedPropertyTypeCodeSequence"] anatomicContext = self.createJSONFromAnatomicContext(terminologyEntry) if anatomicContext.has_key("AnatomicRegionSequence"): data["FindingSite"] = anatomicContext["AnatomicRegionSequence"] data["measurementItems"] = self.createMeasurementItemsForLabelValue(segmentID) measurements.append(data) return measurements
def getPatientInformation(self): if not self.patientInfo: masterVolume = ModuleLogicMixin.getReferencedVolumeFromSegmentationNode(self.segmentationNode) self.patientInfo = self.patientInfoTemplate.format(ModuleLogicMixin.getDICOMValue(masterVolume, DICOMTAGS.PATIENT_NAME), ModuleLogicMixin.getDICOMValue(masterVolume, DICOMTAGS.PATIENT_ID), ModuleLogicMixin.getDICOMValue(masterVolume, DICOMTAGS.PATIENT_BIRTH_DATE)) return self.patientInfo
def getPatientInformation(self): if not self.patientInfo: masterVolume = ModuleLogicMixin.getReferencedVolumeFromSegmentationNode(self.segmentationNode) self.patientInfo = self.patientInfoTemplate.format(ModuleLogicMixin.getDICOMValue(masterVolume, DICOMTAGS.PATIENT_NAME), ModuleLogicMixin.getDICOMValue(masterVolume, DICOMTAGS.PATIENT_ID), ModuleLogicMixin.getDICOMValue(masterVolume, DICOMTAGS.PATIENT_BIRTH_DATE)) return self.patientInfo
def getSeriesAttributes(self): attributes = dict() volumeNode = self.getReferencedVolumeFromSegmentationNode(self.segmentationNode) seriesNumber = ModuleLogicMixin.getDICOMValue(volumeNode, DICOMTAGS.SERIES_NUMBER) attributes["SeriesNumber"] = "100" if seriesNumber in [None,''] else str(int(seriesNumber)+100) attributes["InstanceNumber"] = "1" return attributes
def getSeriesAttributes(self): attributes = dict() volumeNode = self.getReferencedVolumeFromSegmentationNode( self.segmentationNode) seriesNumber = ModuleLogicMixin.getDICOMValue(volumeNode, DICOMTAGS.SERIES_NUMBER) attributes["SeriesNumber"] = "100" if seriesNumber in [ None, '' ] else str(int(seriesNumber) + 100) attributes["InstanceNumber"] = "1" return attributes
def generateJSON4DcmSR(self, dcmSegmentationFile, sourceVolumeNode): measurements = [] sourceImageSeriesUID = ModuleLogicMixin.getDICOMValue( sourceVolumeNode, "0020,000E") logging.debug("SourceImageSeriesUID: {}".format(sourceImageSeriesUID)) segmentationSOPInstanceUID = ModuleLogicMixin.getDICOMValue( dcmSegmentationFile, "0008,0018") logging.debug("SegmentationSOPInstanceUID: {}".format( segmentationSOPInstanceUID)) for segmentID in self.statistics["SegmentIDs"]: if not self.isSegmentValid(segmentID): continue data = dict() data["TrackingIdentifier"] = self.statistics[segmentID, "Segment"] data["ReferencedSegment"] = len(measurements) + 1 data["SourceSeriesForImageSegmentation"] = sourceImageSeriesUID data["segmentationSOPInstanceUID"] = segmentationSOPInstanceUID segment = self.segmentationNode.GetSegmentation().GetSegment( segmentID) terminologyEntry = DICOMSegmentationExporter.getDeserializedTerminologyEntry( segment) data["Finding"] = self.createJSONFromTerminologyContext( terminologyEntry)["SegmentedPropertyTypeCodeSequence"] anatomicContext = self.createJSONFromAnatomicContext( terminologyEntry) if "AnatomicRegionSequence" in anatomicContext: data["FindingSite"] = anatomicContext["AnatomicRegionSequence"] data[ "measurementItems"] = self.createMeasurementItemsForLabelValue( segmentID) measurements.append(data) return measurements
def updateInformationFromWatchBoxAttribute(self, attribute): if attribute.tags and self.sourceFile: values = [] for tag in attribute.tags: currentValue = ModuleLogicMixin.getDICOMValue(self.sourceFile, tag, "") if tag in self.DATE_TAGS_TO_FORMAT: currentValue = self._formatDate(currentValue) elif tag == DICOMTAGS.PATIENT_NAME: currentValue = self._formatPatientName(currentValue) elif tag == self.CURRENTDIRTAG: path = os.path.normpath(self.sourceFile) folderList = path.split(os.sep) if len(folderList)>=4: currentValue = folderList[-4] values.append(currentValue) return self._getTagValueFromTagValues(values) return ""
def _processData(self, caller=None, event=None): self._seriesTypeLabel.text = "{}: {}".format( ModuleLogicMixin.getDICOMValue(self._seriesType.getVolume(), DICOMTAGS.SERIES_NUMBER), self._seriesType.getName())