seqacq.h
1 /***************************************************************************
2  seqacq.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 SEQACQ_H
19 #define SEQACQ_H
20 
21 #include <tjutils/tjhandler.h>
22 
23 #include <odinseq/seqobj.h>
24 #include <odinseq/seqfreq.h>
25 #include <odinseq/seqvec.h>
26 #include <odinseq/seqdriver.h>
27 
28 
29 class SeqGradChanParallel; // forward declaration
30 
31 
33 
39 class SeqAcqInterface : public virtual SeqFreqChanInterface {
40 
41  public:
42 
46  virtual double get_acquisition_duration() const {if(marshall) return marshall->get_acquisition_duration(); else marshall_error(); return 0.0;}
47 
52  virtual double get_acquisition_center() const {if(marshall) return marshall->get_acquisition_center(); else marshall_error(); return 0.0;}
53 
59  virtual double get_acquisition_start() const {if(marshall) return marshall->get_acquisition_start(); else marshall_error(); return 0.0;}
60 
61 
65  virtual unsigned int get_npts() const {if(marshall) return marshall->get_npts(); else marshall_error(); return 0;}
66 
67 
68 
69 
73  virtual SeqAcqInterface& set_sweepwidth(double sw, float os_factor) {if(marshall) marshall->set_sweepwidth(sw,os_factor); else marshall_error(); return *this;}
74 
75 
79  virtual double get_sweepwidth() const {if(marshall) return marshall->get_sweepwidth(); else marshall_error(); return 0.0;}
80 
84  virtual float get_oversampling() const {if(marshall) return marshall->get_oversampling(); else marshall_error(); return 0.0;}
85 
86 
87 
91  virtual SeqAcqInterface& set_readout_shape(const fvector& shape, unsigned int dstsize) {if(marshall) marshall->set_readout_shape(shape, dstsize); else marshall_error(); return *this;}
92 
93 
102  virtual SeqAcqInterface& set_reco_vector(recoDim dim, const SeqVector& vec, const dvector& valvec=dvector()) {if(marshall) marshall->set_reco_vector(dim, vec, valvec); else marshall_error(); return *this;}
103 
104 
105 
110  virtual SeqAcqInterface& set_default_reco_index(recoDim dim, unsigned int index) {if(marshall) marshall->set_default_reco_index(dim, index); else marshall_error(); return *this;}
111 
112 
117  virtual SeqAcqInterface& set_template_type(templateType type) {if(marshall) marshall->set_template_type(type); return set_default_reco_index(templtype,type);}
118 
119 
124  virtual SeqAcqInterface& set_reflect_flag(bool flag) {if(marshall) marshall->set_reflect_flag(flag); else marshall_error(); return *this;}
125 
126 
127 
128  protected:
129  SeqAcqInterface() : marshall(0) {}
130  virtual ~SeqAcqInterface() {}
131 
132  void set_marshall(SeqAcqInterface* mymarshall) {marshall=mymarshall;} // to be used in constructor code
133 
134  private:
135  friend class SeqAcqDeph;
136 
137  // to be used by SeqAcqDeph to retrieve pre-dephasing gradients from acquisition object.
138  // Overload this function if your acq needs pre-dephasers, return them by appending them to 'dephobj'.
139  // Returns any possible vector object as the return value.
140  virtual const SeqVector* get_dephgrad(SeqGradChanParallel& dephobj, bool rephase) const {if(marshall) return marshall->get_dephgrad(dephobj,rephase); return 0;}
141 
142  SeqAcqInterface* marshall; // for marshalling member functions to a sub-object
143 
144 };
145 
146 
147 
149 
150 
155 class SeqAcqDriver : public SeqDriverBase {
156 
157  public:
158  SeqAcqDriver() {}
159  virtual ~SeqAcqDriver() {}
160 
164  virtual double adjust_sweepwidth(double desired_sweep_widht) const = 0;
165 
169  virtual bool prep_driver(kSpaceCoord& recoindex, double sweepwidth, unsigned int nAcqPoints, double acqcenter, int freqchannel) = 0;
170 
174  virtual double get_predelay() const = 0;
175 
179  virtual double get_postdelay(double sweepwidth) const = 0;
180 
181  virtual void event(eventContext& context, double start) const = 0;
182 
183  virtual STD_string get_program(programContext& context, unsigned int phaselistindex) const = 0;
184 
185  virtual STD_string get_instr_label() const = 0;
186 
187  virtual unsigned int get_numof_channels() const = 0;
188 
189  virtual SeqAcqDriver* clone_driver() const = 0;
190 };
191 
192 
194 
195 
206 class SeqAcq : public virtual SeqAcqInterface, public SeqObjBase, public SeqFreqChan {
207 
208  public:
209 
224  SeqAcq(const STD_string& object_label, unsigned int nAcqPoints, double sweepwidth,
225  float os_factor=1.0, const STD_string& nucleus="",
226  const dvector& phaselist=0,const dvector& freqlist=0);
227 
228 
229 
233  SeqAcq(const SeqAcq& sa);
234 
238  SeqAcq(const STD_string& object_label="unnamedSeqAcq");
239 
243  ~SeqAcq();
244 
245 
249  SeqAcq& set_npts(unsigned int nAcqPoints);
250 
251 
255  double get_sweep_width() const {return sweep_width;}
256 
257 
261  SeqAcq& operator = (const SeqAcq& sa);
262 
263 
267  void set_kspace_traj(const farray& kspaceTraj);
268 
269 
273  void set_weight_vec(const cvector& weightVec);
274 
275 
280  SeqAcq& set_rel_center(double relative_kspace_center) {rel_center=relative_kspace_center; return *this;}
281 
282 
286  const kSpaceCoord& get_kcoord() const;
287 
288 
289  // overwriting virtual functions of SeqAcqInterface
290  double get_acquisition_duration() const {return secureDivision(npts,sweep_width);}
291  double get_acquisition_center() const;
292  double get_acquisition_start() const {return acqdriver->get_predelay();}
293  unsigned int get_npts() const {return npts;}
294  SeqAcqInterface& set_sweepwidth(double sw, float os_factor);
295  double get_sweepwidth() const {return sweep_width;}
296  float get_oversampling() const {return oversampl;}
297  SeqAcqInterface& set_readout_shape(const fvector& shape, unsigned int dstsize);
298  SeqAcqInterface& set_reco_vector(recoDim dim, const SeqVector& vec, const dvector& valvec=dvector());
299  SeqAcqInterface& set_default_reco_index(recoDim dim, unsigned int index);
300  SeqAcqInterface& set_reflect_flag(bool flag) {reflect_flag=flag; return *this;}
301 
302 
303  // overwriting virtual functions of SeqTreeObj
304  STD_string get_program(programContext& context) const;
305  double get_duration() const;
306  SeqValList get_freqvallist(freqlistAction action) const;
307  void query(queryContext& context) const {SeqTreeObj::query(context); context.numof_acqs=1;}
308  RecoValList get_recovallist(unsigned int reptimes, LDRkSpaceCoords& coords) const;
309  unsigned int event(eventContext& context) const;
310  STD_string get_properties() const;
311 
312  private:
313  friend class SeqMethod;
314  friend class SeqEpiDriverParavision;
315  friend class SeqEpiDriverEpic;
316 
317  void common_init();
318 
319 
320  // overwriting virtual functions of SeqFreqChan
321  double get_freqchan_duration() const {return get_acquisition_duration();}
322  STD_string get_driver_instr_label() const {return acqdriver->get_instr_label();}
323 
324 
325  // overwriting virtual functions of SeqClass
326  bool prep();
327 
328 
329  mutable kSpaceCoord kcoord;
330 
331  mutable SeqDriverInterface<SeqAcqDriver> acqdriver;
332 
333  double sweep_width;
334  unsigned int npts;
335  float oversampl;
336  double rel_center;
337  bool reflect_flag;
338  int readoutIndex;
339  int trajIndex;
340  int weightIndex;
341 
342  // safe pointers to vectors to create indices for the ADC
343  // pointer to pointer is used here to avoid delete[] bug in GCC2.9
344  Handler<const SeqVector*>** dimvec;
345 
346  int default_recoindex[n_recoIndexDims];
347 
348 
349 };
350 
354 #endif
virtual bool prep()
Definition: seqclass.h:116
double get_sweepwidth() const
Definition: seqacq.h:295
SeqAcqInterface & set_reflect_flag(bool flag)
Definition: seqacq.h:300
void query(queryContext &context) const
Definition: seqacq.h:307
virtual float get_oversampling() const
Definition: seqacq.h:84
virtual SeqAcqInterface & set_default_reco_index(recoDim dim, unsigned int index)
Definition: seqacq.h:110
virtual double get_sweepwidth() const
Definition: seqacq.h:79
virtual SeqAcqInterface & set_reco_vector(recoDim dim, const SeqVector &vec, const dvector &valvec=dvector())
Definition: seqacq.h:102
virtual double get_acquisition_duration() const
Definition: seqacq.h:46
tjvector< double > dvector
Definition: tjvector.h:451
virtual double get_acquisition_center() const
Definition: seqacq.h:52
Acquisition.
Definition: seqacq.h:206
virtual SeqAcqInterface & set_sweepwidth(double sw, float os_factor)
Definition: seqacq.h:73
virtual void query(queryContext &context) const
double get_acquisition_duration() const
Definition: seqacq.h:290
void marshall_error() const
float get_oversampling() const
Definition: seqacq.h:296
freqlistAction
Definition: seqtree.h:102
virtual SeqAcqInterface & set_reflect_flag(bool flag)
Definition: seqacq.h:124
unsigned int get_npts() const
Definition: seqacq.h:293
virtual SeqAcqInterface & set_readout_shape(const fvector &shape, unsigned int dstsize)
Definition: seqacq.h:91
SeqAcq & set_rel_center(double relative_kspace_center)
Definition: seqacq.h:280
Base class for methods (sequences)
Definition: seqmeth.h:155
double secureDivision(double numerator, double denominator)
templateType
Definition: reco.h:91
recoDim
Definition: reco.h:74
double get_sweep_width() const
Definition: seqacq.h:255
Pre-read dephasing.
Definition: seqacqdeph.h:51
virtual unsigned int get_npts() const
Definition: seqacq.h:65
virtual double get_acquisition_start() const
Definition: seqacq.h:59
double get_acquisition_start() const
Definition: seqacq.h:292
virtual SeqAcqInterface & set_template_type(templateType type)
Definition: seqacq.h:117