libxdf: Xdf Class Reference

libxdf 0.92 A static C++ library for loading XDF files

Classes | Public Types | Public Member Functions | Public Attributes | List of all members
Xdf Class Reference

`#include <xdf.h>`

## Classes
class | Stream

## Public Types
typedef std::string | eventName
| Used as `std::vector<std::pair<std::pair<eventName, eventTimeStamp>, int> >` in eventMap. More...
typedef float | eventTimeStamp
| Used as `std::vector<std::pair<std::pair<eventName, eventTimeStamp>, int> >` in eventMap. More...

## Public Member Functions
| Xdf ()
| Default constructor with no parameter. More...
void | adjustTotalLength ()
| Adjust `totalLen` to avoid possible deviation. More...
void | calcTotalLength (int sampleRate)
| Calculate the globle length (in samples). More...
void | createLabels ()
| Create labels for each channel and store them in labels vector. More...
void | detrend ()
| Subtract the entire channel by its mean. More...
void | freeUpTimeStamps ()
| Delete the time stamps vectors when no longer needed to release some memory. More...
int | load_xdf (std::string filename)
| The main function of loading an XDF file. More...
void | resample (int userSrate)
| Resample all streams and channel to a chosen sample rate. More...
int | writeEventsToXDF (std::string file_path)
| writeEventsToXDF More...

## Public Attributes
std::vector< Stream > | streams
float | version
uint64_t | totalLen = 0
float | minTS = 0
float | maxTS = 0
size_t | totalCh = 0
int | majSR = 0
int | maxSR = 0
std::vector< int > | streamMap
std::vector< std::pair< std::pair< eventName, eventTimeStamp >, int > > | eventMap
std::vector< std::string > | dictionary
std::vector< uint16_t > | eventType
std::vector< std::string > | labels
std::set< double > | sampleRateMap
std::vector< float > | offsets
std::string | fileHeader
int | userAddedStream { 0 }
std::vector< std::pair< std::string, double > > | userCreatedEvents

## Detailed Description

Xdf class is designed to store the data of an entire XDF file. It comes with methods to read XDF files and containers to store the data, as well as some additional methods e.g. resampling etc.

## Member Typedef Documentation

## § eventName

typedef std::string Xdf::eventName

Used as `std::vector<std::pair<std::pair<eventName, eventTimeStamp>, int> >` in eventMap.

See also
  eventMap

## § eventTimeStamp

typedef float Xdf::eventTimeStamp

Used as `std::vector<std::pair<std::pair<eventName, eventTimeStamp>, int> >` in eventMap.

See also
  eventMap

## Constructor & Destructor Documentation

## § Xdf()

Xdf::Xdf | ( |  | ) |

Default constructor with no parameter.

## Member Function Documentation

## § adjustTotalLength()

void Xdf::adjustTotalLength | ( |  | ) |

Adjust `totalLen` to avoid possible deviation.

`totalLen` is calculated by multiplying the difference between max time stamp and minimal time stamp by the `majSR` (major sample rate). However, this can be inaccurate. In case any channel is longer than `totalLen`, this function will make `totalLen` match the length of that channel.

See also
  totalLen, majSR, calcTotalLength()

## § calcTotalLength()

void Xdf::calcTotalLength | ( | int | sampleRate | ) |

Calculate the globle length (in samples).

This is calculated by multiplying the rage from the earliest time stamp to the last time stamp across all channels by the parameter sampleRate.

Parameters

  sampleRate | is the sample rate you wish to use to calculate the total length.

## § createLabels()

void Xdf::createLabels | ( |  | ) |

Create labels for each channel and store them in labels vector.

See also
  labels, offsets

## § detrend()

void Xdf::detrend | ( |  | ) |

Subtract the entire channel by its mean.

Sigviewer displays both the channel signals as well as the zero baseline. Thus when the mean of a channel is too high or too low it would be very hard to see the fluctuation. Subtract the entire channel by its mean will make the signal fluctuate around the zero baseline, and has better visual effect. The mean of each channel times `-1` will be stored in member vector `offsets`

See also
  offsets

## § freeUpTimeStamps()

void Xdf::freeUpTimeStamps | ( |  | ) |

Delete the time stamps vectors when no longer needed to release some memory.

Sigviewer doesn't demand time stamps to display signals except irregular sample rate channels, events, and the first time stamp of each channel (used to decide where does a channel start when putting all streams together). In this case we can delete the time stamps when no longer needed to free up some memory.

## § load_xdf()

int Xdf::load_xdf | ( | std::string | filename | ) |

The main function of loading an XDF file.

Parameters

  filename | is the path to the file being loaded including the file name.

## § resample()

void Xdf::resample | ( | int | userSrate | ) |

Resample all streams and channel to a chosen sample rate.

Parameters

  userSrate | is recommended to be between integer 1 and the highest sample rate of the current file.

## § writeEventsToXDF()

int Xdf::writeEventsToXDF | ( | std::string | file_path | ) |

writeEventsToXDF

If user added some markups and events in Sigviewer, this function can store those user created events back to the XDF file in a new stream

## Member Data Documentation

## § dictionary

std::vector<std::string> Xdf::dictionary

The vector to store unique event types with no repetitions.

See also
  eventMap

## § eventMap

std::vector<std::pair<std::pair<eventName, eventTimeStamp>, int> > Xdf::eventMap

The vector to store all the events across all streams. The format is <<events, timestamps>, streamNum>.

## § eventType

std::vector<uint16_t> Xdf::eventType

The vector to store events by their index in the dictionary.

See also
  dictionary, eventMap

## § fileHeader

std::string Xdf::fileHeader

Raw XML of the file header.

## § labels

std::vector<std::string> Xdf::labels

The vector to store descriptive labels of each channel.

## § majSR

int Xdf::majSR = 0

The sample rate that has the most channels across all streams.

## § maxSR

int Xdf::maxSR = 0

Highest sample rate across all streams.

## § maxTS

float Xdf::maxTS = 0

The largest time stamp across all streams.

## § minTS

float Xdf::minTS = 0

The smallest time stamp across all streams.

## § offsets

std::vector<float> Xdf::offsets

Offsets of each channel after using subtractMean() function

## § sampleRateMap

std::set<double> Xdf::sampleRateMap

The vector to store all sample rates across all the streams.

## § streamMap

std::vector<int> Xdf::streamMap

A vector indexes which channels belong to which stream. The index is the same as channel number; the actual content is the stream Number

## § streams

std::vector<Stream> Xdf::streams

A vector to store all the streams of the current XDF file.

## § totalCh

size_t Xdf::totalCh = 0

The total number of channel count.

## § totalLen

uint64_t Xdf::totalLen = 0

The total length is the product of the range between the smallest time stamp and the largest multiplied by the major sample rate.

## § userAddedStream

int Xdf::userAddedStream { 0 }

For Sigviewer only: if user manually added events in Sigviewer, the events will be stored in a new stream after all current streams. The index will be userAddedStream.

## § userCreatedEvents

std::vector<std::pair<std::string, double> > Xdf::userCreatedEvents

User created events in Sigviewer.

## § version

float Xdf::version

The version of XDF file

The documentation for this class was generated from the following files:

- C:/Users/Yida Lin/Documents/GitHub/libxdf/libxdf/xdf.h
- C:/Users/Yida Lin/Documents/GitHub/libxdf/libxdf/xdf.cpp