JEMRIS 2.9.2
open-source MRI simulations
Loading...
Searching...
No Matches
Signal.h
Go to the documentation of this file.
1
5/*
6 * JEMRIS Copyright (C)
7 * 2006-2025 Tony Stoecker
8 * 2007-2018 Kaveh Vahedipour
9 * 2009-2019 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 SIGNAL_H_
28#define SIGNAL_H_
29
30#include "rng.h"
31
32#include <string>
33#include <assert.h>
34using namespace std;
35
36
40struct Repository {
41
43 int m_noofcompartments;
44 std::vector<double> m_times;
45 std::vector<double> m_data;
52
53 m_noofcompartments = 1;
54 m_noofsamples = 0;
55
56 };
57
58
63 }
64
65
71 long Size() {
72
73 return m_noofsamples * (long) NProps();
74
75 };
76
77
83 double* Data () {
84
85 return &m_data[0];
86
87 };
88
89
95 double* Times () {
96
97 return &m_times[0];
98
99 };
100
101
107 inline const long Samples () const {
108
109 return m_noofsamples;
110
111 };
112
113
119 inline const int Compartments () const {
120
121 return m_noofcompartments;
122
123 };
124
125
131 inline const int NProps () const {
132
133 return 3 * m_noofcompartments;
134
135 };
136
137
143 inline const double TP (long l) const {
144
145 return m_times[l];
146
147 };
148
149
155 inline double& TP (long l) {
156
157 return m_times[l];
158
159 };
160
161
165 inline const long Position (long l) const {
166
167 return l*NProps();
168
169 };
170
171
175 inline const void Initialize (long samples, int compartments) {
176
177 assert (samples);
178 assert (compartments);
179
180 m_noofcompartments = compartments;
181 m_noofsamples = samples;
182
183 m_data.resize(Size());
184 m_times.resize(Samples());
185
186 };
187
188
194 inline double
195 &operator[] (long pos) {
196
197 assert(pos >= 0);
198 assert(pos < Size());
199
200 return m_data[pos];
201
202 };
203
209 inline const double
210 operator[] (long pos) const {
211
212 return m_data[pos];
213
214 };
215
221 inline double&
222 at (long pos) {
223
224 assert(pos >= 0);
225 assert(pos < Size());
226
227 return m_data[pos];
228
229 };
230
236 inline const double
237 at (long pos) const {
238
239 return m_data[pos];
240
241 };
242
243
244};
245
249class Signal {
250
251
252 public:
253
254
258 Signal () {};
259
260
264 ~Signal () {};
265
266
272 Signal (long size);
273
274
281 Signal (long size, int compartments);
282
288 void ReadFrom (char* fname);
289
290
296 const long GetSize() {
297 return m_repository.Samples();
298 };
299
300
307 return &m_repository;
308 };
309
310
316 void InitRandGenerator (int val=1) {
317 m_rng = RNG( val * (long ) clock() );
318 };
319
325 RNG* Noise () {
326 return &m_rng;
327 };
328
329private:
330
331 RNG m_rng;
334};
335
336#endif /*SIGNAL_H_*/
The signal store and IO.
Definition Signal.h:249
const long GetSize()
Definition Signal.h:296
void ReadFrom(char *fname)
Definition Signal.cpp:55
Signal()
Default constructor.
Definition Signal.h:258
void InitRandGenerator(int val=1)
Definition Signal.h:316
Repository m_repository
Signal repository
Definition Signal.h:332
RNG m_rng
random number generator
Definition Signal.h:331
RNG * Noise()
Definition Signal.h:325
~Signal()
Default destructor.
Definition Signal.h:264
Repository * Repo()
Definition Signal.h:306
Signal repository structure.
Definition Signal.h:40
const double TP(long l) const
Time of given sample index.
Definition Signal.h:143
const void Initialize(long samples, int compartments)
Occupy RAM and set some dimensions.
Definition Signal.h:175
~Repository()
Destruct.
Definition Signal.h:62
long Size()
Size of bulk data (i.e. number of elemments of m_data)
Definition Signal.h:71
long m_noofsamples
Definition Signal.h:42
std::vector< double > m_times
Definition Signal.h:44
double * Data()
Reference to data repository.
Definition Signal.h:83
const long Position(long l) const
Reference to data of given sample index.
Definition Signal.h:165
const long Samples() const
Number of samples.
Definition Signal.h:107
std::vector< double > m_data
Definition Signal.h:45
double & TP(long l)
Reference to time of given sample index.
Definition Signal.h:155
double & at(long pos)
Value at position in store.
Definition Signal.h:222
double & operator[](long pos)
Value at position in store.
Definition Signal.h:195
Repository()
Construct.
Definition Signal.h:51
const double at(long pos) const
Access to position in store.
Definition Signal.h:237
double * Times()
Reference to time point repository.
Definition Signal.h:95
const int Compartments() const
Number of compartments.
Definition Signal.h:119
const int NProps() const
Number of properties per compartment.
Definition Signal.h:131

-- last change 03.01.2025 | Tony Stoecker | Imprint | Data Protection --