ITK  4.10.0
Insight Segmentation and Registration Toolkit
itkPhilipsPAR.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
34 #ifndef itkPhilipsPAR_h
35 #define itkPhilipsPAR_h
36 #include "ITKIOPhilipsRECExport.h"
37 
38 #include <cstdio>
39 #include <cstdlib>
40 #include <string>
41 #include "itkLightProcessObject.h"
42 #include "itkVectorContainer.h"
43 #include "vnl/vnl_vector_fixed.h"
44 
45 #define RESEARCH_IMAGE_EXPORT_TOOL_V3 30
46 #define RESEARCH_IMAGE_EXPORT_TOOL_V4 40
47 #define RESEARCH_IMAGE_EXPORT_TOOL_V4_1 41
48 #define RESEARCH_IMAGE_EXPORT_TOOL_V4_2 42
49 #define RESEARCH_IMAGE_EXPORT_TOOL_UNKNOWN -1
50 
51 #define PAR_DEFAULT_STRING_LENGTH 32
52 #define PAR_DEFAULT_TRIGGER_TIMES_SIZE 128
53 #define PAR_DEFAULT_ECHO_TIMES_SIZE 128
54 #define PAR_DEFAULT_REP_TIMES_SIZE 128
55 #define PAR_DEFAULT_IMAGE_TYPES_SIZE 8
56 #define PAR_DEFAULT_SCAN_SEQUENCE_SIZE 8
57 #define PAR_RESCALE_VALUES_SIZE 3
58 #define PAR_DIFFUSION_VALUES_SIZE 3
59 
60 #define PAR_SLICE_ORIENTATION_TRANSVERSAL 1
61 #define PAR_SLICE_ORIENTATION_SAGITTAL 2
62 #define PAR_SLICE_ORIENTATION_CORONAL 3
63 
64 namespace itk
65 {
69 struct par_parameter //par_parameter
70 {
71  int problemreading; // Marked 1 if problem
72  // occurred reading in
73  // PAR file
74  int ResToolsVersion; // V3, V4, V4.1, or
75  // V4.2 PAR/REC
76  // version
77  char patient_name[PAR_DEFAULT_STRING_LENGTH]; // Patient name
78  char exam_name[PAR_DEFAULT_STRING_LENGTH]; // Examination name
79  char protocol_name[PAR_DEFAULT_STRING_LENGTH]; // Protocol name
80  char exam_date[PAR_DEFAULT_STRING_LENGTH]; // Examination
81  // date/time
82  char exam_time[PAR_DEFAULT_STRING_LENGTH]; // Examination
83  // date/time
84  char series_type[PAR_DEFAULT_STRING_LENGTH]; // Series Type
85  int scno; // Acquisition nr
86  int recno; // Reconstruction nr
87  int scan_duration; // Scan Duration [sec]
88  int cardiac_phases; // Max. number of
89  // cardiac phases
91  // (float)
92  int echoes; // Max. number of
93  // echoes
94  float echo_times[PAR_DEFAULT_ECHO_TIMES_SIZE]; // Echo times read
95  // from PAR file
96  int slice; // Max. number of
97  // slices/locations
98  int dyn; // Max. number of
99  // dynamics
100  int mixes; // Max. number of
101  // mixes
102  char patient_position[PAR_DEFAULT_STRING_LENGTH]; // Patient position
104  // direction
105  short int bit; // Image pixel size [8
106  // or 16 bits]
109  int num_averages; // Number of averages
110  int scan_resolution[2]; // Scan resolution
111  // (x, y)
112  int scan_percent; // Scan percentage
113  int dim[3]; // Recon resolution
114  // (x, y) + slices (z)
115  float repetition_time[PAR_DEFAULT_REP_TIMES_SIZE]; // Repetition time
116  // [msec]
117  int sliceorient; // slice orientation (
118  // TRA/SAG/COR )
119  // (integer)
120  float slth; // Slice thickness
121  // [mm]
122  float gap; // Slice gap [mm]
123  float fov[3]; // FOV (ap,fh,rl) [mm]
124  float water_fat_shift; // Water Fat shift
125  // [pixels]
126  float angAP; // Angulation
127  // midslice(ap,fh,rl)[degr]
128  float angFH; // Angulation
129  // midslice(ap,fh,rl)[degr]
130  float angRL; // Angulation
131  // midslice(ap,fh,rl)[degr]
132  float offAP; // Off Centre
133  // midslice(ap,fh,rl)
134  // [mm]
135  float offFH; // Off Centre
136  // midslice(ap,fh,rl)
137  // [mm]
138  float offRL; // Off Centre
139  // midslice(ap,fh,rl)
140  // [mm]
141  int flow_comp; // Flow compensation
142  // <0=no 1=yes> ?
143  int presaturation; // Presaturation
144  // <0=no 1=yes> ?
145  int cardiac_freq; // Cardiac frequency
146  int min_rr_int; // Min. RR interval
147  int max_rr_int; // Max. RR interval
148  float phase_encode_vel[3]; // Phase encoding
149  // velocity [cm/sec]
150  int mtc; // MTC
151  // <0=no
152  // 1=yes> ?
153  int spir; // SPIR
154  // <0=no
155  // 1=yes> ?
156  int epi; // EPI factor
157  // <0,1=no EPI>
158  int turbo; // TURBO factor
159  // <0=no turbo>
160  int dynamic_scan; // Dynamic scan
161  // <0=no 1=yes> ?
162  int diffusion; // Diffusion
163  // <0=no
164  // 1=yes> ?
165  float diff_echo; // Diffusion echo time
166  // [msec]
167  float inversion_delay; // Inversion delay
168  // [msec]
169  int max_num_diff_vals; // Max. number of
170  // diffusion values
171  int max_num_grad_orient; // Max. number of
172  // gradient orients
173  int num_label_types; // Number of label
174  // types <0=no ASL>
175  float vox[3]; // pixel spacing (x,y)
176  // (in mm)
177  int slicessorted; // 1-slices sorted,
178  // 0-slices not sorted
179  int image_blocks; // The total number of
180  // image blocks stored
181  // in the REC file
182  int num_image_types; // The number of image
183  // types in the REC
184  // file
185  int image_types[PAR_DEFAULT_IMAGE_TYPES_SIZE]; // The different image
186  // types
187  // detected in the REC
188  int num_scanning_sequences; // The number of
189  // scanning sequences
190  // in the REC file
192  // scanning sequences
193  // detected in the REC
195  // num_scanning_sequences
196  // > 1 then
197  // num_image_types may not equal the total number of slice
198  // repetitions for a single acquisition. This value is the
199  // total number of slice repetitions for a single acquisition
200  // and is valid only when slicessorted == 0.
201 };
203 
213 class ITKIOPhilipsREC_EXPORT PhilipsPAR:public LightProcessObject
214 {
215 public:
217  typedef PhilipsPAR Self;
220 
222  itkNewMacro(Self);
223 
225  itkTypeMacro(PhilipsPAR, Superclass);
226 
227  // Reads the PAR file parameters in "parFile" and stores the PAR parameters in
228  // pPar.
229  // Returns false if an error is encountered during reading, otherwise true is
230  // returned.
231  void ReadPAR(std::string parFile, struct par_parameter *pPar);
232 
233  // Returns a vector of paired values, the first contains the slice index and
234  // the
235  // second is the image type for the PAR file "parFile".
236  typedef std::pair< int, int > PARSliceIndexImageType;
237  typedef std::vector< PARSliceIndexImageType > PARSliceIndexImageTypeVector;
238  PARSliceIndexImageTypeVector GetRECSliceIndexImageTypes(
239  std::string parFile);
240 
241  // Returns a vector of paired values, the first contains the slice index and
242  // the
243  // second is the scan sequence for the PAR file "parFile".
244  typedef std::pair< int, int > PARSliceIndexScanSequence;
245  typedef std::vector< PARSliceIndexScanSequence > PARSliceIndexScanSequenceVector;
246  PARSliceIndexScanSequenceVector GetRECSliceIndexScanningSequence(
247  std::string parFile);
248 
249  // Returns a vector of paired values, the first contains the image type and
250  // the
251  // second is the scan sequence for that image type for the PAR file "parFile".
252  typedef std::pair< int, int > PARImageTypeScanSequence;
253  typedef std::vector< PARImageTypeScanSequence > PARImageTypeScanSequenceVector;
254  PARImageTypeScanSequenceVector GetImageTypesScanningSequence(
255  std::string parFile);
256 
257  // Stores rescale values in the VectorContainer "rescaleValues" for each image
258  // type of the specified scan sequence number "scan_sequence" (from
259  // scanning_sequences) for the PAR file "parFile".
260  // Returns false if an error is encountered during reading, otherwise true is
261  // returned.
262  typedef vnl_vector_fixed< double, PAR_RESCALE_VALUES_SIZE >
266  bool GetRECRescaleValues(std::string parFile,
267  PARRescaleValuesContainer *rescaleValues, int scan_sequence);
268 
269  // Stores the diffusion gradient values in the VectorContainer
270  // "gradientValues"
271  // and the diffusion b values in the VectorContainer "bValues" for each
272  // gradient
273  // direction in the PAR file "parFile". This function is applicable only for
274  // PAR
275  // versions > 4.1
276  // Returns false if an error is encountered during reading, otherwise true is
277  // returned.
278  typedef vnl_vector_fixed< double, PAR_DIFFUSION_VALUES_SIZE >
284  bool GetDiffusionGradientOrientationAndBValues(std::string parFile,
285  PARDiffusionValuesContainer *gradientValues,
286  PARBValuesContainer *bValues);
287 
288  // Returns a vector of ASL label types for the PAR file "parFile".
290  bool GetLabelTypesASL(std::string parFile,
291  PARLabelTypesASLContainer *labelTypes);
292 
293  // Read a line number within the PAR file.
294  std::string GetLineNumber(std::string file, int lineNum);
295 
296 protected:
297  PhilipsPAR();
298  ~PhilipsPAR();
299  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
300 
301 private:
302  PhilipsPAR(const Self &) ITK_DELETE_FUNCTION;
303  void operator=(const Self &) ITK_DELETE_FUNCTION;
304 
306  int GetPARVersion(std::string parFile);
307 
309  std::string GetGeneralInfoString(std::string file, int lineNum);
310 
312  std::string m_FileName;
313 
315  std::vector< std::string > m_PARFileLines;
316 };
317 } // end namespace itk
318 
319 #endif /* itkPhilipsPAR_h */
float repetition_time[PAR_DEFAULT_REP_TIMES_SIZE]
PhilipsPAR Self
#define PAR_DEFAULT_REP_TIMES_SIZE
Definition: itkPhilipsPAR.h:54
char exam_date[PAR_DEFAULT_STRING_LENGTH]
Definition: itkPhilipsPAR.h:80
#define PAR_DEFAULT_ECHO_TIMES_SIZE
Definition: itkPhilipsPAR.h:53
char technique[PAR_DEFAULT_STRING_LENGTH]
LightProcessObject Superclass
#define PAR_DEFAULT_IMAGE_TYPES_SIZE
Definition: itkPhilipsPAR.h:55
std::vector< PARImageTypeScanSequence > PARImageTypeScanSequenceVector
char scan_mode[PAR_DEFAULT_STRING_LENGTH]
STL namespace.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes...
Definition: itkArray.h:30
float trigger_times[PAR_DEFAULT_TRIGGER_TIMES_SIZE]
Definition: itkPhilipsPAR.h:90
std::pair< int, int > PARSliceIndexImageType
int image_types[PAR_DEFAULT_IMAGE_TYPES_SIZE]
vnl_vector_fixed< double, PAR_RESCALE_VALUES_SIZE > PARRescaleValues
float phase_encode_vel[3]
char exam_time[PAR_DEFAULT_STRING_LENGTH]
Definition: itkPhilipsPAR.h:82
SmartPointer< Self > Pointer
Read parameters from a Philips PAR file.
std::pair< int, int > PARImageTypeScanSequence
float echo_times[PAR_DEFAULT_ECHO_TIMES_SIZE]
Definition: itkPhilipsPAR.h:94
char exam_name[PAR_DEFAULT_STRING_LENGTH]
Definition: itkPhilipsPAR.h:78
VectorContainer< unsigned int, PARRescaleValues > PARRescaleValuesContainer
char patient_position[PAR_DEFAULT_STRING_LENGTH]
vnl_vector_fixed< double, PAR_DIFFUSION_VALUES_SIZE > PARDiffusionValues
char prep_direction[PAR_DEFAULT_STRING_LENGTH]
char protocol_name[PAR_DEFAULT_STRING_LENGTH]
Definition: itkPhilipsPAR.h:79
#define PAR_DEFAULT_SCAN_SEQUENCE_SIZE
Definition: itkPhilipsPAR.h:56
VectorContainer< unsigned int, double > PARBValuesContainer
std::vector< PARSliceIndexImageType > PARSliceIndexImageTypeVector
std::vector< PARSliceIndexScanSequence > PARSliceIndexScanSequenceVector
std::pair< int, int > PARSliceIndexScanSequence
#define PAR_DEFAULT_TRIGGER_TIMES_SIZE
Definition: itkPhilipsPAR.h:52
char series_type[PAR_DEFAULT_STRING_LENGTH]
Definition: itkPhilipsPAR.h:84
char patient_name[PAR_DEFAULT_STRING_LENGTH]
Definition: itkPhilipsPAR.h:77
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
LightProcessObject is the base class for all process objects (source, filters, mappers) in the Insigh...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
VectorContainer< unsigned int, PARDiffusionValues > PARDiffusionValuesContainer
VectorContainer< unsigned int, int > PARLabelTypesASLContainer
#define PAR_DEFAULT_STRING_LENGTH
Definition: itkPhilipsPAR.h:51
int scanning_sequences[PAR_DEFAULT_SCAN_SEQUENCE_SIZE]