From 3742735cf853a5c2bf45f808b44e5dfffac14e5f Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Fri, 26 Oct 2018 18:22:12 -0400 Subject: [PATCH] ENH: propagate tracking identification from SEG, if available TrackingIdentifier and TrackingUniqueIdentifier are required. If not specified, TrackingUniqueIdentifier will be initialized automatically by dcmqi. If either one is available in SEG, propagate to link with the measurements. Related PR for dcmqi will make sure TrackingUniqueIdentifier is always created for SEG segments. It does not hurt, but will become useful if those segments are later used for measurements. See https://github.com/QIICR/dcmqi/pull/365. --- labs/pyradiomics-dcm/pyradiomics-dcm.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/labs/pyradiomics-dcm/pyradiomics-dcm.py b/labs/pyradiomics-dcm/pyradiomics-dcm.py index 1a49f659..6e1903fd 100644 --- a/labs/pyradiomics-dcm/pyradiomics-dcm.py +++ b/labs/pyradiomics-dcm/pyradiomics-dcm.py @@ -105,6 +105,18 @@ def getSegmentSegmentationTypeCode(self, segmentNumber): except BaseException: return None + def getTrackingIdentifier(self, segmentNumber): + try: + return self.dcm.SegmentSequence[segmentNumber].TrackingIdentifier + except BaseException: + return None + + def getTrackingUniqueIdentifier(self, segmentNumber): + try: + return self.dcm.SegmentSequence[segmentNumber].TrackingUID + except BaseException: + return None + def getSegmentAnatomicLocationCode(self, segmentNumber): try: return self.dcm.SegmentSequence[segmentNumber].AnatomicRegionSequence[0] @@ -493,8 +505,18 @@ def main(): m.m["Measurements"][-1]["Finding"] = CodedValue(segmentationType.CodeValue, segmentationType.CodingSchemeDesignator, segmentationType.CodeMeaning).getDict() + + segTrackingIdentifier = segmentationMetadataAccessor.getTrackingIdentifier(int(segmentNumber)-1) + segTrackingUniqueIdentifier = segmentationMetadataAccessor.getTrackingUniqueIdentifier(int(segmentNumber)-1) + + if segTrackingIdentifier: + m.m["Measurements"][-1]["TrackingIdentifier"] = segTrackingIdentifier + else: m.m["Measurements"][-1]["TrackingIdentifier"] = segmentationType.CodeMeaning + if segTrackingUniqueIdentifier: + m.m["Measurements"][-1]["TrackingUniqueIdentifier"] = segTrackingUniqueIdentifier + segmentationLocation = segmentationMetadataAccessor.getSegmentAnatomicLocationCode( int(segmentNumber) - 1) if segmentationLocation: @@ -503,10 +525,12 @@ def main(): segmentationLocation.CodeMeaning).getDict() # AlgorithmIdentification + ''' m.m["Measurements"][-1]["measurementAlgorithmIdentification"] = {} m.m["Measurements"][-1]["measurementAlgorithmIdentification"]["AlgorithmName"] = "https://github.com/Radiomics/pyradiomics" m.m["Measurements"][-1]["measurementAlgorithmIdentification"]["AlgorithmVersion"] = pyradiomicsVersion m.m["Measurements"][-1]["measurementAlgorithmIdentification"]["AlgorithmParameters"] = [json.dumps(extractor.settings)] + ''' m.m["observerContext"] = {} m.m["observerContext"]["ObserverType"] = "DEVICE"