Stimfit @PACKAGE_VERSION@
Loading...
Searching...
No Matches
recording.h
Go to the documentation of this file.
1// This program is free software; you can redistribute it and/or
2// modify it under the terms of the GNU General Public License
3// as published by the Free Software Foundation; either version 2
4// of the License, or (at your option) any later version.
5
6// This program is distributed in the hope that it will be useful,
7// but WITHOUT ANY WARRANTY; without even the implied warranty of
8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9// GNU General Public License for more details.
10
11// You should have received a copy of the GNU General Public License
12// along with this program; if not, write to the Free Software
13// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14
20
21#ifndef _RECORDING_H
22#define _RECORDING_H
23
27
28#include <ctime>
29#include <string>
30#include <string.h> // declaration of memcpy
31#include <vector>
32
33#include "./channel.h"
34// #include "./section.h"
35// #include "./stfio.h"
36
37class Section;
38
40
45 public:
46
47 //ctor/dtor-------------------------------------------------------
49 explicit Recording();
50
52
54 explicit Recording(const Channel& c_Channel);
55
57
59 explicit Recording(const std::deque<Channel>& ChannelList);
60
62
68 explicit Recording( std::size_t c_n_channels, std::size_t c_n_sections = 0, std::size_t c_n_points = 0 );
69
71 virtual ~Recording();
72
73 //member access functions: read-----------------------------------
74
76
79 std::size_t GetChannelSize(std::size_t n_channel) const;
80
82
84 const std::deque<Channel>& get() const { return ChannelArray; }
85
87
89 std::deque<Channel>& get() { return ChannelArray; }
90
92
94 const std::string& GetFileDescription() const { return file_description; }
95
97
99 const std::string& GetGlobalSectionDescription() const { return global_section_description; }
100
102
104 const std::string& GetScaling() const { return scaling; }
105
107
109 struct tm GetDateTime() const { return datetime; };
110
112
114 const std::string& GetComment() const { return comment; }
115
117
119 const std::string& GetXUnits() const { return xunits; }
120
122
124 std::size_t size() const { return ChannelArray.size(); }
125
127
129 double GetXScale() const { return dt; }
130
132
134 double GetSR() const { return 1.0/dt; }
135
137
139 std::size_t GetCurChIndex() const { return cc; }
140
142
144 std::size_t GetSecChIndex() const { return sc; }
145
147
149 std::size_t GetCurSecIndex() const { return cs; }
150
152
154 const std::vector<std::size_t>& GetSelectedSections() const { return selectedSections; }
155
157
159 std::vector<std::size_t>& GetSelectedSectionsW() { return selectedSections; }
160
162
164 const Vector_double& GetSelectBase() const { return selectBase; }
165
167
169 Vector_double& GetSelectBaseW() { return selectBase; }
170
172
174 const Section& cursec() const { return (*this)[cc][cs]; }
175
177
179 Section& cursec() { return (*this)[cc][cs]; }
180
182
184 const Section& secsec() const { return (*this)[sc][cs]; }
185
187
189 const Channel& curch() const { return (*this)[cc]; }
190
192
194 Channel& curch() { return (*this)[cc]; }
195
197
199 const Channel& secch() const { return (*this)[sc]; }
200
202
206 const Channel& at(std::size_t n_c) const;
207
209
213 Channel& at(std::size_t n_c);
214
215 //member access functions: write---------------------------------
216
218
220 void SetFileDescription(const std::string& value) { file_description=value; }
221
223
225 void SetGlobalSectionDescription(const std::string& value) {
226 global_section_description=value;
227 }
228
230
232 void SetScaling(const std::string& value) { scaling=value; }
233
235
238 int SetTime(const std::string& value);
239 int SetTime(int hour, int minute, int sec);
240
242
245 int SetDate(const std::string& value);
246 int SetDate(int year, int month, int mday);
247
249
251 void SetDateTime(const struct tm &value) { memcpy(&datetime, &value, sizeof(struct tm)); }
252 void SetDateTime(int year, int month, int mday, int hour, int minute, int sec) ;
253
255
257 void SetComment(const std::string& value) { comment=value; }
258
260
263 void SetGlobalYUnits(std::size_t n_channel, const std::string& value);
264
266
268 void SetXUnits(const std::string& value) { xunits=value; }
269
271
274 void SetXScale(double value);
275
277
279 void SetCurChIndex(std::size_t value);
280
282
284 void SetSecChIndex(std::size_t value);
285
287
289 void SetCurSecIndex(std::size_t value);
290
291 //misc-----------------------------------------------------------
292
294
297 virtual void resize(std::size_t c_n_channels);
298
300
304 virtual void InsertChannel(Channel& c_Channel, std::size_t pos);
305
307
311 void CopyAttributes(const Recording& c_Recording);
312
314
327 void MakeAverage( Section& AverageReturn, Section& SigReturn, std::size_t channel,
328 const std::vector<std::size_t>& section_index, bool isSig,
329 const std::vector<int>& shift) const;
330
332
334 void AddRec(const Recording& toAdd);
335
337
341 void SelectTrace(std::size_t sectionToSelect, std::ptrdiff_t base_start, std::ptrdiff_t base_end);
342
344
347 bool UnselectTrace(std::size_t sectionToUnselect);
348
349 //operators------------------------------------------------------
350
352
355 Channel& operator[](std::size_t at) { return ChannelArray[at]; }
356
358
361 const Channel& operator[](std::size_t at) const { return ChannelArray[at]; }
362
364 std::string GetEventDescription(int type);
365
367 void SetEventDescription(int type, const char* Description);
368
371
373 int GetSectionType(size_t section_number);
374
376 void SetSectionType(size_t section_number, int type);
377
378 private:
379 std::deque<Channel> ChannelArray;
380 std::string global_section_description, scaling;
381
382 /* public: */
383
384 double dt;
385 std::string file_description, comment, xunits;
386 struct tm datetime;
387
388
389 // currently accessed channel:
390 std::size_t cc;
391 // second channel:
392 std::size_t sc;
393 // currently accessed section:
394 std::size_t cs;
395
396 // Indices of the selected sections
397 std::vector<std::size_t> selectedSections;
398 // Base line value for each selected trace
399 Vector_double selectBase;
400
401 // defined when data is loaded
402 const char* listOfMarkers[256];
403
404 /* SectionMarker contains, for each section, it's type
405 as defined event table.
406 currently only one event type per segment is supported.
407 */
408 std::vector<int> sectionMarker;
409
410 void init();
411
412};
413
415
416#endif
WORD TpMarker int n
Definition Son.h:353
short channel
Definition cfs.h:173
Declares the Channel class.
A Channel contains several data Sections representing observations of the same physical quantity.
Definition channel.h:34
Represents a continuously sampled sweep of data points.
Definition section.h:36
std::vector< double > Vector_double
Definition core.h:55
#define StfioDll
Defines dll export or import functions for Windows.
Definition core.h:49
virtual void resize(std::size_t c_n_channels)
Resize the Recording to a new number of channels.
void SetGlobalYUnits(std::size_t n_channel, const std::string &value)
Sets the y units for a channel.
void InitSectionMarkerList(size_t n)
Initialize List of Section Markers.
void SetEventDescription(int type, const char *Description)
Set Description of Event Type.
void SetFileDescription(const std::string &value)
Sets the file description.
Definition recording.h:220
const Section & cursec() const
Retrieves the currently accessed section in the active channel (read-only)
Definition recording.h:174
const std::string & GetFileDescription() const
Retrieves the file description.
Definition recording.h:94
Recording()
Default constuctor.
void SetCurSecIndex(std::size_t value)
Sets the index of the current section.
std::size_t GetChannelSize(std::size_t n_channel) const
Retrieves the number of sections in a channel.
const Vector_double & GetSelectBase() const
Retrieves the stored baseline values of the selected sections (read-only).
Definition recording.h:164
Recording(std::size_t c_n_channels, std::size_t c_n_sections=0, std::size_t c_n_points=0)
Constructor.
const Channel & operator[](std::size_t at) const
Unchecked channel access (read-only)
Definition recording.h:361
int SetTime(int hour, int minute, int sec)
std::size_t size() const
Retrieves the size of the channel array.
Definition recording.h:124
const Channel & secch() const
Retrieves the second (reference) channel (read-only)
Definition recording.h:199
void SetDateTime(int year, int month, int mday, int hour, int minute, int sec)
Recording(const std::deque< Channel > &ChannelList)
Constructor.
std::vector< std::size_t > & GetSelectedSectionsW()
Retrieves the indices of the selected sections (read and write).
Definition recording.h:159
Section & cursec()
Retrieves the currently accessed section in the active channel (read and write)
Definition recording.h:179
std::string GetEventDescription(int type)
Get Description of Event Type.
void SetScaling(const std::string &value)
Sets the scaling as a string.
Definition recording.h:232
const Section & secsec() const
Retrieves the currently accessed section in the second (reference) channel (read-only)
Definition recording.h:184
void SetXScale(double value)
Sets the x scaling.
void SetSecChIndex(std::size_t value)
Sets the index of the second channel.
Channel & operator[](std::size_t at)
Unchecked channel access (read and write)
Definition recording.h:355
int SetDate(int year, int month, int mday)
std::size_t GetSecChIndex() const
Retrieves the index of the second channel.
Definition recording.h:144
void MakeAverage(Section &AverageReturn, Section &SigReturn, std::size_t channel, const std::vector< std::size_t > &section_index, bool isSig, const std::vector< int > &shift) const
Calculates an average of several traces.
void SetCurChIndex(std::size_t value)
Sets the index of the current channel.
double GetXScale() const
Retrieves the x scaling (sampling interval).
Definition recording.h:129
const std::string & GetScaling() const
Retrieves the scaling as a string.
Definition recording.h:104
int SetDate(const std::string &value)
Sets the date of recording as a string.
Channel & curch()
Retrieves active channel (read and write)
Definition recording.h:194
void AddRec(const Recording &toAdd)
Add a Recording at the end of this Recording.
void SetGlobalSectionDescription(const std::string &value)
Sets the common section description.
Definition recording.h:225
const std::string & GetComment() const
Retrieves a comment string.
Definition recording.h:114
Vector_double & GetSelectBaseW()
Retrieves the stored baseline values of the selected sections (read and write).
Definition recording.h:169
void SetDateTime(const struct tm &value)
Sets the date and time of recording as struct tm.
Definition recording.h:251
Channel & at(std::size_t n_c)
Range-checked access to a channel (read and write).
virtual void InsertChannel(Channel &c_Channel, std::size_t pos)
Insert a Channel at a given position.
void SetSectionType(size_t section_number, int type)
Set Type of Section.
void SetComment(const std::string &value)
Sets a comment string.
Definition recording.h:257
std::size_t GetCurSecIndex() const
Retrieves the index of the current section.
Definition recording.h:149
const Channel & at(std::size_t n_c) const
Range-checked access to a channel (read-only).
void SelectTrace(std::size_t sectionToSelect, std::ptrdiff_t base_start, std::ptrdiff_t base_end)
Selects a section.
int SetTime(const std::string &value)
Sets the time of recording as a string.
Recording(const Channel &c_Channel)
Constructor.
int GetSectionType(size_t section_number)
Get Type of Section.
void SetXUnits(const std::string &value)
Sets the x units.
Definition recording.h:268
const std::vector< std::size_t > & GetSelectedSections() const
Retrieves the indices of the selected sections (read-only).
Definition recording.h:154
std::size_t GetCurChIndex() const
Retrieves the index of the current channel.
Definition recording.h:139
void CopyAttributes(const Recording &c_Recording)
Copy descriptive attributes from another Recording to this Recording.
const Channel & curch() const
Retrieves the active channel (read-only)
Definition recording.h:189
bool UnselectTrace(std::size_t sectionToUnselect)
Unselects a section if it was selected before.
struct tm GetDateTime() const
Retrieves the date of recording as a string.
Definition recording.h:109
std::deque< Channel > & get()
Retrieves the channels (read and write).
Definition recording.h:89
virtual ~Recording()
Destructor.
const std::string & GetGlobalSectionDescription() const
Retrieves the common section description.
Definition recording.h:99
double GetSR() const
Retrieves the sampling rate ( 1 / x-scale )
Definition recording.h:134
const std::deque< Channel > & get() const
Retrieves the channels (read-only).
Definition recording.h:84
const std::string & GetXUnits() const
Retrieves the x units.
Definition recording.h:119