reco.h

00001 /***************************************************************************
00002                           reco.h  -  Parameters for image reconstruction
00003                              -------------------
00004     begin                : Thu May 06 2004
00005     copyright            : (C) 2001 by Thies H. Jochimsen
00006     email                : jochimse@cns.mpg.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef RECO_H
00019 #define RECO_H
00020 
00021 #include <tjutils/tjstatic.h>
00022 #include <tjutils/tjvector.h>
00023 #include <tjutils/tjvallist.h>
00024 
00025 #include <odinpara/odinpara.h>
00026 #include <odinpara/jdxblock.h>
00027 #include <odinpara/jdxtypes.h>
00028 #include <odinpara/jdxarrays.h>
00029 
00030 
00036 // some limits
00037 #define MAX_NUMOF_READOUT_SHAPES        10
00038 #define MAX_NUMOF_KSPACE_TRAJS          10
00039 #define MAX_NUMOF_ADC_WEIGHTING_VECTORS 10
00040 
00041 
00047 enum recoFlags {
00048   recoLastInChunkBit   =1,
00049   recoReflectBit       =2,
00050   recoAllBits          =255
00051 };
00052 
00053 
00055 
00073 enum recoDim                      { userdef=0, te,  average,  cycle,  slice,  line3d,  line,  echo,  templtype,  freq,  channel,  readout,  repetition, n_recoDims};
00074 static const char* recoDimLabel[]={"userdef", "te","average","cycle","slice","line3d","line","echo","templtype","freq","channel","readout","repetition"};
00075 static const int n_recoIndexDims=templtype+1; // only the first dims are required for indexing of ADCs, the remaining are used only by odinreco
00076 
00077 
00079 
00080 
00090 enum templateType                    {no_template=0, phasecorr_template, fieldmap_template, grappa_template, epiprescan_template, n_templateTypes};
00091 static const char templateTypeChar[]={'N',           'P',                'F',               'G',             'E'}; // Use uppercase to distinguish from tag chars
00092 
00093 
00095 
00096 
00101 struct kSpaceCoord {
00102 
00103   kSpaceCoord() {reset2defaults();}
00104 
00105   // for STD_list
00106   bool operator == (const kSpaceCoord& ri) const;
00107   bool operator <  (const kSpaceCoord& ri) const;
00108 
00109 
00110   static int string2index(const STD_string& str, recoDim dim);
00111   static STD_string index2string(int index, recoDim dim);
00112 
00113   STD_string printcoord() const;
00114   friend STD_ostream& operator << (STD_ostream& s,const kSpaceCoord& kcoord) { return s << kcoord.printcoord();}
00115   bool parsecoord(const STD_string& str);
00116   void reset2defaults();
00117 
00118   static STD_string print_header();
00119 
00120 
00121   mutable int number;  // unique index of the ADC
00122   int reps;    // number of times this ADC is repeated
00123   short adcSize; // size with oversampling
00124   unsigned char channels; // coil channels
00125   short preDiscard;  // points to discard at the beginning of an ADC
00126   short postDiscard; // points to discard at the end of an ADC
00127   short concat; // number of concatenated acquisition this ADC is composed of
00128   float oversampling; // oversampling factor
00129 
00130   short readoutIndex; // index of the readout shape to be used for ramp-sampling correction, -1 if none
00131   short trajIndex;   // index of the used k-space trajectory, -1 if none
00132   short weightIndex;   // index of the used ADC weighting vector, -1 if none
00133   short dtIndex; // index of the dwell time used
00134 
00135   short index[n_recoDims]; // multi-dimensional reco index to locate ADC in k-space
00136 
00137   unsigned char flags; // recoFlags
00138 
00139 
00140 
00141  private:
00142   friend class JDXkSpaceCoords;
00143 
00144   static void assign_parsepos(const STD_string& header);
00145 
00146 
00147   static int parsepos_number;
00148   static int parsepos_reps;
00149   static int parsepos_adcSize;
00150   static int parsepos_channels;
00151   static int parsepos_preDiscard;
00152   static int parsepos_postDiscard;
00153   static int parsepos_concat;
00154   static int parsepos_oversampling;
00155   static int parsepos_readoutIndex;
00156   static int parsepos_trajIndex;
00157   static int parsepos_weightIndex;
00158   static int parsepos_dtIndex;
00159   static int parsepos_index[n_recoIndexDims];
00160   static int parsepos_lastinchunk;
00161   static int parsepos_reflect;
00162   static int max_parsepos;
00163   
00164 };
00165 
00167 
00168 
00173 class JDXkSpaceCoords : public JcampDxClass {
00174 
00175   enum JDXkSpaceCoords_state {coords_in_list, has_vec_cache, has_vec_alloc};
00176 
00177  public:
00178   JDXkSpaceCoords();
00179   ~JDXkSpaceCoords() {clear();}
00180 
00181   unsigned int size() const {create_vec_cache(); return vec_cache.size();}
00182 
00183   const kSpaceCoord& operator [] (unsigned int i) const {create_vec_cache(); return *(vec_cache[i]);}
00184 
00185   void clear(); // clear list before retrieving k-space ordering from sequence
00186 
00187   JDXkSpaceCoords& append_coord(const kSpaceCoord& coord);
00188 
00189  private:
00190   friend class RecoPars;
00191 
00192   void create_vec_cache() const;
00193 
00194   // overwriting virtual functions from JcampDxClass
00195   bool parsevalstring (const STD_string& parstring);
00196   STD_string printvalstring() const;
00197   STD_ostream& print2stream(STD_ostream& os) const;
00198   const char* get_typeInfo() const {return "kSpaceCoords";}
00199   JcampDxClass* create_copy() const {return new JDXkSpaceCoords(*this);}
00200 
00201   mutable STD_list<kSpaceCoord> coordlist;
00202 
00203   mutable JDXkSpaceCoords_state state;
00204   mutable STD_vector<kSpaceCoord*> vec_cache; // use pointers for better performance
00205 };
00206 
00208 
00213 struct RecoValList : public ValList<int> {
00214   RecoValList(const STD_string& object_label="unnamedRecoValList", unsigned int repetitions=1) : ValList<int>(object_label,repetitions) {}
00215 };
00216 
00218 
00223 class JDXrecoValList : public RecoValList, public JcampDxClass {
00224 
00225  public:
00226   JDXrecoValList(const STD_string& ldrlabel="unnamedJDXrecoValList");
00227   JDXrecoValList(const JDXrecoValList& jdrvl) {JDXrecoValList::operator = (jdrvl);}
00228   JDXrecoValList& operator = (const JDXrecoValList& jdrvl);
00229 
00230   JDXrecoValList& operator = (const RecoValList& rvl); // for assignment from get_recovallist in SeqMethod
00231 
00232   // overwriting virtual functions from JcampDxClass
00233   bool parsevalstring (const STD_string& parstring);
00234   STD_string printvalstring() const;
00235   STD_ostream& print2stream(STD_ostream& os) const;
00236   const char* get_typeInfo() const {return "RecoValList";}
00237   JcampDxClass* create_copy() const {return new JDXrecoValList(*this);}
00238 
00239 };
00240 
00242 
00243 
00247 class RecoPars : public JcampDxBlock {
00248 
00249  public:
00250 
00254   RecoPars(const STD_string& label="unnamedRecoPars");
00255 
00259   RecoPars(const RecoPars& sr);
00260 
00264   RecoPars& operator = (const RecoPars& sr);
00265 
00269   const JDXkSpaceCoords& get_kSpaceCoords() const {return kSpaceCoords;}
00270 
00274   const STD_string& get_DataFormat() const {return DataFormat;}
00275 
00279   bool is_LittleEndian() const {return LittleEndian;}
00280 
00284   const STD_string& get_RawFile() const {return RawFile;}
00285 
00289   unsigned int get_RawHeaderSize() const {return RawHeaderSize;}
00290 
00294   const fvector& get_RelativeOffset() const {return RelativeOffset;}
00295 
00299   const fvector& get_CoordinateScaling() const {return CoordinateScaling;}
00300 
00304   const dvector& get_DimValues(recoDim dim) const {return DimValues[dim];}
00305 
00309   fvector get_ChannelScales() const {return ChannelScaling;}
00310 
00314   double get_DwellTime(unsigned int i) const;
00315 
00321   int get_MatrixSizeRead() const {return MatrixSizeRead;}
00322 
00326   int get_MatrixSizePhase() const {return MatrixSizePhase;}
00327 
00331   int get_MatrixSizePhase2() const {return MatrixSizePhase2;}
00332 
00338   int get_NumOfAdcChunks() const;
00339 
00340 
00344   RecoPars& set_DimValues(recoDim dim, const dvector& vals);
00345 
00346 
00350   int append_readout_shape(const fvector& shape);
00351 
00355   int append_kspace_traj(const farray& kspace_traj);
00356 
00360   int append_adc_weight_vec(const cvector& weightvec);
00361 
00365   int append_dwell_time(double dt);
00366 
00367 
00371   const fvector& get_ReadoutShape(unsigned int i) const;
00372 
00373 
00377   unsigned int numof_kSpaceTraj() const;
00378 
00382   const farray& get_kSpaceTraj(unsigned int i) const;
00383 
00384 
00388   const cvector& get_AdcWeightVector(unsigned int i) const;
00389 
00390 
00396   unsigned long get_TotalNumOfSamples(bool discard=false) const;
00397 
00401   unsigned int numof_adcs() const {return kSpaceOrdering.size();}
00402 
00406   const kSpaceCoord& get_kSpaceCoord(unsigned int i) const;
00407 
00411   RecoPars& set_Recipe(const STD_string& recipe) {Recipe=recipe; return *this;}
00412 
00416   STD_string get_Recipe() const {return Recipe;}
00417 
00423   RecoPars& set_PostProc3D(const STD_string& recipe) {PostProc3D=recipe; return *this;}
00424 
00430   STD_string get_PostProc3D() const {return PostProc3D;}
00431 
00436   RecoPars& set_PreProc3D(const STD_string& recipe) {PreProc3D=recipe; return *this;}
00437 
00442   STD_string get_PreProc3D() const {return PreProc3D;}
00443 
00447   RecoPars& set_CmdLineOpts(const STD_string& opts) {CmdLineOpts=opts; return *this;}
00448 
00453   STD_string get_CmdLineOpts() const {return CmdLineOpts;}
00454 
00455 
00456  private:
00457   friend class SeqAcq;
00458   friend class SeqEpiDriverParavision;
00459   friend class SeqMethod;
00460 
00461   void common_init();
00462 
00463   void reset();
00464   void create_cache() const;
00465 
00466   void append_all_members();
00467 
00468   JDXstring DataFormat;
00469   JDXbool   LittleEndian;
00470   JDXstring RawFile;
00471   JDXint    RawHeaderSize;
00472   JDXint    MatrixSizeRead;
00473   JDXint    MatrixSizePhase;
00474   JDXint    MatrixSizePhase2;
00475   JDXtriple RelativeOffset;
00476   JDXtriple CoordinateScaling;
00477   JDXfloatArr ChannelScaling;
00478   JDXdoubleArr DwellTime;
00479   JDXfloatArr   ReadoutShape[MAX_NUMOF_READOUT_SHAPES];
00480   JDXfloatArr   kSpaceTraj[MAX_NUMOF_KSPACE_TRAJS];
00481   JDXcomplexArr AdcWeightVector[MAX_NUMOF_ADC_WEIGHTING_VECTORS];
00482   JDXdoubleArr DimValues[n_recoIndexDims];
00483   JDXstring Recipe;
00484   JDXstring PreProc3D;
00485   JDXstring PostProc3D;
00486   JDXstring CmdLineOpts;
00487 
00488   JDXkSpaceCoords kSpaceCoords;
00489   JDXrecoValList kSpaceOrdering;
00490 
00491   mutable STD_vector<int> kSpaceOrdering_cache; // fast cache of ADC indices
00492   mutable bool cache_is_up2date;
00493 
00494 };
00495 
00496 
00497 
00500 
00501 
00502 
00506 class CoilSensitivity : public JcampDxBlock {
00507 
00508  public:
00509 
00513   CoilSensitivity(const STD_string& label="unnamedCoilSensitivity");
00514 
00518   CoilSensitivity(const CoilSensitivity& cs);
00519 
00523   CoilSensitivity& operator = (const CoilSensitivity& cs);
00524 
00525 
00530   CoilSensitivity& set_sensitivity_map(const carray& sens_map, float FOVx, float FOVy, float FOVz);
00531 
00536   STD_complex get_sensitivity_value(unsigned int channel, float x, float y, float z) const;
00537 
00541   unsigned int get_numof_channels() const {return SensitivityMap.get_extent()[0];}
00542 
00543 
00544  private:
00545   void append_all_members();
00546 
00547   JDXtriple     FOV;
00548   JDXcomplexArr SensitivityMap;
00549 };
00550 
00551 
00553 
00554 
00555 
00561 #endif

Generated on Sat Jun 14 12:31:22 2008 by  doxygen 1.5.1