MeVisLab Toolbox Reference
DCMTree_StructuredMF.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef DCM_TREE_STRUCTURED_MF_H
14#define DCM_TREE_STRUCTURED_MF_H
15
16#include "DCMTree_Lib.h"
17#include "DCMTree_TagId.h"
18
19#ifdef _MSC_VER
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22#endif
23
24namespace DCMTree
25{
50 {
51 public:
52
54 typedef std::vector<unsigned int> IndexVector;
55
57 static std::string privateCreator; /* = "MeVis StructuredMF data" */
58
59 // Private group and element ID constants used for storing the StructuredMF information
60 enum {
61 privateGroupId = 0x0041,
62
63 dimensionsOffset = 1,
64 dimensionSequenceOffset = 2,
65 frameIndexOffset = 3
66 };
67
68
74
79
84 StructuredMF( TreePtr sharedTagTree, unsigned int depth,
85 unsigned int timePoints = 0, unsigned int u1Size = 0);
86
87
92
93
95
102 Const_TagPtr sharedTag( TagId tagId, const std::string& privateCreatorArg, Vr privateVr=UN ) const;
103
107
110
111
113
117 Const_TagPtr tagForGridPosition( TagId tagId, unsigned int z, unsigned int t = 0, unsigned int u1 = 0 ) const;
118
123 Const_TagPtr tagForGridPosition( TagId tagId, const std::string& privateCreatorArg, Vr privateVr, unsigned int z, unsigned int t = 0, unsigned int u1 = 0 ) const;
124
128 int frameIndexForGridPosition( unsigned int z, unsigned int t = 0, unsigned int u1 = 0 ) const;
129
131 typedef enum {
134 ExtractSpecificWithSharedParent
135 } ExtractMode;
136
140 TreePtr extractTagTreeForGridPosition( unsigned int z, unsigned int t = 0, unsigned int u1 = 0,
141 ExtractMode mode = ExtractSharedAndSpecific ) const;
142
148 void setTagForGridPosition( TagPtr tag, unsigned int z, unsigned int t = 0, unsigned int u1 = 0, const std::string& privateCreatorArg = "" );
149
154 void setGridPositionSpecificTags( TreePtr tree, unsigned int z, unsigned int t = 0, unsigned int u1 = 0 );
155
159 void setFrameIndexForGridPosition( unsigned int frameIndex, unsigned int z, unsigned int t = 0, unsigned int u1 = 0 );
161
162
165
168 OK = 0,
170 AMBIGUOUS_TAG,
173
174 NUM_STATUS_CODES
175 };
176
181 void normalizeTagStructure( double tolerance = 0.0, bool compress = true );
183
184
187
195 boost::uint32_t getGridDimension() const;
196
199
201 unsigned int getNumberOfFrames() const;
202
204 bool frameExists( const IndexVector& position ) const;
205
208 void getEmptyFrames (std::vector<IndexVector> &positions) const;
209
215
216
221 void setAlsoRegardEnhancedMultiFrameTags(bool flag) { _alsoRegardEnhancedMultiFrameTags = flag; }
222 bool alsoRegardEnhancedMultiFrameTags() const { return _alsoRegardEnhancedMultiFrameTags; }
223
225 bool privateTagsAreSet() const;
227
228 private:
230 bool initPrivateTagIds(bool newOrExisting);
232 void clearPrivateTags();
234 void createPrivateCreatorTag();
236 bool isPrivateTagId (const TagId &tagId) const;
238 bool isSingleSlice() const;
240 TagInfo dimensionsTagInfo();
243 TagInfo dimensionGroupTagInfo();
245 TagInfo frameIndexTagInfo();
247 TagInfo defaultCreatorTagInfo();
250 void normalizeTagStructure( TreePtr dimTree, double tolerance, bool compress );
252 Const_TreePtr gridPositionTagTree( IndexVector gridPosition ) const;
254 void createDimensionSubtree( TagPtr parentSeq, int index);
256 void setDimensionsTag();
258 Const_TagPtr dimensionSequence() const;
259
261 IndexVector indexVectorFromIndexes( unsigned int z, unsigned int t, unsigned int u1 ) const;
263 TreePtr getGridItemOrSharedTree(const IndexVector &gridPosition);
264
269 bool checkGridPosition(const IndexVector &gridPosition) const;
270
273 Const_TagPtr searchForTagInFunctionalGroups( Const_TagPtr functionalGroupTag, TagId tagId, unsigned int itemIndex = 0 ) const;
274
276 TreePtr _treePtr;
278 Const_TreePtr _constTreePtr;
280 IndexVector _gridExtent;
281
283 TagId _creatorId, _privateBaseId, _dimensionsId, _dimensionSequenceId, _frameIndexId;
284
286 bool _alsoRegardEnhancedMultiFrameTags{};
287 };
288}
289
290#ifdef _MSC_VER
291 #pragma warning (pop)
292#endif
293
294#endif
#define DCMTREE_EXPORT
Support for structured multi-frame (SMF) DICOM objects.
Const_TagPtr sharedTag(TagId tagId) const
Returns a const pointer to the specified shared tag.
void setTagForGridPosition(TagPtr tag, unsigned int z, unsigned int t=0, unsigned int u1=0, const std::string &privateCreatorArg="")
TreePtr extractTagTreeForGridPosition(IndexVector gridPosition, ExtractMode mode=ExtractSharedAndSpecific) const
Extract all DICOM tags for a given index vector (deep copy).
Const_TreePtr tagTree() const
Returns a const pointer to the contained tag tree.
bool frameExists(const IndexVector &position) const
Returns true if frame at a given grid position exists.
bool privateTagsAreSet() const
Returns true if the internal private tags have been initialized.
void setGridPositionSpecificTags(TreePtr tree, unsigned int z, unsigned int t=0, unsigned int u1=0)
Const_TagPtr tagForGridPosition(TagId tagId, IndexVector gridPosition) const
Returns a pointer to the specified tag for a given grid position.
StatusCode
Status code constants.
@ NO_PER_FRAME_TAGS
A per-frame tag list is empty.
@ INCONSISTENT_PER_FRAME_TAGS
The per-frame tag lists define different sets of tags.
void setFrameIndexForGridPosition(unsigned int frameIndex, unsigned int z, unsigned int t=0, unsigned int u1=0)
void normalizeTagStructure(double tolerance=0.0, bool compress=true)
Makes sure all grid position specific tags are consistent: each tag shall exist either for each grid ...
int frameIndexForGridPosition(unsigned int z, unsigned int t=0, unsigned int u1=0) const
void setGridPositionSpecificTags(TreePtr tree, const IndexVector &gridPosition, bool skipInvalidPrivateTags=true)
Adds/replaces specific tags for a given grid position (no copy); if skipInvalidPrivateTags is false,...
Const_TagPtr tagForGridPosition(TagId tagId, unsigned int z, unsigned int t=0, unsigned int u1=0) const
const IndexVector & getGridExtent() const
Returns the extents of the logical grid (i.e., the size in each dimension).
void getEmptyFrames(std::vector< IndexVector > &positions) const
Fills positions vector with unoccupied logical grid positions, i.e., positions for which no frame dat...
boost::uint32_t getGridDimension() const
Returns the dimension of the logical grid (i.e., the number of dimensions).
TreePtr extractTagTreeForGridPosition(unsigned int z, unsigned int t=0, unsigned int u1=0, ExtractMode mode=ExtractSharedAndSpecific) const
static std::string privateCreator
Private creator string used for storing the StructuredMF information.
Const_TagPtr sharedTag(TagId tagId, const std::string &privateCreatorArg, Vr privateVr=UN) const
Returns a const pointer to the specified shared tag with the given private creator and VR.
int frameIndexForGridPosition(const IndexVector &gridPosition) const
Returns the frame index of the original image for a given grid position.
TreePtr tagTree()
Returns a pointer to the contained tag tree.
void setSharedTags(TreePtr tree, bool handleFuncGroups=true)
Adds/replaces shared tags with the given tag tree (no copy).
std::vector< unsigned int > IndexVector
Index vector type, ordered as (z, t, u1, u2, ...)
Const_TagPtr tagForGridPosition(TagId tagId, const std::string &privateCreatorArg, Vr privateVr, unsigned int z, unsigned int t=0, unsigned int u1=0) const
StructuredMF(Const_TreePtr tree)
Constructor.
Const_TagPtr tagForGridPosition(TagId tagId, IndexVector gridPosition, const std::string &privateCreatorArg, Vr privateVr=UN) const
Returns a pointer to the specified tag for a given index vector or grid position.
TreePtr gridPositionTagTree(IndexVector gridPosition)
Returns a pointer to a specific dimension index tree.
void setTagForGridPosition(TagPtr tag, const IndexVector &gridPosition, const std::string &privateCreatorArg="", bool skipInvalidPrivateTags=true)
Adds/replaces specified tag for a given grid position (no copy); if skipInvalidPrivateTags is false,...
StructuredMF(TreePtr tree)
Constructor.
TagPtr sharedTag_rw(TagId tagId)
Returns a writable pointer to the specified shared tag.
TreePtr extractSharedTagTree() const
Extracts all DICOM tags valid for all frames (deep copy).
void setAlsoRegardEnhancedMultiFrameTags(bool flag)
void setFrameIndexForGridPosition(unsigned int frameIndex, const IndexVector &gridPosition)
Sets frame index of original image (for MF data only).
bool alsoRegardEnhancedMultiFrameTags() const
ExtractMode
Constants for extracting DICOM tags for a given index vector.
@ ExtractSharedAndSpecific
Shared and frame-specific tags are copied to new tree.
@ ExtractSpecific
Only frame-specific tags are copied to new tree.
unsigned int getNumberOfFrames() const
Returns total number of frames.
StructuredMF(TreePtr sharedTagTree, unsigned int depth, unsigned int timePoints=0, unsigned int u1Size=0)
StructuredMF(TreePtr sharedTagTree, const IndexVector &gridExtent)
Constructor.
Class to wrap a tag ID.
Class to carry meta information about a specific tag.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Class to dump a DCMTree DICOM message into a human-readable file.
boost::shared_ptr< const Tag > Const_TagPtr
Definition DCMTree_Lib.h:57
Vr
DICOM VR.
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:67
boost::shared_ptr< Tag > TagPtr
Shared pointer to tag.
Definition DCMTree_Lib.h:56
boost::shared_ptr< Tree > TreePtr
Shared pointer to a DCMTree::Tree.
Definition DCMTree_Lib.h:66