creaImageIO_lib
creaImageIO::tree::Descriptor Class Reference

Descriptor of the structure of a Tree (number of levels, descriptors of each level, ...). More...

#include <creaImageIOTreeDescriptor.h>

Public Types

typedef std::vector
< LevelDescriptor
LevelDescriptorListType
 The type of LevelDescriptor container. More...
 

Public Member Functions

 Descriptor ()
 Ctor : creates the mandatory level 0 descriptor called "Root". More...
 
 ~Descriptor ()
 Destructor. More...
 
void LoadXML (const std::string &filename)
 Loads from a xml description file. More...
 
void CreateDefault ()
 Creates the default descriptor. More...
 
unsigned int GetNumberOfLevels ()
 Returns the number of levels of the tree. More...
 
const LevelDescriptorGetLevelDescriptor (int level) const
 Returns the LevelDescriptor of a given level (const ref) More...
 
const
LevelDescriptor::AttributeDescriptorListType
GetAttributeDescriptorList (int level, int type=0) const
 type = 1 without ID and PATIENT_ID More...
 
void CopyAttributeDescriptorList (int level)
 Copy the AttributeDescriptorList without ID tag. More...
 
void Add (const LevelDescriptor &)
 Adds a LevelDescriptor at the end of the list. More...
 
void Add (const AttributeDescriptor &, int l)
 Adds an AttributeDescriptor to level l. More...
 
void BuildAttributeMap (AttributeMapType &) const
 Builds the key to value map of all the attributes of the tree. More...
 
const LevelDescriptorListTypeGetLevelDescriptorList () const
 Returns the list of tree levels (const) More...
 
void Clear ()
 Clears the Descriptor. More...
 
void createDescriptorfromFile (const std::string &i_file)
 
const std::string isExist (const std::string i_attr)
 

Private Member Functions

void CreateLevel0Descriptor ()
 

Private Attributes

LevelDescriptorListType mLevelDescriptorList
 

Detailed Description

Descriptor of the structure of a Tree (number of levels, descriptors of each level, ...).

Definition at line 49 of file creaImageIOTreeDescriptor.h.

Member Typedef Documentation

The type of LevelDescriptor container.

Definition at line 95 of file creaImageIOTreeDescriptor.h.

Constructor & Destructor Documentation

creaImageIO::tree::Descriptor::Descriptor ( )

Ctor : creates the mandatory level 0 descriptor called "Root".

Definition at line 57 of file creaImageIOTreeDescriptor.cpp.

References CreateLevel0Descriptor().

58  {
60  }

Here is the call graph for this function:

creaImageIO::tree::Descriptor::~Descriptor ( )

Destructor.

Definition at line 64 of file creaImageIOTreeDescriptor.cpp.

65  {
66  }

Member Function Documentation

void creaImageIO::tree::Descriptor::Add ( const LevelDescriptor d)

Adds a LevelDescriptor at the end of the list.

Definition at line 260 of file creaImageIOTreeDescriptor.cpp.

References mLevelDescriptorList.

Referenced by CreateDefault(), createDescriptorfromFile(), CreateLevel0Descriptor(), creaImageIO::SQLiteTreeHandler::DBCreate(), and creaImageIO::SQLiteTreeHandler::DBImportTreeDescription().

261  {
262  mLevelDescriptorList.push_back(d);
263  }

Here is the caller graph for this function:

void creaImageIO::tree::Descriptor::Add ( const AttributeDescriptor d,
int  l 
)

Adds an AttributeDescriptor to level l.

Definition at line 268 of file creaImageIOTreeDescriptor.cpp.

References mLevelDescriptorList.

269  {
270  mLevelDescriptorList[l].Add(d);
271  // TO DO : update DicomTagToName and NameToDicomTag map
272  }
void creaImageIO::tree::Descriptor::BuildAttributeMap ( AttributeMapType map) const

Builds the key to value map of all the attributes of the tree.

Definition at line 286 of file creaImageIOTreeDescriptor.cpp.

References GetLevelDescriptorList().

Referenced by creaImageIO::TreeHandlerImageAdder::AddFile(), creaImageIO::Synchronizer::AttributesMatch(), and creaImageIO::TreeHandlerImageAdder::CheckAttributes().

