ISMRMRD
ISMRM Raw Data Format
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups
xml.h
Go to the documentation of this file.
1 
7 #ifndef ISMRMRDXML_H
8 #define ISMRMRDXML_H
9 
10 #include "ismrmrd/export.h"
11 
12 #include <cstddef>
13 #include <new> //For std::badalloc
14 #include <stdexcept> //For std::length_error
15 #include <stdio.h>
16 #include <string.h>
17 #include <iostream>
18 #include <string>
19 #include <vector>
20 
30 namespace ISMRMRD
31 {
32 
33  template <typename T> class Optional
34  {
35  public:
36  Optional()
37  : present_(false)
38  {
39 
40  }
41 
42  Optional(const T&v) {
43  present_ = true;
44  value_ = v;
45  }
46 
47  const Optional& operator=(const T& v) {
48  present_ = true;
49  value_ = v;
50  return *this;
51  }
52 
53  const T* operator->() const {
54  return &value_;
55  }
56 
57  const T& operator*() const {
58  return value_;
59  }
60 
61  operator bool() const {
62  return present_;
63  }
64 
65  bool is_present() const {
66  return present_;
67  }
68 
69  T& get() {
70  if (!present_) {
71  throw std::runtime_error("Access optional value, which has not been set");
72  }
73  return value_;
74  }
75 
76  T& operator()() {
77  return get();
78  }
79 
80  void set(const T& v) {
81  present_ = true;
82  value_ = v;
83  }
84 
85  protected:
86  bool present_;
87  T value_;
88 
89  };
90 
92  {
93  Optional<std::string> patientName;
94  Optional<float> patientWeight_kg;
95  Optional<std::string> patientID;
96  Optional<std::string> patientBirthdate;
97  Optional<std::string> patientGender;
98  };
99 
101  {
102  Optional<std::string> studyDate;
103  Optional<std::string> studyTime;
104  Optional<std::string> studyID;
105  Optional<long> accessionNumber;
106  Optional<std::string> referringPhysicianName;
107  Optional<std::string> studyDescription;
108  Optional<std::string> studyInstanceUID;
109  };
110 
112  {
113  std::string dependencyType;
114  std::string measurementID;
115  };
116 
118  {
119  std::string referencedSOPInstanceUID;
120  };
121 
123  {
124  Optional<std::string> measurementID;
125  Optional<std::string> seriesDate;
126  Optional<std::string> seriesTime;
127  std::string patientPosition;
128  Optional<long int> initialSeriesNumber;
129  Optional<std::string> protocolName;
130  Optional<std::string> seriesDescription;
131  std::vector<MeasurementDependency> measurementDependency;
132  Optional<std::string> seriesInstanceUIDRoot;
133  Optional<std::string> frameOfReferenceUID;
134  std::vector<ReferencedImageSequence> referencedImageSequence;
135  };
136 
137  struct CoilLabel
138  {
139  unsigned short coilNumber;
140  std::string coilName;
141  };
142 
144  {
145  Optional<std::string> systemVendor;
146  Optional<std::string> systemModel;
147  Optional<float> systemFieldStrength_T;
148  Optional<float> relativeReceiverNoiseBandwidth;
149  Optional<unsigned short> receiverChannels;
150  std::vector<CoilLabel> coilLabel;
151  Optional<std::string> institutionName;
152  Optional<std::string> stationName;
153  };
154 
155 
157  {
158  long int H1resonanceFrequency_Hz;
159  };
160 
161  struct MatrixSize
162  {
163  MatrixSize()
164  : x(1)
165  , y(1)
166  , z(1)
167  {
168 
169  }
170 
171  MatrixSize(unsigned short x, unsigned short y)
172  : x(x)
173  , y(y)
174  , z(1)
175  {
176 
177  }
178 
179  MatrixSize(unsigned short x, unsigned short y, unsigned short z)
180  : x(x)
181  , y(y)
182  , z(z)
183  {
184 
185  }
186 
187  unsigned short x;
188  unsigned short y;
189  unsigned short z;
190  };
191 
193  {
194  float x;
195  float y;
196  float z;
197  };
198 
200  {
201  MatrixSize matrixSize;
202  FieldOfView_mm fieldOfView_mm;
203  };
204 
205 
206  struct Limit
207  {
208  Limit()
209  : minimum(0)
210  , maximum(0)
211  , center(0)
212  {
213 
214  }
215 
216  Limit(unsigned short minimum, unsigned short maximum, unsigned short center)
217  : minimum(minimum)
218  , maximum(maximum)
219  , center(center)
220  {
221 
222  }
223 
224  unsigned short minimum;
225  unsigned short maximum;
226  unsigned short center;
227  };
228 
230  {
231  Optional<Limit> kspace_encoding_step_0;
232  Optional<Limit> kspace_encoding_step_1;
233  Optional<Limit> kspace_encoding_step_2;
234  Optional<Limit> average;
235  Optional<Limit> slice;
236  Optional<Limit> contrast;
237  Optional<Limit> phase;
238  Optional<Limit> repetition;
239  Optional<Limit> set;
240  Optional<Limit> segment;
241  };
242 
243 
245  {
246  std::string name;
247  long value;
248  };
249 
251  {
252  std::string name;
253  double value;
254  };
255 
257 
258  {
259  std::string name;
260  std::string value;
261  };
262 
264  {
265  std::vector<UserParameterLong> userParameterLong;
266  std::vector<UserParameterDouble> userParameterDouble;
267  std::vector<UserParameterString> userParameterString;
268  std::vector<UserParameterString> userParameterBase64;
269  };
270 
272  {
273  std::string identifier;
274  std::vector<UserParameterLong> userParameterLong;
275  std::vector<UserParameterDouble> userParameterDouble;
276  Optional<std::string> comment;
277  };
278 
280  {
281  unsigned short kspace_encoding_step_1;
282  unsigned short kspace_encoding_step_2;
283  };
284 
286  {
287  AccelerationFactor accelerationFactor;
288  Optional<std::string> calibrationMode;
289  Optional<std::string> interleavingDimension;
290  };
291 
292  struct Encoding
293  {
294  EncodingSpace encodedSpace;
295  EncodingSpace reconSpace;
296  EncodingLimits encodingLimits;
297  std::string trajectory;
298  Optional<TrajectoryDescription> trajectoryDescription;
299  Optional<ParallelImaging> parallelImaging;
300  Optional<long> echoTrainLength;
301  };
302 
304  {
308  Optional<std::vector<float> > flipAngle_deg;
309  Optional<std::string> sequence_type;
310  Optional<std::vector<float> > echo_spacing;
311  };
312 
314  {
315  Optional<long> version;
316  Optional<SubjectInformation> subjectInformation;
317  Optional<StudyInformation> studyInformation;
318  Optional<MeasurementInformation> measurementInformation;
319  Optional<AcquisitionSystemInformation> acquisitionSystemInformation;
320  ExperimentalConditions experimentalConditions;
321  std::vector<Encoding> encoding;
322  Optional<SequenceParameters> sequenceParameters;
323  Optional<UserParameters> userParameters;
324  };
325 
326 
327 
328  EXPORTISMRMRD void deserialize(const char* xml, IsmrmrdHeader& h);
329  EXPORTISMRMRD void serialize(const IsmrmrdHeader& h, std::ostream& o);
330 }
331 
333 #endif //ISMRMRDXML_H
Definition: xml.h:285
Definition: xml.h:161
Definition: xml.h:122
Definition: xml.h:206
Definition: xml.h:279
Definition: xml.h:263
Definition: xml.h:100
Definition: xml.h:292
Definition: xml.h:156
Definition: xml.h:313
Definition: xml.h:271
Definition: xml.h:256
Definition: xml.h:229
Definition: xml.h:250
Definition: xml.h:303
Definition: xml.h:111
Definition: xml.h:33
Definition: xml.h:244
Definition: xml.h:192
Definition: xml.h:137
Definition: xml.h:199
Definition: xml.h:91