Mercurial > hg > orthanc
changeset 4771:9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 Aug 2021 17:20:21 +0200 |
parents | 248408d2b336 |
children | ec8aef42a7db add0337b928a |
files | OrthancFramework/Sources/DicomFormat/DicomTag.h OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp |
diffstat | 6 files changed, 95 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomFormat/DicomTag.h Wed Aug 25 15:42:34 2021 +0200 +++ b/OrthancFramework/Sources/DicomFormat/DicomTag.h Wed Aug 25 17:20:21 2021 +0200 @@ -172,6 +172,9 @@ static const DicomTag DICOM_TAG_PATIENT_SPECIES_DESCRIPTION(0x0010, 0x2201); static const DicomTag DICOM_TAG_STUDY_COMMENTS(0x0032, 0x4000); static const DicomTag DICOM_TAG_OTHER_PATIENT_IDS(0x0010, 0x1000); + static const DicomTag DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUP_SEQUENCE(0x5200, 0x9230); + static const DicomTag DICOM_TAG_PIXEL_VALUE_TRANSFORMATION_SEQUENCE(0x0028, 0x9145); + static const DicomTag DICOM_TAG_FRAME_VOI_LUT_SEQUENCE(0x0028, 0x9132); // Tags used within the Stone of Orthanc static const DicomTag DICOM_TAG_FRAME_INCREMENT_POINTER(0x0028, 0x0009);
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Wed Aug 25 15:42:34 2021 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Wed Aug 25 17:20:21 2021 +0200 @@ -3162,6 +3162,56 @@ IDicomPathVisitor::Apply(visitor, dataset, path); } } + + + bool FromDcmtkBridge::LookupSubSequence(DicomMap& target, + DcmDataset& dataset, + const DicomPath& path, + size_t sequenceIndex) + { + class Visitor : public FromDcmtkBridge::IDicomPathVisitor + { + private: + bool found_; + DicomMap& target_; + size_t sequenceIndex_; + + public: + Visitor(DicomMap& target, + size_t sequenceIndex) : + found_(false), + target_(target), + sequenceIndex_(sequenceIndex) + { + } + + virtual void Visit(DcmItem& item, + const DicomPath& path) ORTHANC_OVERRIDE + { + DcmTagKey tag(path.GetFinalTag().GetGroup(), path.GetFinalTag().GetElement()); + + DcmSequenceOfItems *sequence = NULL; + + if (item.findAndGetSequence(tag, sequence).good() && + sequence != NULL && + sequenceIndex_ < sequence->card()) + { + std::set<DicomTag> ignoreTagLength; + ExtractDicomSummary(target_, *sequence->getItem(sequenceIndex_), 0, ignoreTagLength); + found_ = true; + } + } + + bool HasFound() const + { + return found_; + } + }; + + Visitor visitor(target, sequenceIndex); + IDicomPathVisitor::Apply(visitor, dataset, path); + return visitor.HasFound(); + } }
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h Wed Aug 25 15:42:34 2021 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h Wed Aug 25 17:20:21 2021 +0200 @@ -277,5 +277,10 @@ const DicomPath& path, const DcmElement& element, DicomReplaceMode mode); + + static bool LookupSubSequence(DicomMap& target, + DcmDataset& dataset, + const DicomPath& path, + size_t sequenceIndex); }; }
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Wed Aug 25 15:42:34 2021 +0200 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Wed Aug 25 17:20:21 2021 +0200 @@ -1777,6 +1777,15 @@ } + bool ParsedDicomFile::LookupSubSequence(DicomMap& target, + const DicomPath& path, + size_t sequenceIndex) const + { + DcmDataset& dataset = *const_cast<ParsedDicomFile&>(*this).GetDcmtkObject().getDataset(); + return FromDcmtkBridge::LookupSubSequence(target, dataset, path, sequenceIndex); + } + + #if ORTHANC_BUILDING_FRAMEWORK_LIBRARY == 1 // Alias for binary compatibility with Orthanc Framework 1.7.2 => don't use it anymore void ParsedDicomFile::DatasetToJson(Json::Value& target,
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h Wed Aug 25 15:42:34 2021 +0200 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h Wed Aug 25 17:20:21 2021 +0200 @@ -285,5 +285,9 @@ void ClearPath(const DicomPath& path, bool onlyIfExists); + + bool LookupSubSequence(DicomMap& target, + const DicomPath& path, + size_t sequenceIndex) const; }; }
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Wed Aug 25 15:42:34 2021 +0200 +++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Wed Aug 25 17:20:21 2021 +0200 @@ -2739,6 +2739,30 @@ ASSERT_EQ("1.2.840.113619.2.176.2025.1499492.7040.1171286241.726", vv[REF_IM_SEQ][1][REF_SOP_INSTANCE].asString()); // kept ASSERT_EQ("1.2.840.113704.1.111.7016.1342451220.40", vv[REL_SERIES_SEQ][0][STUDY_INSTANCE_UID].asString()); // kept } + + { + std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); + + DicomMap m; + ASSERT_TRUE(dicom->LookupSubSequence(m, DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE), 0)); + ASSERT_EQ(2u, m.GetSize()); + ASSERT_EQ("1.2.840.113619.2.176.2025.1499492.7040.1171286241.719", + m.GetStringValue(DICOM_TAG_REFERENCED_SOP_INSTANCE_UID, "", false)); + + ASSERT_TRUE(dicom->LookupSubSequence(m, DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE), 1)); + ASSERT_EQ(2u, m.GetSize()); + ASSERT_EQ("1.2.840.113619.2.176.2025.1499492.7040.1171286241.726", + m.GetStringValue(DICOM_TAG_REFERENCED_SOP_INSTANCE_UID, "", false)); + + ASSERT_FALSE(dicom->LookupSubSequence(m, DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE), 2)); + + ASSERT_TRUE(dicom->LookupSubSequence(m, DicomPath(DicomTag(0x0008, 0x1250), 0, DicomTag(0x0040, 0xa170)), 0)); + ASSERT_EQ(2u, m.GetSize()); + ASSERT_EQ("122403", m.GetStringValue(DicomTag(0x0008, 0x0100), "", false)); + ASSERT_EQ("WORLD", m.GetStringValue(DICOM_TAG_SERIES_DESCRIPTION, "", false)); + + ASSERT_FALSE(dicom->LookupSubSequence(m, DicomPath(DicomTag(0x0008, 0x1250), 0, DicomTag(0x0040, 0xa170)), 1)); + } }