Skip to content

Commit

Permalink
ENH: propagate tracking identification from SEG, if available
Browse files Browse the repository at this point in the history
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 QIICR/dcmqi#365.
  • Loading branch information
fedorov committed Oct 26, 2018
1 parent ab1bcaa commit 3742735
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions labs/pyradiomics-dcm/pyradiomics-dcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand All @@ -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"
Expand Down

0 comments on commit 3742735

Please sign in to comment.