JEMRIS  2.8.1
open-source MRI simulations
TPOI.h
Go to the documentation of this file.
1 
5 /*
6  * JEMRIS Copyright (C)
7  * 2006-2015 Tony Stoecker
8  * 2007-2015 Kaveh Vahedipour
9  * 2009-2015 Daniel Pflugfelder
10  *
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  */
26 
27 #ifndef TPOI_H_
28 #define TPOI_H_
29 
30 #include <cstdlib>
31 #include <vector>
32 #include <ostream>
33 #include <iostream>
34 #include <bitset>
35 #include <cmath>
36 
37 using namespace std;
38 
39 #include "Declarations.h"
40 
41 //const double TIME_ERR_TOL = 1e-6; // Avoid CVODE warnings. Doesn't affect physics.
42 
44 
45 template<class T> inline T
46 BIT (const T& x) { return T(1) << x; }
47 
48 static const size_t JTPOI_T (0);
49 static const size_t ADC_T (1);
50 static const size_t EXCITE_T (2);
51 static const size_t REFOCUS_T (3);
52 
53 template<class T, class S> inline bool
54 check_bit (const T& x, const S& y) { return 0 != (x & BIT(y)); }
55 
56 template<class T, class S> inline void
57 set_bit (T& x, const S& y) { x |= T(1) << y; }
58 
59 
60 class TPOI {
61 
62  public:
63 
65  struct set {
66 
67 
68  double dtime;
69  double dphase;
70  size_t bmask;
78  inline set (const double time, const double phase = -1.,
79  const size_t mask = 0) : dtime(time), dphase (phase), bmask(mask) {}
80 
81  };
82 
89  TPOI() {
90  // Reset my data repository
91  Reset();
92  };
93 
94 
98  void Reset () {
99  // Set position back to first slot and values to zero
100  m_time.clear();
101  m_phase.clear();
102  m_mask.clear();
103  }
104 
110  ~TPOI() {}
111 
112 
120  void operator += (const TPOI& tpoi);
121 
130  TPOI& operator + (const TPOI& tpoi);
131 
138  void operator + (const set& data);
139 
145  int GetSize () const ;
146 
147 
148  void Print (std::ostream& os) const {
149  for (size_t i = 0; i < m_time.size(); ++i)
150  os << m_time[i] << "\t" << m_phase[i] << "\t" << m_mask[i] << std::endl;
151  os << std::endl;
152  }
153 
160  inline double GetTime (const size_t pos) const {return m_time[pos]; }
161 
168  inline double GetPhase (const size_t pos) const {return m_phase[pos]; }
169 
170  bool IsADC (const size_t pos) {return check_bit (m_mask[pos], 0); }
171  bool IsExcitation (const size_t pos) {return check_bit (m_mask[pos], 1); }
172  bool IsRefocussing (const size_t pos) {return check_bit (m_mask[pos], 2); }
173 
174  inline size_t GetMask (const size_t pos) const {return m_mask[pos];}
175 
179  void Sort ();
180 
184  void Purge ();
185 
186  private:
187 
188  vector<double> m_time;
189  vector<double> m_phase;
190  vector<size_t> m_mask;
192 };
193 
194 
195 
196 inline std::ostream& operator<< (std::ostream& os, const TPOI& tpoi) {
197  tpoi.Print(os);
198  return os;
199 }
200 
201 #endif
Implementation of JEMRIS Declarations.
double dphase
Definition: TPOI.h:69
double dtime
Definition: TPOI.h:68
vector< double > m_time
Definition: TPOI.h:188
Definition: TPOI.h:60
The set of data of each time point of interest.
Definition: TPOI.h:65
size_t bmask
Definition: TPOI.h:70
double GetTime(const size_t pos) const
Definition: TPOI.h:160
TPOI()
Definition: TPOI.h:89
double GetPhase(const size_t pos) const
Definition: TPOI.h:168
vector< size_t > m_mask
Definition: TPOI.h:190
T BIT(const T &x)
Time points of interest of all modules.
Definition: TPOI.h:46
vector< double > m_phase
Definition: TPOI.h:189
~TPOI()
Definition: TPOI.h:110
void Reset()
Definition: TPOI.h:98

-- last change 17.06.2016 | Tony Stoecker | Imprint --