seqpuls.h
1 /***************************************************************************
2  seqpuls.h - description
3  -------------------
4  begin : Wed Aug 8 2001
5  copyright : (C) 2000-2015 by Thies H. Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef SEQPULS_H
19 #define SEQPULS_H
20 
21 #include <odinseq/seqdur.h>
22 #include <odinseq/seqfreq.h>
23 #include <odinseq/seqobj.h>
24 #include <odinseq/seqdriver.h>
25 
26 
27 
28 #define _MAX_PULSE_ATTENUATION_ 120.0
29 
30 
42 enum pulseType {excitation=0, refocusing, storeMagn, recallMagn, inversion, saturation, numof_pulseTypes};
43 static const char* pulseTypeLabel[]={"excitation", "refocusing","storeMagn","recallMagn","inversion","saturation"};
44 AVOID_CC_WARNING(pulseTypeLabel)
45 
46 
47 
48 
50 
51 
52 
57 class SeqPulsInterface : public virtual SeqTreeObj, public virtual SeqFreqChanInterface {
58 
59  public:
60 
67  virtual SeqPulsInterface& set_pulsduration(float pulsduration) {if(marshall) marshall->set_pulsduration(pulsduration); else marshall_error(); return *this;}
68 
75  virtual double get_pulsduration() const {if(marshall) return marshall->get_pulsduration(); else marshall_error(); return 0.0;}
76 
77 
81  virtual float get_flipangle() const {if(marshall) return marshall->get_flipangle(); else marshall_error(); return 0.0;}
82 
83 
87  virtual SeqPulsInterface& set_flipangle(float flipangle) {if(marshall) marshall->set_flipangle(flipangle); else marshall_error(); return *this;}
88 
89 
94  SeqPulsInterface& set_flipangles(const fvector& flipangles);
95 
96 
101  fvector get_flipangles() const {return get_flipangle()*get_flipscales();}
102 
103 
107  virtual SeqPulsInterface& set_power(float pulspower) {if(marshall) marshall->set_power(pulspower); else marshall_error(); return *this;}
108 
109 
113  virtual float get_power() const {if(marshall) return marshall->get_power(); else marshall_error(); return 0.0;}
114 
115 
119  virtual SeqPulsInterface& set_rel_magnetic_center(float center) {if(marshall) marshall->set_rel_magnetic_center(center); else marshall_error(); return *this;}
120 
124  virtual float get_rel_magnetic_center() const {if(marshall) return marshall->get_rel_magnetic_center(); else marshall_error(); return 0.0;}
125 
129  virtual float get_magnetic_center() const {if(marshall) return marshall->get_magnetic_center(); else marshall_error(); return 0.0;}
130 
134  virtual SeqPulsInterface& set_pulse_type(pulseType type) {if(marshall) marshall->set_pulse_type(type); else marshall_error(); return *this;}
135 
139  virtual pulseType get_pulse_type() const {if(marshall) return marshall->get_pulse_type(); else marshall_error(); return pulseType(0);}
140 
141 
145  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;}
146 
147 
151  virtual const SeqVector& get_flipangle_vector() const {if(marshall) return marshall->get_flipangle_vector(); else marshall_error(); return get_dummyvec();}
152 
156  virtual const SeqVector& get_flipangle_reorder_vector() const {if(marshall) return marshall->get_flipangle_vector(); else marshall_error(); return get_dummyvec();}
157 
158  protected:
159 
160  SeqPulsInterface() : marshall(0) {}
161  virtual ~SeqPulsInterface() {}
162 
163  virtual void set_flipscales(const fvector& flipscales) {if(marshall) marshall->set_flipscales(flipscales); else marshall_error();}
164  virtual fvector get_flipscales() const {if(marshall) return marshall->get_flipscales(); else marshall_error(); return fvector();}
165 
166  void set_marshall(SeqPulsInterface* mymarshall) {marshall=mymarshall;} // to be used in constructor code
167 
168  private:
169  SeqPulsInterface* marshall; // for marshalling member functions to a sub-object
170 };
171 
172 
174 
175 
176 class SeqPuls; // forward declaration
177 
182 class SeqFlipAngVector : public SeqVector {
183 
184  public:
185 
186  SeqFlipAngVector(const STD_string& object_label, SeqPuls* flipangvec_user ) : SeqVector(object_label), user(flipangvec_user) {}
187 
188 
189  // overloading virtual functions from SeqVector
190  unsigned int get_vectorsize() const {return flipanglescale.size();}
191  bool needs_unrolling_check() const {return true;}
192  bool prep_iteration() const;
193  svector get_vector_commands(const STD_string& iterator) const;
194 
195  fvector flipanglescale;
196 
197  private:
198  // disable copying
200  SeqFlipAngVector& operator = (const SeqFlipAngVector&) {return *this;}
201 
202  SeqPuls* user;
203 };
204 
205 
206 
208 
213 class SeqPulsDriver : public SeqDriverBase {
214 
215  public:
216  SeqPulsDriver() {}
217  virtual ~SeqPulsDriver() {}
218 
219  virtual bool prep_driver(const cvector& wave, double pulsduration, double pulscenter, float b1max, float power, float flipangle, const fvector& flipscales, pulseType plstype) = 0;
220  virtual void event(eventContext& context, double start) const = 0;
221  virtual double get_rf_energy() const = 0;
222 
223  virtual bool prep_flipangle_iteration(unsigned int count) = 0;
224 
225  virtual double get_predelay() const = 0;
226  virtual double get_postdelay() const = 0;
227 
228  virtual STD_string get_program(programContext& context, unsigned int phaselistindex, int channel, const STD_string& iteratorcommand) const = 0;
229 
230  virtual STD_string get_instr_label() const = 0;
231 
232  virtual svector get_flipvector_commands(const STD_string& iterator) const =0;
233 // virtual svector get_phase_commands(const STD_string& iterator) const =0;
234 
235  virtual void new_freq(double newfreq) const = 0;
236  virtual bool has_new_freq() const = 0;
237 
238 
239  virtual SeqPulsDriver* clone_driver() const = 0;
240 };
241 
243 
244 
257 class SeqPuls : public virtual SeqPulsInterface, public SeqObjBase, public SeqFreqChan, public SeqDur {
258 
259  public:
260 
275 SeqPuls(const STD_string& object_label,const cvector& waveform,float pulsduration,
276  float pulspower,
277  const STD_string& nucleus="",const dvector& phaselist=0,
278  const dvector& freqlist=0,float rel_magnetic_center=0.5);
279 
283  SeqPuls(const STD_string& object_label = "unnamedSeqPuls");
284 
288  SeqPuls(const SeqPuls& sp);
289 
290 
294  SeqPuls& operator = (const SeqPuls& sp);
295 
296 
300  SeqPuls& set_wave(const cvector& waveform);
301 
305  cvector get_wave() const {return wave;}
306 
310  double get_pulsstart() const {return pulsdriver->get_predelay();}
311 
312 
313  // overloading virtual functions from SeqPulsInterface
314  SeqPulsInterface& set_pulsduration(float pulsduration);
315  double get_pulsduration() const;
316  float get_flipangle() const {return system_flipangle;}
317  SeqPulsInterface& set_flipangle(float flipangle) {return set_system_flipangle(flipangle);}
318  float get_power() const {return power;}
319  SeqPulsInterface& set_power(float pulspower) {power=pulspower; return *this;}
320  SeqPulsInterface& set_rel_magnetic_center(float center) {relmagcent=center; return *this;}
321  float get_rel_magnetic_center() const {return relmagcent;}
322  float get_magnetic_center() const;
323  SeqPulsInterface& set_pulse_type(pulseType type);
324  pulseType get_pulse_type() const;
325  const SeqVector& get_flipangle_vector() const {return flipvec;}
326  void set_flipscales(const fvector& flipscales) {flipvec.flipanglescale=flipscales;}
327  fvector get_flipscales() const {return flipvec.flipanglescale;}
328  SeqPulsInterface& set_flipangle_reorder_scheme(reorderScheme scheme,unsigned int nsegments) {flipvec.set_reorder_scheme(scheme,nsegments); return *this;}
329  const SeqVector& get_flipangle_reorder_vector() const {return flipvec.get_reorder_vector();}
330 
331 
332  // overloading virtual function from SeqTreeObj
333  double get_duration() const;
334  STD_string get_program(programContext& context) const;
335  double get_rf_energy() const;
336  STD_string get_properties() const;
337  unsigned int event(eventContext& context) const;
338  SeqValList get_freqvallist(freqlistAction action) const;
339 
340 
341  // some helper functions to use SeqPulse together with OdinPulse/Pulsar
342  SeqPuls& set_system_flipangle(float angle);
343  SeqPuls& set_B1max(float b1max);
344  float get_B1max() const {return B1max_mT;}
345 
346 
347  private:
348  friend class SeqFlipAngVector;
349 
350  // overloading virtual functions from SeqFreqChan
351  double get_freqchan_duration() const {return get_pulsduration();}
352  STD_string get_driver_instr_label() const {return pulsdriver->get_instr_label();}
353 
354  // overwriting virtual functions from SeqClass
355  bool prep();
356 
357  mutable SeqDriverInterface<SeqPulsDriver> pulsdriver;
358 
359  cvector wave;
360  float power;
361  float system_flipangle;
362  float B1max_mT;
363  float relmagcent;
364  pulseType plstype;
365 
366  SeqFlipAngVector flipvec;
367 
368 };
369 
370 
371 
375 #endif
cvector get_wave() const
Definition: seqpuls.h:305
virtual bool prep()
Definition: seqclass.h:116
float get_power() const
Definition: seqpuls.h:318
virtual pulseType get_pulse_type() const
Definition: seqpuls.h:139
svector get_vector_commands(const STD_string &iterator) const
virtual float get_magnetic_center() const
Definition: seqpuls.h:129
unsigned int get_vectorsize() const
Definition: seqpuls.h:190
SeqPulsInterface & set_power(float pulspower)
Definition: seqpuls.h:319
pulseType
Definition: seqpuls.h:42
virtual float get_flipangle() const
Definition: seqpuls.h:81
virtual SeqFreqChanInterface & set_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1)
Definition: seqfreq.h:79
virtual SeqPulsInterface & set_pulse_type(pulseType type)
Definition: seqpuls.h:134
tjvector< float > fvector
Definition: tjvector.h:446
virtual const SeqVector & get_flipangle_vector() const
Definition: seqpuls.h:151
reorderScheme
Definition: seqvec.h:48
Definition: seqdur.h:38
bool prep_iteration() const
float get_rel_magnetic_center() const
Definition: seqpuls.h:321
SeqPulsInterface & set_flipangle(float flipangle)
Definition: seqpuls.h:317
virtual SeqPulsInterface & set_pulsduration(float pulsduration)
Definition: seqpuls.h:67
SeqVector(const STD_string &object_label="unnamedSeqVector")
virtual float get_power() const
Definition: seqpuls.h:113
virtual double get_pulsduration() const
Definition: seqpuls.h:75
RF pulse.
Definition: seqpuls.h:257
freqlistAction
Definition: seqtree.h:102
virtual const SeqVector & get_flipangle_reorder_vector() const
Definition: seqpuls.h:156
float get_flipangle() const
Definition: seqpuls.h:316
virtual SeqPulsInterface & set_flipangle_reorder_scheme(reorderScheme scheme, unsigned int nsegments)
Definition: seqpuls.h:145
const SeqVector & get_flipangle_vector() const
Definition: seqpuls.h:325
virtual SeqPulsInterface & set_flipangle(float flipangle)
Definition: seqpuls.h:87
SeqPulsInterface & set_rel_magnetic_center(float center)
Definition: seqpuls.h:320
bool needs_unrolling_check() const
Definition: seqpuls.h:191
virtual SeqPulsInterface & set_rel_magnetic_center(float center)
Definition: seqpuls.h:119
const SeqVector & get_reorder_vector() const
double get_pulsstart() const
Definition: seqpuls.h:310
virtual float get_rel_magnetic_center() const
Definition: seqpuls.h:124
const SeqVector & get_flipangle_reorder_vector() const
Definition: seqpuls.h:329
SeqPulsInterface & set_flipangle_reorder_scheme(reorderScheme scheme, unsigned int nsegments)
Definition: seqpuls.h:328
virtual SeqPulsInterface & set_power(float pulspower)
Definition: seqpuls.h:107
fvector get_flipangles() const
Definition: seqpuls.h:101