287  {
288  map.clear();
289  LevelDescriptorListType::const_iterator l;
290  for (l = GetLevelDescriptorList().begin();
291  l!= GetLevelDescriptorList().end();
292  ++l)
293  {
294  LevelDescriptor::AttributeDescriptorListType::const_iterator a;
295  for (a = l->GetAttributeDescriptorList().begin();
296  a!= l->GetAttributeDescriptorList().end();
297  ++a)
298  {
299  map[a->GetKey()]="";
300  }
301  }
302  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::tree::Descriptor::Clear ( )

Clears the Descriptor.

Definition at line 277 of file creaImageIOTreeDescriptor.cpp.

References mLevelDescriptorList.

Referenced by CreateDefault(), createDescriptorfromFile(), and creaImageIO::SQLiteTreeHandler::DBImportTreeDescription().

278  {
279  mLevelDescriptorList.clear();
280  }

Here is the caller graph for this function:

void creaImageIO::tree::Descriptor::CopyAttributeDescriptorList ( int  level)
inline

Copy the AttributeDescriptorList without ID tag.

Definition at line 79 of file creaImageIOTreeDescriptor.h.

Referenced by creaImageIO::tree::Tree::CopyAttributeDescriptorList().

80  {
81  mLevelDescriptorList[level].CopyAttributeDescriptorList();
82  }

Here is the caller graph for this function:

void creaImageIO::tree::Descriptor::CreateDefault ( )

Creates the default descriptor.

Definition at line 78 of file creaImageIOTreeDescriptor.cpp.

References Add(), Clear(), CreateLevel0Descriptor(), creaImageIO::tree::AttributeDescriptor::IDENTIFIER, and creaImageIO::tree::AttributeDescriptor::LABEL.

79  {
80  // clears the existing one
81  Clear();
82 
83  // Creates the level 0 descriptor
85  // Creates the attribute "Name"
86  Add(AttributeDescriptor("Name","Name",
88 
89  // Patient level
90  Add(LevelDescriptor("Patient"));
91  Add(AttributeDescriptor("NumberOfChildren","#Series",0),1); // Number of Series
92  Add(AttributeDescriptor(0x0010,0x0010, // Patient name
94  Add(AttributeDescriptor(0x0010,0x0040),1); // Patient sex
95  Add(AttributeDescriptor(0x0010,0x0030),1); // Patient birthday
96  Add(AttributeDescriptor(0x0010,0x0020, // Patient ID
98 
99  // Study-series level
100  Add(LevelDescriptor("Series"));
101  Add(AttributeDescriptor("NumberOfChildren","#Images",0),2); // Number of images
102  Add(AttributeDescriptor(0x0008,0x0060, // Modality
104  Add(AttributeDescriptor(0x0008,0x1030),2); // Study Description
105  Add(AttributeDescriptor(0x0008,0x103E),2); // Description
106  Add(AttributeDescriptor(0x0008,0x0080),2); // Institution Name
107  Add(AttributeDescriptor(0x0008,0x0081),2); // Institution Adress
108  Add(AttributeDescriptor(0x0008,0x1010),2); // Station Name
109  Add(AttributeDescriptor(0x0008,0x1048),2); // Physician of Record
110  Add(AttributeDescriptor(0x0008,0x1050),2); // Performing Physician's Name
111  Add(AttributeDescriptor(0x0018,0x1030),2); // Protocol Name
112 
113  Add(AttributeDescriptor(0x0020,0x0010),2); // Study ID
114  Add(AttributeDescriptor(0x0008,0x0020),2); // Study Date
115  Add(AttributeDescriptor(0x0008,0x0030),2); // Study Time
116  Add(AttributeDescriptor(0x0008,0x0050),2); // Study Accession Number
117  Add(AttributeDescriptor(0x0008,0x0005),2); // Specific character set
118  Add(AttributeDescriptor(0x0008,0x0021),2); // Series Date
119  Add(AttributeDescriptor(0x0008,0x0031),2); // Series time
120 
121  Add(AttributeDescriptor(0x0020,0x000D // Study Instance UID
122  ),2);//AttributeDescriptor::IDENTIFIER),2);
123  Add(AttributeDescriptor(0x0020,0x000E, // Series Instance UID
125  // |
126  // AttributeDescriptor::LABEL),2);
127 
128 
129  // Image level
130  Add(LevelDescriptor("Image"));
131 
132  Add(AttributeDescriptor(0x0020,0x0013),3); // Image Number
133 
134  Add(AttributeDescriptor(0x0028,0x0010),3); // Rows
135  Add(AttributeDescriptor(0x0028,0x0011),3); // Columns
136  Add(AttributeDescriptor(0x0028,0x0012),3); // Planes
137  Add(AttributeDescriptor(0x0028,0x0002),3); // Sample per pixels
138  Add(AttributeDescriptor(0x0028,0x0008),3); // Number of Frames
139  Add(AttributeDescriptor(0x0028,0x0004),3); // Photometric Interpretation
140  Add(AttributeDescriptor(0x0028,0x0103),3); // Pixel Representation
141 
142  Add(AttributeDescriptor(0x0020,0x0032),3); // Image Position Patient
143  Add(AttributeDescriptor(0x0020,0x0037),3); // Image Orientation Patient
144  Add(AttributeDescriptor(0x0020,0x1041),3); // Slice Location
145  Add(AttributeDescriptor(0x0028,0x0006),3); // Planar Configuration
146 
147  Add(AttributeDescriptor(0x0028,0x0030),3); // Pixel Spacing
148  Add(AttributeDescriptor(0x0028,0x0100),3); // AlocatedBits
149  Add(AttributeDescriptor(0x0028,0x0101),3); // StoredBits
150 
151  Add(AttributeDescriptor(0x0008,0x0008),3); // Image Type
152  Add(AttributeDescriptor(0x0008,0x0023),3); // Content Date
153  Add(AttributeDescriptor(0x0008,0x0033),3); // Content Time
154 
155  Add(AttributeDescriptor(0x0020,0x4000),3); // Image Comments
156 
157  Add(AttributeDescriptor(0x0004,0x1500, // File Name
159  Add(AttributeDescriptor(0x0028,0x1052),3); // Rescale Intercept
160  Add(AttributeDescriptor(0x0028,0x1053),3); // Rescale Slope
161 
162  Add(AttributeDescriptor(0x0050,0x0004),3); // Calibration Image
163 
164  Add(AttributeDescriptor(0x0020,0x0052 // Frame Reference UID
165  ),3);
166  Add(AttributeDescriptor(0x0008,0x0016),3); // SOP Class UID
167  Add(AttributeDescriptor("FullFileName", // Full file name
168  "Full file name",
170 
171  }

Here is the call graph for this function:

void creaImageIO::tree::Descriptor::createDescriptorfromFile ( const std::string &  i_file)

Definition at line 178 of file creaImageIOTreeDescriptor.cpp.

References Add(), and Clear().

Referenced by creaImageIO::Gimmick::createDB().

179  {
180  Clear();
181 
182  // read file and put in buffer
183  std::ifstream i_file(i_name.c_str());
184  std::stringstream buffer;
185  buffer << i_file.rdbuf();
186  std::string line;
187  bool bname;
188  int ilevel = -1;
189 
190 
191  while(std::getline(buffer, line))
192  {
193  if(line =="<level>")
194  { //increment levels.
195  ilevel++;
196  bname = true;
197  }
198  else if(bname)
199  {
200  // For each level, a name to describe it
201  Add(LevelDescriptor(line));
202  bname = false;
203  }
204  else if(line.empty()) // to avoid end line
205  {
206  return;
207  }
208  else
209  {
210  // split line to find all tags
211  std::vector<std::string> descriptors;
212  std::string separator = " ";
213  std::string::size_type last_pos = line.find_first_not_of(separator);
214  //find first separator
215  std::string::size_type pos = line.find_first_of(separator, last_pos);
216  while(std::string::npos != pos || std::string::npos != last_pos)
217  {
218  descriptors.push_back(line.substr(last_pos, pos - last_pos));
219  last_pos = line.find_first_not_of(separator, pos);
220  pos = line.find_first_of(separator, last_pos);
221  }
222 
223  // By default, the last tag is at zero and not recorded but if take in count
224  unsigned int flag = 0;
225  if(descriptors.size() == 4)
226  {
227  std::stringstream val;
228  val << std::dec << descriptors[3];
229  val>> flag;
230  }
231 
232  // if Dicom tag, use "group" and "element" descriptor
233  if(descriptors[0] == "D")
234  { std::stringstream val, val2;
235  unsigned short group;
236  unsigned short element;
237  val << std::dec << descriptors[1] ;
238  val >> std::hex >> group;
239  val2 << std::dec << descriptors[2];
240  val2 >> std::hex >> element;
241  Add(AttributeDescriptor( group,element,flag), ilevel);
242  }
243 
244  else if(descriptors[0].find("#") != -1)
245  {
246  // commented line continue to next line
247  }
248  else
249  { boost::algorithm::replace_all(descriptors[2],"_"," ");
250  Add(AttributeDescriptor( descriptors[1].c_str(),descriptors[2].c_str(),flag), ilevel);
251  }
252  }
253  }
254  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::tree::Descriptor::CreateLevel0Descriptor ( )
private

Creates the mandatory level 0 descriptor called "Root" (assumes the list is empty)

Definition at line 70 of file creaImageIOTreeDescriptor.cpp.

References Add().

Referenced by CreateDefault(), and Descriptor().

71  {
72  Add(LevelDescriptor("Root"));
73  }

Here is the call graph for this function:

Here is the caller graph for this function:

const LevelDescriptor::AttributeDescriptorListType& creaImageIO::tree::Descriptor::GetAttributeDescriptorList ( int  level,
int  type = 0 
) const
inline

type = 1 without ID and PATIENT_ID

Returns the AttributeDescriptorList of a given level (const ref) type = 0 all attributes

Definition at line 74 of file creaImageIOTreeDescriptor.h.

References creaImageIO::tree::LevelDescriptor::GetAttributeDescriptorList().

Referenced by creaImageIO::tree::Tree::GetAttributeDescriptorList().

75  { return mLevelDescriptorList[level].GetAttributeDescriptorList(type); }

Here is the call graph for this function:

Here is the caller graph for this function:

const LevelDescriptor& creaImageIO::tree::Descriptor::GetLevelDescriptor ( int  level) const
inline

Returns the LevelDescriptor of a given level (const ref)

Definition at line 67 of file creaImageIOTreeDescriptor.h.

Referenced by creaImageIO::tree::Tree::GetLevelDescriptor().

68  { return mLevelDescriptorList[level]; }

Here is the caller graph for this function:

const LevelDescriptorListType& creaImageIO::tree::Descriptor::GetLevelDescriptorList ( ) const
inline

Returns the list of tree levels (const)

Definition at line 98 of file creaImageIOTreeDescriptor.h.

Referenced by BuildAttributeMap(), and isExist().

98 { return mLevelDescriptorList; }

Here is the caller graph for this function:

unsigned int creaImageIO::tree::Descriptor::GetNumberOfLevels ( )
inline

Returns the number of levels of the tree.

Definition at line 63 of file creaImageIOTreeDescriptor.h.

Referenced by creaImageIO::tree::Tree::GetNumberOfLevels().

64  { return (int)mLevelDescriptorList.size(); }

Here is the caller graph for this function:

const std::string creaImageIO::tree::Descriptor::isExist ( const std::string  i_attr)

test if an attribute is present in DescriptionList return level's name

Definition at line 308 of file creaImageIOTreeDescriptor.cpp.

References GetLevelDescriptorList().

Referenced by creaImageIO::tree::Tree::isAttributeExist().

309  {
310  std::string name = "";
311  LevelDescriptorListType::const_iterator l = GetLevelDescriptorList().begin();
312  for (; l!= GetLevelDescriptorList().end(); ++l)
313  {
314  LevelDescriptor::AttributeDescriptorListType::const_iterator a = l->GetAttributeDescriptorList().begin();
315  for(;a!= l->GetAttributeDescriptorList().end(); ++a)
316  {
317  if (a->GetKey() == i_attr)
318  {
319  name = l->GetName();
320  break;
321  }
322  }
323  }
324  return name.c_str();
325  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::tree::Descriptor::LoadXML ( const std::string &  filename)

Loads from a xml description file.

Member Data Documentation

LevelDescriptorListType creaImageIO::tree::Descriptor::mLevelDescriptorList
private

Definition at line 112 of file creaImageIOTreeDescriptor.h.

Referenced by Add(), and Clear().


The documentation for this class was generated from the following files: