00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00033 #ifndef __itkPhilipsPAR_h
00034 #define __itkPhilipsPAR_h
00035
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <string>
00039 #include "itkLightProcessObject.h"
00040 #include "itkVectorContainer.h"
00041 #include "vnl/vnl_vector_fixed.h"
00042
00043 #define RESEARCH_IMAGE_EXPORT_TOOL_V3 30
00044 #define RESEARCH_IMAGE_EXPORT_TOOL_V4 40
00045 #define RESEARCH_IMAGE_EXPORT_TOOL_V4_1 41
00046 #define RESEARCH_IMAGE_EXPORT_TOOL_V4_2 42
00047 #define RESEARCH_IMAGE_EXPORT_TOOL_UNKNOWN -1
00048
00049 #define PAR_DEFAULT_STRING_LENGTH 32
00050 #define PAR_DEFAULT_TRIGGER_TIMES_SIZE 128
00051 #define PAR_DEFAULT_ECHO_TIMES_SIZE 128
00052 #define PAR_DEFAULT_REP_TIMES_SIZE 128
00053 #define PAR_DEFAULT_IMAGE_TYPES_SIZE 8
00054 #define PAR_DEFAULT_SCAN_SEQUENCE_SIZE 8
00055 #define PAR_RESCALE_VALUES_SIZE 3
00056 #define PAR_DIFFUSION_VALUES_SIZE 3
00057
00058 #define PAR_SLICE_ORIENTATION_TRANSVERSAL 1
00059 #define PAR_SLICE_ORIENTATION_SAGITTAL 2
00060 #define PAR_SLICE_ORIENTATION_CORONAL 3
00061
00062 namespace itk
00063 {
00064
00068 struct par_parameter
00069 {
00070 int problemreading;
00071 int ResToolsVersion;
00072 char patient_name[PAR_DEFAULT_STRING_LENGTH];
00073 char exam_name[PAR_DEFAULT_STRING_LENGTH];
00074 char protocol_name[PAR_DEFAULT_STRING_LENGTH];
00075 char exam_date[PAR_DEFAULT_STRING_LENGTH];
00076 char exam_time[PAR_DEFAULT_STRING_LENGTH];
00077 char series_type[PAR_DEFAULT_STRING_LENGTH];
00078 int scno;
00079 int recno;
00080 int scan_duration;
00081 int cardiac_phases;
00082 float trigger_times[PAR_DEFAULT_TRIGGER_TIMES_SIZE];
00083 int echoes;
00084 float echo_times[PAR_DEFAULT_ECHO_TIMES_SIZE];
00085 int slice;
00086 int dyn;
00087 int mixes;
00088 char patient_position[PAR_DEFAULT_STRING_LENGTH];
00089 char prep_direction[PAR_DEFAULT_STRING_LENGTH];
00090 short int bit;
00091 char technique[PAR_DEFAULT_STRING_LENGTH];
00092 char scan_mode[PAR_DEFAULT_STRING_LENGTH];
00093 int num_averages;
00094 int scan_resolution[2];
00095 int scan_percent;
00096 int dim[3];
00097 float repetition_time[PAR_DEFAULT_REP_TIMES_SIZE];
00098 int sliceorient;
00099 float slth;
00100 float gap;
00101 float fov[3];
00102 float water_fat_shift;
00103 float angAP;
00104 float angFH;
00105 float angRL;
00106 float offAP;
00107 float offFH;
00108 float offRL;
00109 int flow_comp;
00110 int presaturation;
00111 int cardiac_freq;
00112 int min_rr_int;
00113 int max_rr_int;
00114 float phase_encode_vel[3];
00115 int mtc;
00116 int spir;
00117 int epi;
00118 int turbo;
00119 int dynamic_scan;
00120 int diffusion;
00121 float diff_echo;
00122 float inversion_delay;
00123 int max_num_diff_vals;
00124 int max_num_grad_orient;
00125 int num_label_types;
00126 float vox[3];
00127 int slicessorted;
00128 int image_blocks;
00129 int num_image_types;
00130 int image_types[PAR_DEFAULT_IMAGE_TYPES_SIZE];
00131
00132 int num_scanning_sequences;
00133 int scanning_sequences[PAR_DEFAULT_SCAN_SEQUENCE_SIZE];
00134
00135
00136 int num_slice_repetitions;
00137
00138
00139
00140
00142
00143 };
00144
00153 class ITK_EXPORT PhilipsPAR : public LightProcessObject
00154 {
00155 public:
00157 typedef PhilipsPAR Self;
00158 typedef LightProcessObject Superclass;
00159 typedef SmartPointer<Self> Pointer;
00160
00162 itkNewMacro(Self);
00163
00165 itkTypeMacro(PhilipsPAR, Superclass);
00166
00167
00168
00169
00170
00171 void ReadPAR(std::string parFile, struct par_parameter* pPar);
00172
00173
00174
00175 typedef std::pair< int, int > PARSliceIndexImageType;
00176 typedef std::vector< PARSliceIndexImageType > PARSliceIndexImageTypeVector;
00177 PARSliceIndexImageTypeVector GetRECSliceIndexImageTypes(
00178 std::string parFile);
00179
00180
00181
00182 typedef std::pair< int, int > PARSliceIndexScanSequence;
00183 typedef std::vector< PARSliceIndexScanSequence > PARSliceIndexScanSequenceVector;
00184 PARSliceIndexScanSequenceVector GetRECSliceIndexScanningSequence(
00185 std::string parFile);
00186
00187
00188
00189 typedef std::pair< int, int > PARImageTypeScanSequence;
00190 typedef std::vector< PARImageTypeScanSequence > PARImageTypeScanSequenceVector;
00191 PARImageTypeScanSequenceVector GetImageTypesScanningSequence(
00192 std::string parFile);
00193
00194
00195
00196
00197
00198
00199 typedef vnl_vector_fixed< double, PAR_RESCALE_VALUES_SIZE >
00200 PARRescaleValues;
00201 typedef VectorContainer< unsigned int, PARRescaleValues >
00202 PARRescaleValuesContainer;
00203 bool GetRECRescaleValues(std::string parFile,
00204 PARRescaleValuesContainer *rescaleValues, int scan_sequence);
00205
00206
00207
00208
00209
00210
00211
00212 typedef vnl_vector_fixed< double, PAR_DIFFUSION_VALUES_SIZE >
00213 PARDiffusionValues;
00214 typedef VectorContainer< unsigned int, PARDiffusionValues >
00215 PARDiffusionValuesContainer;
00216 typedef VectorContainer< unsigned int, double >
00217 PARBValuesContainer;
00218 bool GetDiffusionGradientOrientationAndBValues(std::string parFile,
00219 PARDiffusionValuesContainer *gradientValues, PARBValuesContainer *bValues);
00220
00221
00222 typedef VectorContainer< unsigned int, int > PARLabelTypesASLContainer;
00223 bool GetLabelTypesASL(std::string parFile,
00224 PARLabelTypesASLContainer *labelTypes);
00225
00226
00227 std::string GetLineNumber(std::string file, int lineNum);
00228
00229 protected:
00230 PhilipsPAR();
00231 ~PhilipsPAR();
00232 void PrintSelf(std::ostream& os, Indent indent) const;
00233
00234 private:
00235 PhilipsPAR(const Self&);
00236 void operator=(const Self&);
00237
00239 int GetPARVersion(std::string parFile);
00240
00242 std::string GetGeneralInfoString(std::string file, int lineNum);
00243
00245 std::string m_FileName;
00246
00248 std::vector<std::string> m_PARFileLines;
00249
00250 };
00251
00252 }
00253
00254 #endif
00255