Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/DicomModification.cpp @ 4691:a08ef46c95a1
applying modifications to subsequences after all the other modifications
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Jun 2021 12:15:38 +0200 |
parents | 13efc0967cea |
children | 45bce660ce3a |
comparison
equal
deleted
inserted
replaced
4690:13efc0967cea | 4691:a08ef46c95a1 |
---|---|
962 assert(it->second != NULL); | 962 assert(it->second != NULL); |
963 toModify.Replace(it->first, *it->second, true /* decode data URI scheme */, | 963 toModify.Replace(it->first, *it->second, true /* decode data URI scheme */, |
964 DicomReplaceMode_InsertIfAbsent, privateCreator_); | 964 DicomReplaceMode_InsertIfAbsent, privateCreator_); |
965 } | 965 } |
966 | 966 |
967 // (6) New in Orthanc 1.9.4: Apply modifications to subsequences | 967 // (6) Update the DICOM identifiers |
968 if (level_ <= ResourceType_Study && | |
969 !IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID)) | |
970 { | |
971 if (keepStudyInstanceUid_) | |
972 { | |
973 LOG(WARNING) << "Modifying a study while keeping its original StudyInstanceUID: This should be avoided!"; | |
974 } | |
975 else | |
976 { | |
977 MapDicomTags(toModify, ResourceType_Study); | |
978 } | |
979 } | |
980 | |
981 if (level_ <= ResourceType_Series && | |
982 !IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID)) | |
983 { | |
984 if (keepSeriesInstanceUid_) | |
985 { | |
986 LOG(WARNING) << "Modifying a series while keeping its original SeriesInstanceUID: This should be avoided!"; | |
987 } | |
988 else | |
989 { | |
990 MapDicomTags(toModify, ResourceType_Series); | |
991 } | |
992 } | |
993 | |
994 if (level_ <= ResourceType_Instance && // Always true | |
995 !IsReplaced(DICOM_TAG_SOP_INSTANCE_UID)) | |
996 { | |
997 if (keepSopInstanceUid_) | |
998 { | |
999 LOG(WARNING) << "Modifying an instance while keeping its original SOPInstanceUID: This should be avoided!"; | |
1000 } | |
1001 else | |
1002 { | |
1003 MapDicomTags(toModify, ResourceType_Instance); | |
1004 } | |
1005 } | |
1006 | |
1007 // (7) Update the "referenced" relationships in the case of an anonymization | |
1008 if (isAnonymization_) | |
1009 { | |
1010 RelationshipsVisitor visitor(*this); | |
1011 | |
1012 if (updateReferencedRelationships_) | |
1013 { | |
1014 const_cast<const ParsedDicomFile&>(toModify).Apply(visitor); | |
1015 } | |
1016 else | |
1017 { | |
1018 visitor.RemoveRelationships(toModify); | |
1019 } | |
1020 } | |
1021 | |
1022 // (8) New in Orthanc 1.9.4: Apply modifications to subsequences | |
968 for (ListOfPaths::const_iterator it = removeSequences_.begin(); | 1023 for (ListOfPaths::const_iterator it = removeSequences_.begin(); |
969 it != removeSequences_.end(); ++it) | 1024 it != removeSequences_.end(); ++it) |
970 { | 1025 { |
971 assert(it->GetPrefixLength() > 0); | 1026 assert(it->GetPrefixLength() > 0); |
972 toModify.RemovePath(*it); | 1027 toModify.RemovePath(*it); |
977 { | 1032 { |
978 assert(*it != NULL); | 1033 assert(*it != NULL); |
979 assert((*it)->GetPath().GetPrefixLength() > 0); | 1034 assert((*it)->GetPath().GetPrefixLength() > 0); |
980 toModify.ReplacePath((*it)->GetPath(), (*it)->GetValue(), true /* decode data URI scheme */, | 1035 toModify.ReplacePath((*it)->GetPath(), (*it)->GetValue(), true /* decode data URI scheme */, |
981 DicomReplaceMode_InsertIfAbsent, privateCreator_); | 1036 DicomReplaceMode_InsertIfAbsent, privateCreator_); |
982 } | |
983 | |
984 // (7) Update the DICOM identifiers | |
985 if (level_ <= ResourceType_Study && | |
986 !IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID)) | |
987 { | |
988 if (keepStudyInstanceUid_) | |
989 { | |
990 LOG(WARNING) << "Modifying a study while keeping its original StudyInstanceUID: This should be avoided!"; | |
991 } | |
992 else | |
993 { | |
994 MapDicomTags(toModify, ResourceType_Study); | |
995 } | |
996 } | |
997 | |
998 if (level_ <= ResourceType_Series && | |
999 !IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID)) | |
1000 { | |
1001 if (keepSeriesInstanceUid_) | |
1002 { | |
1003 LOG(WARNING) << "Modifying a series while keeping its original SeriesInstanceUID: This should be avoided!"; | |
1004 } | |
1005 else | |
1006 { | |
1007 MapDicomTags(toModify, ResourceType_Series); | |
1008 } | |
1009 } | |
1010 | |
1011 if (level_ <= ResourceType_Instance && // Always true | |
1012 !IsReplaced(DICOM_TAG_SOP_INSTANCE_UID)) | |
1013 { | |
1014 if (keepSopInstanceUid_) | |
1015 { | |
1016 LOG(WARNING) << "Modifying an instance while keeping its original SOPInstanceUID: This should be avoided!"; | |
1017 } | |
1018 else | |
1019 { | |
1020 MapDicomTags(toModify, ResourceType_Instance); | |
1021 } | |
1022 } | |
1023 | |
1024 // (8) Update the "referenced" relationships in the case of an anonymization | |
1025 if (isAnonymization_) | |
1026 { | |
1027 RelationshipsVisitor visitor(*this); | |
1028 | |
1029 if (updateReferencedRelationships_) | |
1030 { | |
1031 const_cast<const ParsedDicomFile&>(toModify).Apply(visitor); | |
1032 } | |
1033 else | |
1034 { | |
1035 visitor.RemoveRelationships(toModify); | |
1036 } | |
1037 } | 1037 } |
1038 } | 1038 } |
1039 | 1039 |
1040 void DicomModification::SetAllowManualIdentifiers(bool check) | 1040 void DicomModification::SetAllowManualIdentifiers(bool check) |
1041 { | 1041 { |