Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkPhilipsPAR.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkPhilipsPAR.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-29 12:17:28 $
00007   Version:   $Revision: 1.5 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
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  //par_parameter
00069 {
00070   int problemreading; // Marked 1 if problem occurred reading in PAR file
00071   int ResToolsVersion; // V3, V4, V4.1, or V4.2 PAR/REC version
00072   char patient_name[PAR_DEFAULT_STRING_LENGTH]; // Patient name
00073   char exam_name[PAR_DEFAULT_STRING_LENGTH]; // Examination name
00074   char protocol_name[PAR_DEFAULT_STRING_LENGTH]; // Protocol name
00075   char exam_date[PAR_DEFAULT_STRING_LENGTH]; // Examination date/time
00076   char exam_time[PAR_DEFAULT_STRING_LENGTH]; // Examination date/time
00077   char series_type[PAR_DEFAULT_STRING_LENGTH]; // Series Type
00078   int scno; // Acquisition nr
00079   int recno; // Reconstruction nr
00080   int scan_duration; // Scan Duration [sec]
00081   int cardiac_phases; // Max. number of cardiac phases
00082   float trigger_times[PAR_DEFAULT_TRIGGER_TIMES_SIZE]; // trigger_time (float)
00083   int echoes; // Max. number of echoes
00084   float echo_times[PAR_DEFAULT_ECHO_TIMES_SIZE]; // Echo times read from PAR file
00085   int slice; // Max. number of slices/locations
00086   int dyn; // Max. number of dynamics
00087   int mixes; // Max. number of mixes
00088   char patient_position[PAR_DEFAULT_STRING_LENGTH]; // Patient position
00089   char prep_direction[PAR_DEFAULT_STRING_LENGTH]; // Preparation direction
00090   short int bit; // Image pixel size [8 or 16 bits]
00091   char technique[PAR_DEFAULT_STRING_LENGTH]; // Technique
00092   char scan_mode[PAR_DEFAULT_STRING_LENGTH]; // Scan mode
00093   int num_averages; // Number of averages
00094   int scan_resolution[2]; // Scan resolution  (x, y)
00095   int scan_percent; // Scan percentage
00096   int dim[3]; // Recon resolution (x, y) + slices (z)
00097   float repetition_time[PAR_DEFAULT_REP_TIMES_SIZE]; // Repetition time [msec]
00098   int sliceorient; // slice orientation ( TRA/SAG/COR ) (integer)
00099   float slth; // Slice thickness [mm]
00100   float gap; // Slice gap [mm]
00101   float fov[3]; // FOV (ap,fh,rl) [mm]
00102   float water_fat_shift; // Water Fat shift [pixels]
00103   float angAP; // Angulation midslice(ap,fh,rl)[degr]
00104   float angFH; // Angulation midslice(ap,fh,rl)[degr]
00105   float angRL; // Angulation midslice(ap,fh,rl)[degr]
00106   float offAP; // Off Centre midslice(ap,fh,rl) [mm]
00107   float offFH; // Off Centre midslice(ap,fh,rl) [mm]
00108   float offRL; // Off Centre midslice(ap,fh,rl) [mm]
00109   int flow_comp; // Flow compensation <0=no 1=yes> ?
00110   int presaturation; // Presaturation     <0=no 1=yes> ?
00111   int cardiac_freq; // Cardiac frequency
00112   int min_rr_int; // Min. RR interval
00113   int max_rr_int; // Max. RR interval
00114   float phase_encode_vel[3]; // Phase encoding velocity [cm/sec]
00115   int mtc; // MTC               <0=no 1=yes> ?
00116   int spir; // SPIR              <0=no 1=yes> ?
00117   int epi; // EPI factor        <0,1=no EPI>
00118   int turbo; // TURBO factor      <0=no turbo>
00119   int dynamic_scan; // Dynamic scan      <0=no 1=yes> ?
00120   int diffusion; // Diffusion         <0=no 1=yes> ?
00121   float diff_echo; // Diffusion echo time [msec]
00122   float inversion_delay; // Inversion delay [msec]
00123   int max_num_diff_vals; // Max. number of diffusion values
00124   int max_num_grad_orient; // Max. number of gradient orients
00125   int num_label_types; // Number of label types   <0=no ASL>
00126   float vox[3]; // pixel spacing (x,y) (in mm)
00127   int slicessorted; // 1-slices sorted, 0-slices not sorted
00128   int image_blocks; // The total number of image blocks stored in the REC file
00129   int num_image_types; // The number of image types in the REC file
00130   int image_types[PAR_DEFAULT_IMAGE_TYPES_SIZE]; // The different image types 
00131                                                  // detected in the REC
00132   int num_scanning_sequences; // The number of scanning sequences in the REC file
00133   int scanning_sequences[PAR_DEFAULT_SCAN_SEQUENCE_SIZE]; // The different 
00134                                                           // scanning sequences 
00135                                                           // detected in the REC
00136   int num_slice_repetitions; // If num_scanning_sequences > 1 then 
00137                   // num_image_types may not equal the total number of slice 
00138                   // repetitions for a single acquisition.  This value is the 
00139                   // total number of slice repetitions for a single acquisition 
00140                   // and is valid only when slicessorted == 0.
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   // Reads the PAR file parameters in "parFile" and stores the PAR parameters in 
00168   // pPar.
00169   // Returns false if an error is encountered during reading, otherwise true is 
00170   // returned.
00171   void ReadPAR(std::string parFile, struct par_parameter* pPar);
00172 
00173   // Returns a vector of paired values, the first contains the slice index and the 
00174   // second is the image type for the PAR file "parFile".
00175   typedef std::pair< int, int >                 PARSliceIndexImageType;
00176   typedef std::vector< PARSliceIndexImageType > PARSliceIndexImageTypeVector;
00177   PARSliceIndexImageTypeVector GetRECSliceIndexImageTypes(
00178     std::string parFile);
00179 
00180   // Returns a vector of paired values, the first contains the slice index and the 
00181   // second is the scan sequence for the PAR file "parFile".
00182   typedef std::pair< int, int >                    PARSliceIndexScanSequence;
00183   typedef std::vector< PARSliceIndexScanSequence > PARSliceIndexScanSequenceVector;
00184   PARSliceIndexScanSequenceVector GetRECSliceIndexScanningSequence(
00185     std::string parFile);
00186 
00187   // Returns a vector of paired values, the first contains the image type and the 
00188   // second is the scan sequence for that image type for the PAR file "parFile".
00189   typedef std::pair< int, int >                   PARImageTypeScanSequence;
00190   typedef std::vector< PARImageTypeScanSequence > PARImageTypeScanSequenceVector;
00191   PARImageTypeScanSequenceVector GetImageTypesScanningSequence(
00192     std::string parFile);
00193 
00194   // Stores rescale values in the VectorContainer "rescaleValues" for each image 
00195   // type of the specified scan sequence number "scan_sequence" (from 
00196   // scanning_sequences) for the PAR file "parFile".
00197   // Returns false if an error is encountered during reading, otherwise true is 
00198   // returned.
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   // Stores the diffusion gradient values in the VectorContainer "gradientValues" 
00207   // and the diffusion b values in the VectorContainer "bValues" for each gradient 
00208   // direction in the PAR file "parFile".  This function is applicable only for PAR
00209   // versions > 4.1
00210   // Returns false if an error is encountered during reading, otherwise true is 
00211   // returned.
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   // Returns a vector of ASL label types for the PAR file "parFile".
00222   typedef VectorContainer< unsigned int, int > PARLabelTypesASLContainer;
00223   bool GetLabelTypesASL(std::string parFile,
00224     PARLabelTypesASLContainer *labelTypes);
00225 
00226   // Read a line number within the PAR file.
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&); //purposely not implemented
00236   void operator=(const Self&); //purposely not implemented
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 } // end namespace itk
00253 
00254 #endif                           /* __itkPhilipsPAR_h */
00255 

Generated at Fri Apr 16 19:18:30 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000