MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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:
53 typedef std::vector<unsigned int> IndexVector;
54
56 static std::string privateCreator; /* = "MeVis StructuredMF data" */
57
58 // Private group and element ID constants used for storing the StructuredMF information
59 enum {
60 privateGroupId = 0x0041,
61
62 dimensionsOffset = 1,
63 dimensionSequenceOffset = 2,
64 frameIndexOffset = 3
65 };
66
67
73
78
83 StructuredMF(TreePtr sharedTagTree, unsigned int depth, unsigned int timePoints = 0, unsigned int u1Size = 0);
84
85
90
91
93
100 Const_TagPtr sharedTag(TagId tagId, const std::string& privateCreatorArg, Vr privateVr = UN) const;
101
105
108
109
111
115 Const_TagPtr tagForGridPosition(TagId tagId, unsigned int z, unsigned int t = 0, unsigned int u1 = 0) const;
116
121 Vr privateVr = UN) const;
122 Const_TagPtr tagForGridPosition(TagId tagId, const std::string& privateCreatorArg, Vr privateVr, unsigned int z,
123 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 bool skipInvalidPrivateTags = true);
149 void setTagForGridPosition(TagPtr tag, unsigned int z, unsigned int t = 0, unsigned int u1 = 0,
150 const std::string& privateCreatorArg = "");
151
157 void setGridPositionSpecificTags(TreePtr tree, unsigned int z, unsigned int t = 0, unsigned int u1 = 0);
158
162 void setFrameIndexForGridPosition(unsigned int frameIndex, unsigned int z, unsigned int t = 0, unsigned int u1 = 0);
164
165
168
171 OK = 0,
173 AMBIGUOUS_TAG,
176
177 NUM_STATUS_CODES
178 };
179
184 void normalizeTagStructure(double tolerance = 0.0, bool compress = true);
186
187
190
198 boost::uint32_t getGridDimension() const;
199
202
204 unsigned int getNumberOfFrames() const;
205
207 bool frameExists(const IndexVector& position) const;
208
211 void getEmptyFrames(std::vector<IndexVector>& positions) const;
212
218
219
225 {
226 _alsoRegardEnhancedMultiFrameTags = flag;
227 }
229 {
230 return _alsoRegardEnhancedMultiFrameTags;
231 }
232
234 bool privateTagsAreSet() const;
236
237 private:
239 bool initPrivateTagIds(bool newOrExisting);
241 void clearPrivateTags();
243 void createPrivateCreatorTag();
245 bool isPrivateTagId(const TagId& tagId) const;
247 bool isSingleSlice() const;
249 TagInfo dimensionsTagInfo();
252 TagInfo dimensionGroupTagInfo();
254 TagInfo frameIndexTagInfo();
256 TagInfo defaultCreatorTagInfo();
259 void normalizeTagStructure(std::vector<TreePtr> dimTrees, double tolerance, bool compress);
261 Const_TreePtr gridPositionTagTree(IndexVector gridPosition) const;
263 void createDimensionSubtree(TagPtr parentSeq, int index);
265 void setDimensionsTag();
267 Const_TagPtr dimensionSequence() const;
268
270 IndexVector indexVectorFromIndexes(unsigned int z, unsigned int t, unsigned int u1) const;
272 TreePtr getGridItemOrSharedTree(const IndexVector& gridPosition);
273
278 bool checkGridPosition(const IndexVector& gridPosition) const;
279
282 Const_TagPtr searchForTagInFunctionalGroups(Const_TagPtr functionalGroupTag, TagId tagId,
283 unsigned int itemIndex = 0) const;
284
286 TreePtr _treePtr;
288 Const_TreePtr _constTreePtr;
290 IndexVector _gridExtent;
291
293 TagId _creatorId, _privateBaseId, _dimensionsId, _dimensionSequenceId, _frameIndexId;
294
296 bool _alsoRegardEnhancedMultiFrameTags{};
297 };
298} // namespace DCMTree
299
300#ifdef _MSC_VER
301#pragma warning(pop)
302#endif
303
304#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:58
Vr
DICOM VR.
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:68
boost::shared_ptr< Tag > TagPtr
Shared pointer to tag.
Definition DCMTree_Lib.h:57
boost::shared_ptr< Tree > TreePtr
Shared pointer to a DCMTree::Tree.
Definition DCMTree_Lib.h:67