From 6095d0776f9f8c4b3ac16c285452b19e90e98931 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Fri, 26 Oct 2018 18:04:43 -0400 Subject: [PATCH 1/3] ENH: always initialize TrackingUID If not provided by the user, initialize it. This can't hurt, but will come handy if measurements are done later using this segmentation. --- libsrc/ImageSEGConverter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libsrc/ImageSEGConverter.cpp b/libsrc/ImageSEGConverter.cpp index 1ff2a366..9e34e2b7 100644 --- a/libsrc/ImageSEGConverter.cpp +++ b/libsrc/ImageSEGConverter.cpp @@ -241,6 +241,11 @@ namespace dcmqi { if(segmentAttributes->getTrackingUniqueIdentifier().length() > 0) segment->setTrackingUID(segmentAttributes->getTrackingUniqueIdentifier().c_str()); + else { + char dimUID[128]; + dcmGenerateUniqueIdentifier(dimUID, QIICR_UID_ROOT); + segment->setTrackingUID(dimUID); + } CodeSequenceMacro* typeModifierCode = segmentAttributes->getSegmentedPropertyTypeModifierCodeSequence(); if (typeModifierCode != NULL) { From d3fa9bfe66798b067876f3fad038e18ab5741287 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Sun, 28 Oct 2018 21:57:25 -0400 Subject: [PATCH 2/3] BUG: TrackingUID requires TrackingID to be initialized --- libsrc/ImageSEGConverter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libsrc/ImageSEGConverter.cpp b/libsrc/ImageSEGConverter.cpp index 9e34e2b7..515fd9cc 100644 --- a/libsrc/ImageSEGConverter.cpp +++ b/libsrc/ImageSEGConverter.cpp @@ -238,6 +238,8 @@ namespace dcmqi { if(segmentAttributes->getTrackingIdentifier().length() > 0) segment->setTrackingID(segmentAttributes->getTrackingIdentifier().c_str()); + else + segment->setTrackingID(segmentLabel); if(segmentAttributes->getTrackingUniqueIdentifier().length() > 0) segment->setTrackingUID(segmentAttributes->getTrackingUniqueIdentifier().c_str()); From a227160993e8723bcb6dfb34bafd4f594d28de3d Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Mon, 29 Oct 2018 10:55:28 -0400 Subject: [PATCH 3/3] ENH: revise the procedure for initializing tracking info If neither TrackingID nor TrackingUID are initialized, then do nothing. If TrackingID is initialized, generate TrackingUID and print a warning alerting user that they should pay attention in case they encode longitudinal data. If TrackingUID is initialized, but TrackingID is not, reuse SegmentLabel as TrackingID, and alert the user about that. --- libsrc/ImageSEGConverter.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/libsrc/ImageSEGConverter.cpp b/libsrc/ImageSEGConverter.cpp index 515fd9cc..762f84b3 100644 --- a/libsrc/ImageSEGConverter.cpp +++ b/libsrc/ImageSEGConverter.cpp @@ -236,17 +236,35 @@ namespace dcmqi { if(segmentAttributes->getSegmentDescription().length() > 0) segment->setSegmentDescription(segmentAttributes->getSegmentDescription().c_str()); - if(segmentAttributes->getTrackingIdentifier().length() > 0) + if(segmentAttributes->getTrackingIdentifier().length() > 0){ + std::string trackingUID; + if(!segmentAttributes->getTrackingUniqueIdentifier().length()){ + std::cout << "WARNING: TrackingIdentifier is initialized, but TrackingUniqueIdentifier is not!" << std::endl; + std::cout << "TrackingUniqueIdentifier will be automatically populated. If you are encoding longitudinally" << std::endl; + std::cout << "segmented data, make sure you use the same TrackingUniqueIdentifier for the same structure!" << std::endl; + + char dimUID[128]; + dcmGenerateUniqueIdentifier(dimUID, QIICR_UID_ROOT); + trackingUID = std::string(dimUID); + } else { + trackingUID = segmentAttributes->getTrackingUniqueIdentifier(); + } segment->setTrackingID(segmentAttributes->getTrackingIdentifier().c_str()); - else - segment->setTrackingID(segmentLabel); + segment->setTrackingUID(trackingUID.c_str()); + } - if(segmentAttributes->getTrackingUniqueIdentifier().length() > 0) + if(segmentAttributes->getTrackingUniqueIdentifier().length() > 0){ + std::string trackingID; + if(!segmentAttributes->getTrackingUniqueIdentifier().length()){ + std::cout << "WARNING: TrackingUniqueIdentifier is initialized, but TrackingIdentifier is not!" << std::endl; + std::cout << "TrackingIdentifier will be automatically populated to be the same as SegmentLabel." << std::endl; + + trackingID = segmentLabel.c_str(); + } else { + trackingID = segmentAttributes->getTrackingIdentifier(); + } + segment->setTrackingID(trackingID.c_str()); segment->setTrackingUID(segmentAttributes->getTrackingUniqueIdentifier().c_str()); - else { - char dimUID[128]; - dcmGenerateUniqueIdentifier(dimUID, QIICR_UID_ROOT); - segment->setTrackingUID(dimUID); } CodeSequenceMacro* typeModifierCode = segmentAttributes->getSegmentedPropertyTypeModifierCodeSequence();