|
libGDF
|
Class for writing GDF files to disc. More...
#include <Writer.h>
Inheritance diagram for gdf::Writer:
Collaboration diagram for gdf::Writer:Public Member Functions | |
| Writer () | |
| Constructor. | |
| virtual | ~Writer () |
| Destructor. | |
| void | open (const int flags=writer_ev_file) |
| Opens file for writing and writes Header. | |
| void | open (const std::string filename, const int flags=writer_ev_file) |
| Opens file for writing and writes Header. | |
| void | close () |
| Close file. | |
| bool | isOpen () |
| Check if file is open. | |
| void | setFilename (std::string filename) |
| set filename for later opening | |
| void | setMaxFullRecords (size_t num) |
| Set number of full records that are kept in memory before the buffer is flushed. | |
| bool | createSignal (size_t index, bool throwexc=false) |
| Create a signal. | |
| void | swapSignals (size_t a, size_t b) |
| Swap to signals. | |
| void | relocateSignal (size_t src, size_t dst) |
| Change signal index. | |
| size_t | getFirstFreeSignalIndex () |
| get lowest signal index that can be created | |
| void | blitFromSerialBufferPhys (const double *buf, const std::vector< size_t > &samples_per_channel) |
| Blit data from a serial buffer. | |
| void | addSamplePhys (const size_t channel_idx, const float64 value) |
| Add sample in physical units to a channel. | |
| template<typename T > | |
| void | addSampleRaw (const size_t channel_idx, const T value) |
| Add a raw sample to channel. | |
| void | blitSamplesPhys (const size_t channel_idx, const float64 *values, size_t num) |
| Blit a number of samples in physical units to channel. | |
| void | blitSamplesPhys (const size_t channel_idx, const std::vector< float64 > &values) |
| Blit a number of samples in physical units to channel. | |
| template<typename T > | |
| void | blitSamplesRaw (const size_t channel_idx, const T *values, size_t num) |
| Blit a number of raw samples to channel. | |
| template<typename T > | |
| void | blitSamplesRaw (const size_t channel_idx, const std::vector< T > &values) |
| Blit a number of raw samples to channel. | |
| void | addRecord (Record *r) |
| Add a complete Record. | |
| Record * | acquireRecord () |
| Get pointer to a fresh Record. | |
| void | writeRecordDirect (Record *r) |
| writes record to disc | |
| void | flush () |
| writes all full records from buffer to disc | |
| void | setEventMode (uint8 mode) |
| Set Event Mode. | |
| void | setEventSamplingRate (float32 fs=-1) |
| Set Sampling Rate associated with event positions. | |
| void | addEvent (const Mode1Event &ev) |
| Add a Mode 1 Event. | |
| void | addEvent (uint32 position, uint16 type) |
| Add a Mode 1 Event. | |
| void | addEvent (const Mode3Event &ev) |
| Add a Mode 3 Event. | |
| void | addEvent (uint32 position, uint16 type, uint16 channel, uint32 duration) |
| Add a Mode 3 Event. | |
| void | addEvent (uint32 position, uint16 type, uint16 channel, float32 value) |
| Add a Mode 3 Event. | |
| const GDFHeaderAccess & | getHeaderAccess_readonly () const |
| get Constant reference to header access | |
| GDFHeaderAccess & | getHeaderAccess () |
| get reference to main header | |
| const MainHeader & | getMainHeader_readonly () const |
| get Constant reference to main header | |
| MainHeader & | getMainHeader () |
| get reference to main header | |
| const SignalHeader & | getSignalHeader_readonly (size_t idx) const |
| get constant reference to a signal's header | |
| size_t | getNumSignals () const |
| SignalHeader & | getSignalHeader (size_t idx) |
| get reference to a signal's header | |
Class for writing GDF files to disc.
Events are buffered and appended to the file when calling close( ). By default events are buffered in a separate file named filename.events. Thus, information may be recovered after computer crashes during long online recordings. The user may chose to buffer events in memory instead (see open()).
| void gdf::Writer::addSamplePhys | ( | const size_t | channel_idx, |
| const float64 | value | ||
| ) |
Add sample in physical units to a channel.
The sample value is converted from the channels [physmin,physmax] to the range of [digmin,digmax] and then cast to the correct data type.
| [in] | channel_idx | index of the channel written to |
| [in] | value | sample value in physical units |
Definition at line 249 of file Writer.cpp.
Here is the call graph for this function:| void gdf::Writer::addSampleRaw | ( | const size_t | channel_idx, |
| const T | value | ||
| ) | [inline] |
Add a raw sample to channel.
The sample value is cast to the correct data type, but no range checking is performed
| [in] | channel_idx | index of the channel written to |
| [in] | value | raw sample value in physical units |
Definition at line 140 of file Writer.h.
Here is the call graph for this function:| void gdf::Writer::blitFromSerialBufferPhys | ( | const double * | buf, |
| const std::vector< size_t > & | samples_per_channel | ||
| ) |
Blit data from a serial buffer.
Instead of streaming samples as they come, the complete data is provided in an array of type double. In the buffer channels have to be arranged sequentially. I.e. all samples from channel 1 are followed by all samles from channel 2, and so on. This function attempts to keep memory overhead low by filling record by record whenever possible.
| [in] | buf | Buffer |
| [in] | samples_per_channel | A vector containing the number of samples in each channel. |
Definition at line 218 of file Writer.cpp.
Here is the call graph for this function:| void gdf::Writer::blitSamplesPhys | ( | const size_t | channel_idx, |
| const float64 * | values, | ||
| size_t | num | ||
| ) |
Blit a number of samples in physical units to channel.
The sample values are converted from the channels [physmin,physmax] to the range of [digmin,digmax] and then cast to the correct data type.
| [in] | channel_idx | index of the channel written to |
| [in] | values | array of sample values in physical units |
| [in] | num | number of samples to blit |
Definition at line 259 of file Writer.cpp.
Here is the call graph for this function:| void gdf::Writer::blitSamplesPhys | ( | const size_t | channel_idx, |
| const std::vector< float64 > & | values | ||
| ) |
Blit a number of samples in physical units to channel.
The sample values are converted from the channels [physmin,physmax] to the range of [digmin,digmax] and then cast to the correct data type.
| [in] | channel_idx | index of the channel written to |
| [in] | values | vector of sample values in physical units |
Definition at line 269 of file Writer.cpp.
Here is the call graph for this function:| void gdf::Writer::blitSamplesRaw | ( | const size_t | channel_idx, |
| const T * | values, | ||
| size_t | num | ||
| ) | [inline] |
Blit a number of raw samples to channel.
The sample values are cast to the correct data type, but no range checking is performed
| [in] | channel_idx | index of the channel written to |
| [in] | values | array of raw sample value |
| [in] | num | number of samples to blit |
Definition at line 171 of file Writer.h.
Here is the call graph for this function:| void gdf::Writer::blitSamplesRaw | ( | const size_t | channel_idx, |
| const std::vector< T > & | values | ||
| ) | [inline] |
Blit a number of raw samples to channel.
The sample values are cast to the correct data type, but no range checking is performed
| [in] | channel_idx | index of the channel written to |
| [in] | values | vector of raw sample value |
Definition at line 182 of file Writer.h.
Here is the call graph for this function:| void gdf::Writer::close | ( | ) |
Close file.
File is closed if open. Prior to closing, events are written to the file.
Definition at line 122 of file Writer.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| bool gdf::Writer::createSignal | ( | size_t | index, |
| bool | throwexc = false |
||
| ) |
Create a signal.
Signals have to be created before they can be configured and stored.
| [in] | index | index of the signal |
| [in] | throwexc | if true, exception::signal_exists may be thrown |
Definition at line 186 of file Writer.cpp.
| void gdf::Writer::open | ( | const int | flags = writer_ev_file | ) |
Opens file for writing and writes Header.
Prior to opening the file, GDFHeaderAccess::sanitize() is called. Exceptions thrown by GDFHeaderAccess::sanitize() are checked if there are errors and/or warnings. In the presence of errors the exception is forwarded immediately, and in case of warnings the file is opened but the exception is still forwarded. If the file exists, it is not opened unless the file_overwrite flag is set.
| [in] | flags | Flags... |
| exception::header_issues | |
| exception::file_exists |
Definition at line 47 of file Writer.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void gdf::Writer::open | ( | const std::string | filename, |
| const int | flags = writer_ev_file |
||
| ) |
Opens file for writing and writes Header.
Convenience function. Calls setFilename prior to opening the file
| [in] | filename | Full path name to the file. |
| [in] | flags | Flags... |
| exception::header_issues | |
| exception::file_exists |
Definition at line 113 of file Writer.cpp.
Here is the call graph for this function:| void gdf::Writer::relocateSignal | ( | size_t | src, |
| size_t | dst | ||
| ) |
Change signal index.
The new index must not exist
| [in] | src | old index of first signal |
| [in] | dst | new index of second signal |
Definition at line 202 of file Writer.cpp.
| void gdf::Writer::setEventMode | ( | uint8 | mode | ) |
Set Event Mode.
mode can be 1 or 3 1: (default) Events are stored as position,type pairs 3: Events are stored with position and type, associated to a channel and have a duration or value.
| [in] | mode | event mode |
Definition at line 334 of file Writer.cpp.
Here is the call graph for this function:| void gdf::Writer::setEventSamplingRate | ( | float32 | fs = -1 | ) |
Set Sampling Rate associated with event positions.
Events are not actually sampled, but their position is stored in samples rather than seconds. In order to convert event positions between time and sample, this sampling rate is used. If Sampling rate is not set (or set to <= 0 ), fs is set to the highest signal sampling rate.
| [in] | fs | sampling rate |
Definition at line 344 of file Writer.cpp.
Here is the call graph for this function:| void gdf::Writer::setFilename | ( | std::string | filename | ) |
set filename for later opening
| [in] | filename | Full path name to the file |
Definition at line 170 of file Writer.cpp.
Here is the caller graph for this function:| void gdf::Writer::setMaxFullRecords | ( | size_t | num | ) |
Set number of full records that are kept in memory before the buffer is flushed.
| [in] | num | number of records |
Definition at line 178 of file Writer.cpp.
Here is the caller graph for this function:| void gdf::Writer::swapSignals | ( | size_t | a, |
| size_t | b | ||
| ) |
Swap to signals.
Both signals must exist.
| [in] | a | index of first signal |
| [in] | b | index of second signal |
Definition at line 194 of file Writer.cpp.