seqfreq.h
1 /***************************************************************************
2  seqfreq.h - description
3  -------------------
4  begin : Wed Aug 14 2002
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 
19 
20 #ifndef SEQFREQ_H
21 #define SEQFREQ_H
22 
23 #include <odinseq/seqclass.h>
24 #include <odinseq/seqvec.h>
25 #include <odinseq/seqphase.h>
26 #include <odinseq/seqdriver.h>
27 
28 
30 
36 class SeqFreqChanInterface : public virtual SeqClass {
37 
38  public:
42  virtual SeqFreqChanInterface& set_nucleus(const STD_string& nucleus) {if(marshall) marshall->set_nucleus(nucleus); else marshall_error(); return *this;}
43 
44 
48  virtual SeqFreqChanInterface& set_freqlist(const dvector& freqlist) {if(marshall) marshall->set_freqlist(freqlist); else marshall_error(); return *this;}
49 
53  virtual SeqFreqChanInterface& set_phaselist(const dvector& phaselist) {if(marshall) marshall->set_phaselist(phaselist); else marshall_error(); return *this;}
54 
58  virtual const SeqVector& get_freqlist_vector() const {if(marshall) return marshall->get_freqlist_vector(); else marshall_error(); return get_dummyvec();}
59 
60 
64  virtual const SeqVector& get_phaselist_vector() const {if(marshall) return marshall->get_phaselist_vector(); else marshall_error(); return get_dummyvec();}
65 
69  operator const SeqVector& () const {return get_freqlist_vector();}
70 
74  virtual SeqFreqChanInterface& set_encoding_scheme(encodingScheme scheme) {if(marshall) marshall->get_mutable_freqlist_vector().set_encoding_scheme(scheme); else marshall_error(); return *this;}
75 
79  virtual SeqFreqChanInterface& set_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1) {if(marshall) marshall->get_mutable_freqlist_vector().set_reorder_scheme(scheme,nsegments); else marshall_error(); return *this;}
80 
84  virtual const SeqVector& get_reorder_vector() const {if(marshall) return marshall->get_freqlist_vector().get_reorder_vector(); else marshall_error(); return get_dummyvec();}
85 
89  virtual SeqFreqChanInterface& set_phaselist_encoding_scheme(encodingScheme scheme) {if(marshall) marshall->get_mutable_phaselist_vector().set_encoding_scheme(scheme); else marshall_error(); return *this;}
90 
94  virtual SeqFreqChanInterface& set_phaselist_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1) {if(marshall) marshall->get_mutable_phaselist_vector().set_reorder_scheme(scheme,nsegments); else marshall_error(); return *this;}
95 
99  virtual const SeqVector& get_phaselist_reorder_vector() const {if(marshall) return marshall->get_phaselist_vector().get_reorder_vector(); else marshall_error(); return get_dummyvec();}
100 
101 
105  SeqFreqChanInterface& set_freqoffset(double freqoffset);
106 
110  SeqFreqChanInterface& set_phase(double phaseval);
111 
116  SeqFreqChanInterface& set_phasespoiling(unsigned int size=80, double incr=117.0, double offset=0.0);
117 
118  protected:
120  virtual ~SeqFreqChanInterface() {}
121 
122  void set_marshall(SeqFreqChanInterface* mymarshall) {marshall=mymarshall;} // to be used in constructor code
123 
124  private:
125  friend class SeqAcqEPI; // to allow SeqAcqEPI full access to its driver
126 
127  SeqFreqChanInterface* marshall; // for marshalling member functions to a sub-object
128 
129 
130  virtual SeqVector& get_mutable_freqlist_vector() {if(marshall) return marshall->get_mutable_freqlist_vector(); else marshall_error(); return get_dummyvec();}
131  virtual SeqVector& get_mutable_phaselist_vector() {if(marshall) return marshall->get_mutable_phaselist_vector(); else marshall_error(); return get_dummyvec();}
132 
133 };
134 
135 
137 
142 class SeqFreqChanDriver : public SeqDriverBase {
143 
144  public:
145  SeqFreqChanDriver() {}
146  virtual ~SeqFreqChanDriver() {}
147 
148  virtual bool prep_driver(const STD_string& nucleus, const dvector& freqlist) = 0;
149  virtual void prep_iteration(double current_frequency, double current_phase, double freqchan_duration) const = 0;
150  virtual int get_channel() const = 0;
151 
152  virtual STD_string get_iteratorcommand(objCategory cat,int freqlistindex) const = 0;
153  virtual svector get_freqvec_commands(const STD_string& iterator, const STD_string& instr) const = 0;
154 
155  virtual STD_string get_pre_program(programContext& context, objCategory cat, const STD_string& instr_label, double default_frequency, double default_phase) const = 0;
156 
157 
158  virtual SeqFreqChanDriver* clone_driver() const = 0;
159 
160  virtual void pre_event (eventContext& context,double starttime) const = 0;
161  virtual void post_event(eventContext& context,double starttime) const = 0;
162 };
163 
165 
171 class SeqFreqChan : public SeqVector, public virtual SeqFreqChanInterface {
172 
173  public:
177  SeqFreqChan(const STD_string& object_label="unnamedSeqFreqChan");
178 
179 
189  SeqFreqChan(const STD_string& object_label,const STD_string& nucleus,
190  const dvector& freqlist=0,const dvector& phaselist=0);
191 
192 
196  SeqFreqChan(const SeqFreqChan& sfc);
197 
198 
202  virtual ~SeqFreqChan() {}
203 
204 
208  SeqFreqChan& operator = (const SeqFreqChan& sfc);
209 
210 
214  int get_channel() const {return freqdriver->get_channel();}
215 
216 
220  dvector get_freqlist() const {return frequency_list;}
221 
222 
226  double get_phase() const {return phaselistvec.get_phase();}
227 
228 
232  virtual double get_frequency() const;
233 
234 
238  unsigned int get_phaselistindex() const {return phaselistvec.get_phaselistindex();}
239 
240 
244  virtual unsigned int get_freqlistindex() const {return 1;}
245 
246 
250  STD_string get_iteratorcommand(objCategory cat) const;
251 
252 
253 
254  // overloaded virtual functions of SeqFreqChanInterface
255  SeqFreqChanInterface& set_nucleus(const STD_string& nucleus);
256  SeqFreqChanInterface& set_freqlist (const dvector& freqlist) {frequency_list=freqlist; return *this;}
257  SeqFreqChanInterface& set_phaselist(const dvector& phaselist) {phaselistvec.set_phaselist(phaselist); return *this;}
258  const SeqVector& get_freqlist_vector() const {return *this;}
259  const SeqVector& get_phaselist_vector() const {return phaselistvec;}
260 
261 
262  // overloaded virtual functions of SeqVector
263  unsigned int get_vectorsize() const {return frequency_list.size();}
264  bool prep_iteration() const;
265  bool is_qualvector() const {return false;}
266  svector get_vector_commands(const STD_string& iterator) const {return freqdriver->get_freqvec_commands(iterator,get_driver_instr_label());}
267 
268  // overloaded functions for SeqTreeObj
269  SeqValList get_freqvallist(freqlistAction action) const;
270 
271 
272  protected:
273 
274  STD_string get_pre_program(programContext& context, objCategory cat, const STD_string& instr_label) const;
275 
276  void pre_event (eventContext& context,double starttime) const {freqdriver->pre_event(context,starttime);}
277  void post_event(eventContext& context,double starttime) const {freqdriver->post_event(context,starttime);}
278 
283  virtual double get_freqchan_duration() const {return 0.0;}
284 
285  // overwriting virtual functions from SeqClass
286  bool prep();
287 
288  private:
289  friend class SeqPhaseListVector;
290 
291  // overloaded virtual functions of SeqFreqChanInterface
292  SeqVector& get_mutable_freqlist_vector() {return *this;}
293  SeqVector& get_mutable_phaselist_vector() {return phaselistvec;}
294 
295 
296  double get_default_phase() const {return closest2zero(phaselistvec.get_phaselist());}
297  double get_default_frequency() const {return closest2zero(frequency_list);}
298 
299  static double closest2zero(const dvector& v);
300 
301  // for EPIC
302  virtual STD_string get_driver_instr_label() const {return "";}
303 
304 
305  // the hardware driver
306  mutable SeqDriverInterface<SeqFreqChanDriver> freqdriver;
307 
308  // the nucleus of this freq/phase object
309  STD_string nucleusName;
310 
311  // the frequency list to iterate through
312  dvector frequency_list;
313 
314  // the phaselist associated with this freq/phase object
315  SeqPhaseListVector phaselistvec;
316 };
317 
319 
320 #endif
virtual bool prep()
Definition: seqclass.h:116
virtual SeqFreqChanInterface & set_phaselist_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1)
Definition: seqfreq.h:94
SeqFreqChanInterface & set_phasespoiling(unsigned int size=80, double incr=117.0, double offset=0.0)
SeqVector & set_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1)
double get_phase() const
Definition: seqfreq.h:226
unsigned int get_vectorsize() const
Definition: seqfreq.h:263
virtual SeqFreqChanInterface & set_nucleus(const STD_string &nucleus)
Definition: seqfreq.h:42
SeqFreqChanInterface & set_freqlist(const dvector &freqlist)
Definition: seqfreq.h:256
int get_channel() const
Definition: seqfreq.h:214
svector get_vector_commands(const STD_string &iterator) const
Definition: seqfreq.h:266
virtual SeqFreqChanInterface & set_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1)
Definition: seqfreq.h:79
const SeqVector & get_phaselist_vector() const
Definition: seqfreq.h:259
reorderScheme
Definition: seqvec.h:48
unsigned int get_phaselistindex() const
Definition: seqfreq.h:238
void marshall_error() const
bool is_qualvector() const
Definition: seqfreq.h:265
virtual SeqFreqChanInterface & set_phaselist(const dvector &phaselist)
Definition: seqfreq.h:53
virtual SeqFreqChanInterface & set_phaselist_encoding_scheme(encodingScheme scheme)
Definition: seqfreq.h:89
virtual unsigned int get_freqlistindex() const
Definition: seqfreq.h:244
SeqFreqChanInterface & set_freqoffset(double freqoffset)
virtual const SeqVector & get_reorder_vector() const
Definition: seqfreq.h:84
virtual SeqFreqChanInterface & set_freqlist(const dvector &freqlist)
Definition: seqfreq.h:48
virtual const SeqVector & get_phaselist_reorder_vector() const
Definition: seqfreq.h:99
freqlistAction
Definition: seqtree.h:102
virtual double get_freqchan_duration() const
Definition: seqfreq.h:283
const SeqVector & get_freqlist_vector() const
Definition: seqfreq.h:258
virtual ~SeqFreqChan()
Definition: seqfreq.h:202
dvector get_freqlist() const
Definition: seqfreq.h:220
virtual SeqFreqChanInterface & set_encoding_scheme(encodingScheme scheme)
Definition: seqfreq.h:74
encodingScheme
Definition: seqvec.h:37
Acquisition + echo-planar imaging readout.
Definition: seqacqepi.h:191
virtual const SeqVector & get_phaselist_vector() const
Definition: seqfreq.h:64
virtual const SeqVector & get_freqlist_vector() const
Definition: seqfreq.h:58
const SeqVector & get_reorder_vector() const
objCategory
Definition: system.h:46
SeqFreqChanInterface & set_phaselist(const dvector &phaselist)
Definition: seqfreq.h:257
SeqVector & set_encoding_scheme(encodingScheme scheme)
SeqFreqChanInterface & set_phase(double phaseval)