libGDF
gdf::Reader Class Reference

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)
RecordgetRecordPtr (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.
EventHeadergetEventHeader ()
 get reference to event header
const GDFHeaderAccessgetHeaderAccess_readonly () const
 get Constant reference to header access
const MainHeadergetMainHeader_readonly () const
 get Constant reference to main header
const SignalHeadergetSignalHeader_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
EventHeaderm_events
std::vector< Record * > m_record_cache
Recordm_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.

Detailed Description

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.

Definition at line 38 of file Reader.h.


Member Function Documentation

double gdf::Reader::getSample ( uint16  channel_idx,
size_t  sample_idx 
)

Read a single Sample (physical units)

Parameters:
[in]channel_idxchannel index
[in]sample_idxsample 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.

Parameters:
[in]channel_idxindex of channel to read
[out]bufferpointer to double array
[in]start_timesamples with n >= start are loaded.
[in]end_timesamples 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.

Parameters:
[out]buffervector; each element is a channel.
[in]start_timesamples with n >= start_time*fs are loaded.
[in]end_timesamples with n < end_time*fs are loaded. end_time = -1 loads the complete signal.
[in]signal_indicesvector 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:


The documentation for this class was generated from the following files:
 All Data Structures Functions Variables Friends