|
libGDF
|
Class for reading GDF files to disc. More...
#include <Reader.h>
Inheritance diagram for gdf::Reader:
Collaboration diagram for gdf::Reader:Public Member Functions | |
| Reader () | |
| Constructor. | |
| virtual | ~Reader () |
| Destructor. | |
| void | open (const std::string filename) |
| Opens file for reading. | |
| void | close () |
| Close file. | |
| void | enableCache (bool b) |
| Enable or disable cache. | |
| virtual void | initCache () |
| Set cache to the correct size. | |
| virtual void | resetCache () |
| Reset cache to empty state. | |
| size_t | findRecord (uint16 channel_idx, size_t sample_idx) |
| Find Record index to which a sample belongs. | |
| void | getSignals (std::vector< std::vector< double > > &buffer, double start_time=0, double end_time=-1, std::vector< uint16 > signal_indices=std::vector< uint16 >()) |
| Read Signals from file into buffer (physical units) | |
| void | getSignal (uint16 channel_idx, double *buffer, size_t start=0, size_t end=0) |
| Read a single channel from file into buffer. | |
| double | getSample (uint16 channel_idx, size_t sample_idx) |
| Read a single Sample (physical units) | |
| Record * | getRecordPtr (size_t index) |
| Returns a reference to Record. | |
| void | readRecord (size_t index, Record *rec) |
| Read directly into Record rec. | |
| void | precacheRecords (size_t start, size_t end) |
| Precache a range of Records. | |
| EventHeader * | getEventHeader () |
| get reference to event header | |
| const GDFHeaderAccess & | getHeaderAccess_readonly () const |
| get Constant reference to header access | |
| const MainHeader & | getMainHeader_readonly () const |
| get Constant reference to main header | |
| const SignalHeader & | getSignalHeader_readonly (size_t idx) const |
| get constant reference to a signal's header | |
Protected Member Functions | |
| void | readEvents () |
Protected Attributes | |
| std::string | m_filename |
| GDFHeaderAccess | m_header |
| EventHeader * | m_events |
| std::vector< Record * > | m_record_cache |
| Record * | m_record_nocache |
| std::list< size_t > | m_cache_entries |
| std::ifstream | m_file |
| bool | m_cache_enabled |
| size_t | m_record_length |
| size_t | m_record_offset |
| Record length in bytes. | |
| size_t | m_event_offset |
| Where data records start in the file. | |
Class for reading GDF files to disc.
Data Records are only read on demand and stay in memory until another file is opened or the Reader object is destroyed. This cache can be disabled. Then each data record is loaded from disk everytime it is accessed. This saves memory, but may severly decrease performance.
| double gdf::Reader::getSample | ( | uint16 | channel_idx, |
| size_t | sample_idx | ||
| ) |
Read a single Sample (physical units)
| [in] | channel_idx | channel index |
| [in] | sample_idx | sample index |
Reimplemented in gdf::Modifier.
Definition at line 223 of file Reader.cpp.
Here is the call graph for this function:| void gdf::Reader::getSignal | ( | uint16 | channel_idx, |
| double * | buffer, | ||
| size_t | start = 0, |
||
| size_t | end = 0 |
||
| ) |
Read a single channel from file into buffer.
The buffer must be allocated by the user, who is also responsible that enough memory is allocated.
| [in] | channel_idx | index of channel to read |
| [out] | buffer | pointer to double array |
| [in] | start_time | samples with n >= start are loaded. |
| [in] | end_time | samples with n < end are loaded. end <= start loads the complete signal. |
Definition at line 192 of file Reader.cpp.
Here is the call graph for this function:| void gdf::Reader::getSignals | ( | std::vector< std::vector< double > > & | buffer, |
| double | start_time = 0, |
||
| double | end_time = -1, |
||
| std::vector< uint16 > | signal_indices = std::vector<uint16>() |
||
| ) |
Read Signals from file into buffer (physical units)
Sample values are converted to physical units.
| [out] | buffer | vector; each element is a channel. |
| [in] | start_time | samples with n >= start_time*fs are loaded. |
| [in] | end_time | samples with n < end_time*fs are loaded. end_time = -1 loads the complete signal. |
| [in] | signal_indices | vector with signal indices that should be loaded. If empty, all signals are loaded. |
Definition at line 136 of file Reader.cpp.
Here is the call graph for this function: