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 info
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 TagInfo dimensionsTagInfo();
241 TagInfo dimensionGroupTagInfo();
243 TagInfo frameIndexTagInfo();
245 TagInfo defaultCreatorTagInfo();
248 void normalizeTagStructure( TreePtr dimTree, double tolerance, bool compress );
250 Const_TreePtr gridPositionTagTree( IndexVector gridPosition ) const;
252 void createDimensionSubtree( TagPtr parentSeq, int index);
254 void setDimensionsTag();
256 Const_TagPtr dimensionSequence() const;
257
259 IndexVector indexVectorFromIndexes( unsigned int z, unsigned int t, unsigned int u1 ) const;
261 TreePtr getGridItemOrSharedTree(const IndexVector &gridPosition);
262
267 bool checkGridPosition(const IndexVector &gridPosition) const;
268
271 Const_TagPtr searchForTagInFunctionalGroups( Const_TagPtr functionalGroupTag, TagId tagId, unsigned int itemIndex = 0 ) const;
272
274 TreePtr _treePtr;
276 Const_TreePtr _constTreePtr;
278 IndexVector _gridExtent;
279
281 TagId _creatorId, _privateBaseId, _dimensionsId, _dimensionSequenceId, _frameIndexId;
282
284 bool _alsoRegardEnhancedMultiFrameTags{};
285 };
286}
287
288#ifdef _MSC_VER
289 #pragma warning (pop)
290#endif
291
292#endif
#define DCMTREE_EXPORT
Support for structured multi-frame (SMF) DICOM objects.
Const_TagPtr sharedTag(TagId tagId) const
Get 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) Returns a null pointer if the grid positi...
Const_TreePtr tagTree() const
Return a const pointer to the contained tag tree.
bool frameExists(const IndexVector &position) const
Return true if frame at a given grid position exists.
bool privateTagsAreSet() const
Return 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
Get 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)
Make sure all grid position specific tags are consistent: each tag shall exist either for each grid p...
int frameIndexForGridPosition(unsigned int z, unsigned int t=0, unsigned int u1=0) const
void setGridPositionSpecificTags(TreePtr tree, const IndexVector &gridPosition, bool skipInvalidPrivateTags=true)
Add/replace specific tags for a given grid position (no copy); if skipInvalidPrivateTags is false the...
Const_TagPtr tagForGridPosition(TagId tagId, unsigned int z, unsigned int t=0, unsigned int u1=0) const
const IndexVector & getGridExtent() const
Get the extents of the logical grid (i.e. the size in each dimension)
void getEmptyFrames(std::vector< IndexVector > &positions) const
Fill positions vector with unoccupied logical grid positions, i.e.
boost::uint32_t getGridDimension() const
Get 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 info.
Const_TagPtr sharedTag(TagId tagId, const std::string &privateCreatorArg, Vr privateVr=UN) const
Get a const pointer to the specified shared tag with the given private creator and VR.
int frameIndexForGridPosition(const IndexVector &gridPosition) const
Get the frame index of the original image for a given grid position Returns -1 if the slice does not ...
TreePtr tagTree()
Return a pointer to the contained tag tree.
void setSharedTags(TreePtr tree, bool handleFuncGroups=true)
Add/replace 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)
ctor - gets the tree of the DICOM tags for the SMF Use this constructor to access an existing SMF obj...
Const_TagPtr tagForGridPosition(TagId tagId, IndexVector gridPosition, const std::string &privateCreatorArg, Vr privateVr=UN) const
Get a pointer to the specified tag for a given index vector or grid position.
TreePtr gridPositionTagTree(IndexVector gridPosition)
Get a pointer to a specific dimension index tree Create the tree with basic sequence structures if it...
void setTagForGridPosition(TagPtr tag, const IndexVector &gridPosition, const std::string &privateCreatorArg="", bool skipInvalidPrivateTags=true)
Add/replace specified tag for a given grid position (no copy); if skipInvalidPrivateTags is false the...
StructuredMF(TreePtr tree)
ctor - gets the tree of the DICOM tags for the SMF Use this constructor to access an existing writabl...
TagPtr sharedTag_rw(TagId tagId)
Get a writable pointer to the specified shared tag.
TreePtr extractSharedTagTree() const
Extract all DICOM tags valid for all frames (deep copy)
void setAlsoRegardEnhancedMultiFrameTags(bool flag)
void setFrameIndexForGridPosition(unsigned int frameIndex, const IndexVector &gridPosition)
Set 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
Get total number of frames.
StructuredMF(TreePtr sharedTagTree, unsigned int depth, unsigned int timePoints=0, unsigned int u1Size=0)
StructuredMF(TreePtr sharedTagTree, const IndexVector &gridExtent)
ctor - create a DICOM SMF object from the tree of common tags, the extent of the logical grid and the...
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 this class could be used as a starte...
boost::shared_ptr< const Tag > Const_TagPtr
Definition DCMTree_Lib.h:63
Vr
DICOM VR.
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:73
boost::shared_ptr< Tag > TagPtr
shared-pointer to tag
Definition DCMTree_Lib.h:62
boost::shared_ptr< Tree > TreePtr
shared pointer to a DCMTree::Tree
Definition DCMTree_Lib.h:72