MeVisLab Toolbox Reference
mlEnhancedMultiFrameTools.h
Go to the documentation of this file.
1// Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2// **InsertLicense** code
3//----------------------------------------------------------------------------------
5
10//----------------------------------------------------------------------------------
11
12#pragma once
13
15
16#include <mlModuleIncludes.h>
17#include <DCMTree_Tree.h>
18#include <DCMTree_DicomTags.h>
19#include <DICOMPart16Tables.h>
20
21#include <list>
22
23ML_START_NAMESPACE
24
29
32
34 SourceFrameReference(DCMTree::Const_TreePtr dcmTree){ getFromDCMTree(dcmTree); }
35
38
41
43 std::string sopClassUID;
45 std::string fmeSOPClassUID;
46
48 std::string sopInstanceUID;
50 std::string fmeSOPInstanceUID;
51
54
60 std::string segmentNumber;
61
63 std::string frameCounter;
65 std::string zCoord;
67 std::string tCoord;
69 std::string uCoord;
70
72 static const std::vector<MLuint64> rawTagIds;
73
77 std::vector<std::string> &rawTopLevelSourceFrameInfos) const;
78
82 void setUpFromTagValueVector(const std::vector<std::string> &rawTopLevelSourceFrameReferences);
83
87};
88
90typedef std::vector< SourceFrameReference > SourceFrameReferenceVector;
91
101 const Vector2 &pixelSpacing,
102 double sliceThickness,
103 bool addSpacingBetweenSlices=false,
104 double spacingBetweenSlices=1.0);
105
111 const Vector3 &imagePositionPatient);
112
118 const Vector6 &imageOrientationPatient);
119
120//----------------------------------------------------------------------------------
127//----------------------------------------------------------------------------------
128ML_MLToDicomTools_EXPORT void addCIDEntry(const char * const CIDGroupTable[][CIDGroups::NUM_CID_COLUMNS],
129 size_t CIDGroupTableSize,
130 const std::string &entryToAdd,
131 DCMTree::TreePtr itemTree);
132
150 const std::vector<std::string> &derivationCodeSequence,
151 bool createEmpty=false,
152 const SourceFrameReferenceVector &sourceFrameReferences=SourceFrameReferenceVector(),
153 const size_t entriesToAddZ=std::string::npos,
154 const size_t entriesToAddT=std::string::npos,
155 const size_t entriesToAddU=std::string::npos,
156 const std::string &purposeOfReferenceCodeSequenceEntry="");
157
173 const MedicalImageProperties &medImgProps,
174 bool setTemporalPositionIndex,
175 bool setFrameAcquisitionDateTime,
176 const unsigned int ztuPos[3],
177 const unsigned int ztuNumFrames[3]);
178
182
193 DCMTree::TreePtr dcmTree,
194 bool removeReferencedImageSequence,
195 bool suppressWritingUnassignedContent);
196
198typedef std::set<std::pair<std::string, std::string>> StringPairSet;
199
211 DCMTree::RawTagId sequenceTagId,
212 DCMTree::RawTagId tagId1,
213 DCMTree::RawTagId tagId2,
214 StringPairSet &pairSet);
215
239 DCMTree::RawTagId inputSequenceTagId,
240 DCMTree::TreePtr dcmTree,
241 DCMTree::RawTagId evidenceSequenceTagId,
242 MLint insertionIndex,
243 bool scanFrames);
244
256
260
270
277 std::vector<unsigned int> referencedSegmentNumbers;
278
280 std::vector<SubImageBox> frameBoxes;
281
283 std::vector<SegmentInfos> segmentInfos;
284
286 std::vector<std::string> purposeOfReferenceCodeSequence;
287
298
300 inline bool empty() const {
301 return referencedSegmentNumbers.empty() && frameBoxes.empty() && segmentInfos.empty();
302 }
303};
304
333 const ImageVector &frameHeapImageExtent,
334 const MedicalImageProperties &medicalImageProps,
335 const std::vector<std::string> &derivationCodeSequence=std::vector<std::string>(),
336 const EnhancedMFObjectInfosBase &enhancedMFObjectInfos=EnhancedMFObjectInfosBase(),
338 std::vector<DCMTree::TagPtr> *dicomImageTypeTags=nullptr,
339 std::vector<DCMTree::TagPtr> *dicomImageDescriptionTags=nullptr,
340 bool suppressWritingUnassignedContent=false);
341
349 const ImageVector &frameHeapImageExtent,
350 const MedicalImageProperties &medicalImageProps);
351
352// Forward internally used classes.
353class DicomSegmentItem;
354
372 PagedImage &inputPagedImage,
373 ImageVector &imageExtentToAdapt,
374 const std::vector<DicomSegmentItem> &segmentItems,
375 EnhancedMFSEGObjectInfos &enhancedMFSegmentInfos,
376 bool savePaddedPixelData);
377
382 const ImageVector &inputImageExtent,
383 SourceFrameReferenceVector &sourceFrameReferences);
384
385
386ML_END_NAMESPACE
Tables containing DICOM tables from Part 16.
Project global and OS specific declarations.
#define ML_MLToDicomTools_EXPORT
Only for diagnostic purposes.
Class implementing a segmentation item according to the DICOM Segmentation Image Modul as described i...
This class encapsulates basic medical image properties:
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:67
boost::shared_ptr< Tree > TreePtr
Shared pointer to a DCMTree::Tree.
Definition DCMTree_Lib.h:66
unsigned int RawTagId
std::set< std::pair< std::string, std::string > > StringPairSet
Set of string pairs; typically to store unique pairs of DICOM UIDs.
ML_MLToDicomTools_EXPORT void addMultiFrameFunctionalGroups(DCMTree::TreePtr dcmTree, const ImageVector &frameHeapImageExtent, const MedicalImageProperties &medicalImageProps, const std::vector< std::string > &derivationCodeSequence=std::vector< std::string >(), const EnhancedMFObjectInfosBase &enhancedMFObjectInfos=EnhancedMFObjectInfosBase(), DCMTree::Const_TreePtr inputDcmTree=DCMTree::Const_TreePtr(), std::vector< DCMTree::TagPtr > *dicomImageTypeTags=nullptr, std::vector< DCMTree::TagPtr > *dicomImageDescriptionTags=nullptr, bool suppressWritingUnassignedContent=false)
Adds the perFrameFunctionalGroupsSequence and the SharedFunctionalGroupsSequence for.
ML_MLToDicomTools_EXPORT void getUniqueValuePairSetFromSequence(DCMTree::Const_TreePtr dcmTree, DCMTree::RawTagId sequenceTagId, DCMTree::RawTagId tagId1, DCMTree::RawTagId tagId2, StringPairSet &pairSet)
Looks for sequence with sequenceTagId in dcmTree and if found then all items of the sequence are pars...
ML_MLToDicomTools_EXPORT void addUnassignedSharedConvertedAttributes(DCMTree::Const_TreePtr inputDcmTree, DCMTree::TreePtr dcmTree, bool removeReferencedImageSequence, bool suppressWritingUnassignedContent)
Adds the UnassignedSharedFunctionaGroupsSequence and a first entry to dcmTree if they still do not ex...
ML_MLToDicomTools_EXPORT void addMultiFrameDimensionTags(DCMTree::TreePtr dcmTree, const ImageVector &frameHeapImageExtent, const MedicalImageProperties &medicalImageProps)
Adds the perFrameFunctionalGroupsSequence and the SharedFunctionalGroupƶsSequence for the Segmentatio...
ML_MLToDicomTools_EXPORT void setPlaneOrientationFunctionalGroupTags(DCMTree::TreePtr dcmTree, const Vector6 &imageOrientationPatient)
Set DCMTree_PlaneOrientationSequence sequence with tags belonging to Plane Orientation Functional Gro...
ML_MLToDicomTools_EXPORT void setFrameContentFunctionalGroupTags(DCMTree::TreePtr dcmTree, const MedicalImageProperties &medImgProps, bool setTemporalPositionIndex, bool setFrameAcquisitionDateTime, const unsigned int ztuPos[3], const unsigned int ztuNumFrames[3])
Set DCMTree_FrameContentSequence sequence with tags belonging to Frame Content Functional Group C....
ML_MLToDicomTools_EXPORT std::string addAndSetMultiBinarySEGPixelDataTag(DCMTree::TreePtr resultTree, PagedImage &inputPagedImage, ImageVector &imageExtentToAdapt, const std::vector< DicomSegmentItem > &segmentItems, EnhancedMFSEGObjectInfos &enhancedMFSegmentInfos, bool savePaddedPixelData)
In case of multiple binary segmentations this routine extracts binary segments from the segment list ...
ML_MLToDicomTools_EXPORT void setDerivationImageFunctionalGroupTags(DCMTree::TreePtr seqItemTreePtr, const std::vector< std::string > &derivationCodeSequence, bool createEmpty=false, const SourceFrameReferenceVector &sourceFrameReferences=SourceFrameReferenceVector(), const size_t entriesToAddZ=std::string::npos, const size_t entriesToAddT=std::string::npos, const size_t entriesToAddU=std::string::npos, const std::string &purposeOfReferenceCodeSequenceEntry="")
Set DCMTree_DerivationImageSequence sequence with tags belonging to Derivation Image Functional Group...
ML_MLToDicomTools_EXPORT void setPixelMeasuresFunctionalGroupTags(DCMTree::TreePtr dcmTree, const Vector2 &pixelSpacing, double sliceThickness, bool addSpacingBetweenSlices=false, double spacingBetweenSlices=1.0)
Set DCMTree_PixelMeasuresSequence sequence with tags belonging to Pixel Measures Functional Group C....
ML_MLToDicomTools_EXPORT void removedDuplicatedUnassignedSharedConvertedAttributes(DCMTree::TreePtr dcmTree)
Removes all tags from SharedFunctionalGroupSequence/UnassignedSharedConvertedAttributes which already...
ML_MLToDicomTools_EXPORT void addCIDEntry(const char *const CIDGroupTable[][CIDGroups::NUM_CID_COLUMNS], size_t CIDGroupTableSize, const std::string &entryToAdd, DCMTree::TreePtr itemTree)
Adds the code sequence entry entryToAdd.
ML_MLToDicomTools_EXPORT void buildImageEvidenceSequence(DCMTree::Const_TreePtr inputDcmTree, DCMTree::RawTagId inputSequenceTagId, DCMTree::TreePtr dcmTree, DCMTree::RawTagId evidenceSequenceTagId, MLint insertionIndex, bool scanFrames)
Creates and adds and ImageEvidenceSequence with Tag Id evidenceSequenceTagId to dcmTree and fills it ...
ML_MLToDicomTools_EXPORT void setPlanePositionFunctionalGroupTags(DCMTree::TreePtr dcmTree, const Vector3 &imagePositionPatient)
Set DCMTree_PlanePositionSequence sequence with tags belonging to Segmentation Functional Group C....
ML_MLToDicomTools_EXPORT void getSourceImageSequenceInformation(DCMTree::Const_TreePtr inputDcmTree, const ImageVector &inputImageExtent, SourceFrameReferenceVector &sourceFrameReferences)
Analyzes the inputDcmTree and extracts a SourceFrameReference entry for each input frame given by inp...
std::vector< SourceFrameReference > SourceFrameReferenceVector
A vector of SourceFrameReference, each one referencing a frame of a source image.
Currently empty class used as base for all classes carrying additional IOD object information.
virtual ~EnhancedMFObjectInfosBase()=default
Default virtual destructor.
EnhancedMFObjectInfosBase & operator=(const EnhancedMFObjectInfosBase &)=default
Default assignment operator.
EnhancedMFObjectInfosBase()=default
Default virtual destructor.
EnhancedMFObjectInfosBase(const EnhancedMFObjectInfosBase &)=default
Default copy constructor.
Structure providing SEG IOD specific information for and about composed BitImage Frame heap to be sav...
std::vector< SubImageBox > frameBoxes
A vector of SubImageBoxes for all frames.
bool empty() const
Returns true if all vectors are empty which indicates that its shall not be used at all.
SourceFrameReferenceVector sourceFrameReferenceVector
A vector of vectors of (SOPClassUIDs, SOPInstanceUID, ReferencedFrameNumber, ReferencedSegmentNumber)...
std::vector< SegmentInfos > segmentInfos
A vector of SegmentInfos; one info for each segment.
std::vector< unsigned int > referencedSegmentNumbers
Vector of referenced Segment number to indicate which segment number is related to a given frame of a...
std::vector< std::string > purposeOfReferenceCodeSequence
Code sequence to be used in Source Image Sequence if that sequence is filled.
Structure providing additional (IOD specific) information for Legacy Converted Enhanced MR; still not...
Structure providing SEG IOD specific information for and about composed BitImage Frame heap to be sav...
SubImageBox box
The subimage box of the segment in voxel position related to the inputPagedImage.
MLint segmentFrames
The number of frames in the Enhanced multi-frame Heap of frames unrolled in the z-dimension.
MLint startFrame
The index of the first frame in the Enhanced multi-frame Heap of frames unrolled in the z-dimension.
Structure to collect important information of input frames.
SourceFrameReference(DCMTree::Const_TreePtr dcmTree)
Constructor with initialization from a DCMTree.
static const std::vector< MLuint64 > rawTagIds
Raw tag ids matching to the order of the first seven fields which contain tag values.
void getFromDCMTree(DCMTree::Const_TreePtr inputDcmTree)
Tries to read the srcFrameRef.rawTagIds tags from inputDcmTree and to set up all members of srcFrameR...
std::string referencedFrameNumber
ReferencedFrameNumber.
std::string fmeSOPInstanceUID
If available the SOPInstanceUID of an input frame or image from private FME tag.
std::string fmeIndexOfDecomposedFrame
If available the index of decomposed frame from private FME tag.
void setUpFromTagValueVector(const std::vector< std::string > &rawTopLevelSourceFrameReferences)
Assigns the values of rawTopLevelSourceFrameReferences to all members of srcFrameRef in given order.
~SourceFrameReference()
Default constructor.
SourceFrameReference & operator=(const SourceFrameReference &)=default
Default copy constructor.
SourceFrameReference(const SourceFrameReference &)=default
Default copy constructor.
std::string referencedSegmentNumber
ReferencedSegmentNumber.
SourceFrameReference()=default
Default constructor.
std::string segmentNumber
SegmentNumber.
std::string sopInstanceUID
SOPInstanceUID of an input frame or image.
std::string sopClassUID
SOPClassUID of an input frame or image.
void getRawTopLevelSourceFrameReferences(DCMTree::Const_TreePtr inputDcmTree, std::vector< std::string > &rawTopLevelSourceFrameInfos) const
Return tag values given in rawTagIds from tree root and append four empty entries for non-available f...
std::string frameCounter
Frame Counter.
std::string fmeSOPClassUID
If available the SOPClassUID of an input frame or image from private FME tag.