00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SEQPULS_H
00019 #define SEQPULS_H
00020
00021 #include <odinseq/seqdur.h>
00022 #include <odinseq/seqfreq.h>
00023 #include <odinseq/seqobj.h>
00024 #include <odinseq/seqdriver.h>
00025
00026
00027
00028 #define _MAX_PULSE_ATTENUATION_ 120.0
00029
00030
00042 enum pulseType {excitation=0, refocusing, storeMagn, recallMagn, inversion, saturation, numof_pulseTypes};
00043 static const char* pulseTypeLabel[]={"excitation", "refocusing","storeMagn","recallMagn","inversion","saturation"};
00044
00045
00046
00048
00049
00050
00056 class SeqPulsInterface : public virtual SeqTreeObj, public virtual SeqFreqChanInterface {
00057
00058 public:
00059
00066 virtual SeqPulsInterface& set_pulsduration(float pulsduration) {if(marshall) marshall->set_pulsduration(pulsduration); else marshall_error(); return *this;}
00067
00074 virtual double get_pulsduration() const {if(marshall) return marshall->get_pulsduration(); else marshall_error(); return 0.0;}
00075
00076
00080 virtual float get_flipangle() const {if(marshall) return marshall->get_flipangle(); else marshall_error(); return 0.0;}
00081
00082
00086 virtual SeqPulsInterface& set_flipangle(float flipangle) {if(marshall) marshall->set_flipangle(flipangle); else marshall_error(); return *this;}
00087
00088
00093 SeqPulsInterface& set_flipangles(const fvector& flipangles);
00094
00095
00100 fvector get_flipangles() const {return get_flipangle()*get_flipscales();}
00101
00102
00106 virtual SeqPulsInterface& set_power(float pulspower) {if(marshall) marshall->set_power(pulspower); else marshall_error(); return *this;}
00107
00108
00112 virtual float get_power() const {if(marshall) return marshall->get_power(); else marshall_error(); return 0.0;}
00113
00114
00118 virtual SeqPulsInterface& set_rel_magnetic_center(float center) {if(marshall) marshall->set_rel_magnetic_center(center); else marshall_error(); return *this;}
00119
00123 virtual float get_rel_magnetic_center() const {if(marshall) return marshall->get_rel_magnetic_center(); else marshall_error(); return 0.0;}
00124
00128 virtual float get_magnetic_center() const {if(marshall) return marshall->get_magnetic_center(); else marshall_error(); return 0.0;}
00129
00133 virtual SeqPulsInterface& set_pulse_type(pulseType type) {if(marshall) marshall->set_pulse_type(type); else marshall_error(); return *this;}
00134
00138 virtual pulseType get_pulse_type() const {if(marshall) return marshall->get_pulse_type(); else marshall_error(); return pulseType(0);}
00139
00140
00144 virtual SeqPulsInterface& set_flipangle_reorder_scheme(reorderScheme scheme,unsigned int nsegments) {if(marshall) marshall->set_flipangle_reorder_scheme(scheme,nsegments); else marshall_error(); return *this;}
00145
00146
00150 virtual const SeqVector& get_flipangle_vector() const {if(marshall) return marshall->get_flipangle_vector(); else marshall_error(); return get_dummyvec();}
00151
00155 virtual const SeqVector& get_flipangle_reorder_vector() const {if(marshall) return marshall->get_flipangle_vector(); else marshall_error(); return get_dummyvec();}
00156
00157 protected:
00158
00159 SeqPulsInterface() : marshall(0) {}
00160 virtual ~SeqPulsInterface() {}
00161
00162 virtual void set_flipscales(const fvector& flipscales) {if(marshall) marshall->set_flipscales(flipscales); else marshall_error();}
00163 virtual fvector get_flipscales() const {if(marshall) return marshall->get_flipscales(); else marshall_error(); return fvector();}
00164
00165 void set_marshall(SeqPulsInterface* mymarshall) {marshall=mymarshall;}
00166
00167 private:
00168 SeqPulsInterface* marshall;
00169 };
00170
00171
00173
00174
00175 class SeqPuls;
00176
00181 class SeqFlipAngVector : public SeqVector {
00182
00183 public:
00184
00185 SeqFlipAngVector(const STD_string& object_label, SeqPuls* flipangvec_user ) : SeqVector(object_label), user(flipangvec_user) {}
00186
00187
00188
00189 unsigned int get_vectorsize() const {return flipanglescale.size();}
00190 bool needs_unrolling_check() const {return true;}
00191 bool prep_iteration() const;
00192 svector get_vector_commands(const STD_string& iterator) const;
00193
00194 fvector flipanglescale;
00195
00196 private:
00197
00198 SeqFlipAngVector(const SeqFlipAngVector&) {}
00199 SeqFlipAngVector& operator = (const SeqFlipAngVector&) {return *this;}
00200
00201 SeqPuls* user;
00202 };
00203
00204
00205
00207
00212 class SeqPulsDriver : public SeqDriverBase {
00213
00214 public:
00215 SeqPulsDriver() {}
00216 virtual ~SeqPulsDriver() {}
00217
00218 virtual bool prep_driver(const cvector& wave, double pulsduration, double pulscenter, float b1max, float power, float flipangle, const fvector& flipscales, pulseType plstype) = 0;
00219 virtual void event(eventContext& context, double start) const = 0;
00220 virtual double get_rf_energy() const = 0;
00221
00222 virtual bool prep_flipangle_iteration(unsigned int count) = 0;
00223
00224 virtual double get_predelay() const = 0;
00225 virtual double get_postdelay() const = 0;
00226
00227 virtual STD_string get_program(programContext& context, unsigned int phaselistindex, int channel, const STD_string& iteratorcommand) const = 0;
00228
00229 virtual STD_string get_instr_label() const = 0;
00230
00231 virtual svector get_flipvector_commands(const STD_string& iterator) const =0;
00232
00233
00234 virtual void new_freq(double newfreq) const = 0;
00235 virtual bool has_new_freq() const = 0;
00236
00237
00238 virtual SeqPulsDriver* clone_driver() const = 0;
00239 };
00240
00242
00243
00256 class SeqPuls : public virtual SeqPulsInterface, public SeqObjBase, public SeqFreqChan, public SeqDur {
00257
00258 public:
00259
00274 SeqPuls(const STD_string& object_label,const cvector& waveform,float pulsduration,
00275 float pulspower,
00276 const STD_string& nucleus="",const dvector& phaselist=0,
00277 const dvector& freqlist=0,float rel_magnetic_center=0.5);
00278
00282 SeqPuls(const STD_string& object_label = "unnamedSeqPuls");
00283
00287 SeqPuls(const SeqPuls& sp);
00288
00289
00293 SeqPuls& operator = (const SeqPuls& sp);
00294
00295
00299 SeqPuls& set_wave(const cvector& waveform);
00300
00304 cvector get_wave() const {return wave;}
00305
00309 double get_pulsstart() const {return pulsdriver->get_predelay();}
00310
00311
00312
00313 SeqPulsInterface& set_pulsduration(float pulsduration);
00314 double get_pulsduration() const;
00315 float get_flipangle() const {return system_flipangle;}
00316 SeqPulsInterface& set_flipangle(float flipangle) {return set_system_flipangle(flipangle);}
00317 float get_power() const {return power;}
00318 SeqPulsInterface& set_power(float pulspower) {power=pulspower; return *this;}
00319 SeqPulsInterface& set_rel_magnetic_center(float center) {relmagcent=center; return *this;}
00320 float get_rel_magnetic_center() const {return relmagcent;}
00321 float get_magnetic_center() const;
00322 SeqPulsInterface& set_pulse_type(pulseType type);
00323 pulseType get_pulse_type() const;
00324 const SeqVector& get_flipangle_vector() const {return flipvec;}
00325 void set_flipscales(const fvector& flipscales) {flipvec.flipanglescale=flipscales;}
00326 fvector get_flipscales() const {return flipvec.flipanglescale;}
00327 SeqPulsInterface& set_flipangle_reorder_scheme(reorderScheme scheme,unsigned int nsegments) {flipvec.set_reorder_scheme(scheme,nsegments); return *this;}
00328 const SeqVector& get_flipangle_reorder_vector() const {return flipvec.get_reorder_vector();}
00329
00330
00331
00332 double get_duration() const;
00333 STD_string get_program(programContext& context) const;
00334 double get_rf_energy() const;
00335 STD_string get_properties() const;
00336 unsigned int event(eventContext& context) const;
00337 SeqValList get_freqvallist(freqlistAction action) const;
00338
00339
00340
00341 SeqPuls& set_system_flipangle(float angle);
00342 SeqPuls& set_B1max(float b1max);
00343 float get_B1max() const {return B1max_mT;}
00344
00345
00346 private:
00347 friend class SeqFlipAngVector;
00348
00349
00350 double get_freqchan_duration() const {return get_pulsduration();}
00351 STD_string get_driver_instr_label() const {return pulsdriver->get_instr_label();}
00352
00353
00354 bool prep();
00355
00356 mutable SeqDriverInterface<SeqPulsDriver> pulsdriver;
00357
00358 cvector wave;
00359 float power;
00360 float system_flipangle;
00361 float B1max_mT;
00362 float relmagcent;
00363 pulseType plstype;
00364
00365 SeqFlipAngVector flipvec;
00366
00367 };
00368
00369
00370
00374 #endif