diff --git a/README.md b/README.md index e94b609..7a50263 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Introduction -Libxdf is a cross-platform C++ library for loading multimodal, multi-rate signals stored in [XDF](https://github.com/sccn/xdf/wiki/Specifications "Extensible Data Format") files. +Libxdf is a cross-platform C++ library for loading multi-modal, multi-rate signals stored in [XDF](https://github.com/sccn/xdf/wiki/Specifications "Extensible Data Format") files. Libxdf is used in the biosignal viewing application [SigViewer](https://github.com/cbrnr/sigviewer). It can also be integrated into other C++ applications. @@ -57,35 +57,32 @@ Example: ```C++ #include "xdf.h" -Xdf XDFdata; -XDFdata.load_xdf("C:/example.xdf"); +Xdf xdf; +xdf.load_xdf("C:/example.xdf"); ``` -To resample the signals to e.g. 100Hz: +To resample the signals, e.g. to 100Hz: ```C++ -XDFdata.resample(100); +xdf.resample(100); ``` -The functions in libxdf must be called following a certain order. For instance, if you call the `subtractMean` function before you load any data, it will cause undefined behavior. +The methods in libxdf must be called following a certain order. For instance, if you call the `detrend` method before you load any data, it will cause undefined behavior. The recommended order is shown here. Only `load_xdf` is mandatory. ```C++ -XDFdata.load_xdf(std::string filepath); -XDFdata.subtractMean(); -XDFdata.createLabels(); -XDFdata.resample(int sampleRate); -XDFdata.freeUpTimeStamps(); +xdf.load_xdf(std::string filepath); +xdf.detrend(); +xdf.create_labels(); +xdf.resample(int sampling_rate); +xdf.free_up_time_stamps(); ``` Libxdf depends on third party libraries [Pugixml v1.8](http://pugixml.org/) for XML parsing and [Smarc](http://audio-smarc.sourceforge.net/) for resampling. ## Documentation -Detailed documentation was generated via [Doxygen](http://www.stack.nl/~dimitri/doxygen/index.html) and is available [here](docs/html/class_xdf.html). - -## SigViewer Online Repo -SigViewer Online Repository is [here](repository/Updates.xml). +[Documentation](docs/html/class_xdf.html) was generated via [Doxygen](http://www.stack.nl/~dimitri/doxygen/index.html). ## Support diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 1796cb7..75b3253 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -1,21 +1,14 @@ - +
- + -This is the complete list of members for Xdf, including all inherited members.
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... | |
typedef std::string | event_name_ |
An alias of std::string type used on event names. More... | |
typedef double | event_timestamp_ |
An alias of double type used on event timestamps. More... | |
Public Member Functions | |
Xdf () | |
Default constructor with no parameter. More... | |
+ | Xdf () |
Default constructor with no parameter. | |
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 | adjust_total_length () |
Adjusts total_len_ to avoid possible deviation. More... | |
void | calculate_total_length (int sampling_rate) |
Calculates the global length (in samples). More... | |
void | create_labels () |
Creates labels for each channel and stores them in labels_ . More... | |
void | detrend () |
Subtract the entire channel by its mean. More... | |
Subtracts all data in a channel by the mean. More... | |
void | freeUpTimeStamps () |
Delete the time stamps vectors when no longer needed to release some memory. More... | |
void | free_up_timestamps () |
Deletes Stream::time_stamps when no longer needed (to release memory). More... | |
int | load_xdf (std::string filename) |
The main function of loading an XDF file. More... | |
Loads 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... | |
void | resample (int sampling_rate) |
Resamples all streams and channels to sampling_rate . More... | |
+void | sync_timestamps () |
Sync the timestamps. | |
+int | write_events_to_xdf (std::string file_path) |
Writes events to the XDF file. Used when user added markups and/or events in SigViewer, this method stores the newly created events to the XDF file in a new stream. | |
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 |
std::vector< Stream > | streams_ |
float | version_ |
uint64_t | total_len_ = 0 |
double | min_timestamp_ = 0 |
double | max_timestamp_ = 0 |
size_t | channel_count_ = 0 |
int | major_sampling_rate_ = 0 |
int | max_sampling_rate_ = 0 |
std::vector< double > | effective_sampling_rates_ |
double | file_effective_sampling_rate_ = 0 |
std::vector< int > | stream_map_ |
std::vector< std::pair< std::pair< event_name_, event_timestamp_ >, int > > | event_map_ |
std::vector< std::string > | dictionary_ |
std::vector< uint16_t > | event_type_ |
std::vector< std::string > | labels_ |
std::set< double > | sampling_rate_map_ |
std::vector< float > | offsets_ |
std::string | file_header_ |
int | user_added_stream_ {0} |
std::vector< std::pair< std::string, double > > | user_created_events_ |
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.
+Xdf class stores the data of an XDF file. It contains methods to read XDF files, store the data, and additional functionalities such as resampling etc.
typedef std::string Xdf::eventName | +typedef std::string Xdf::event_name_ |
Used as std::vector<std::pair<std::pair<eventName, eventTimeStamp>, int> >
in eventMap.
An alias of std::string type used on event names.
+typedef float Xdf::eventTimeStamp | +typedef double Xdf::event_timestamp_ |
Used as std::vector<std::pair<std::pair<eventName, eventTimeStamp>, int> >
in eventMap.
Xdf::Xdf | -( | -) | -- |
Default constructor with no parameter.
+An alias of double type used on event timestamps.
+void Xdf::adjustTotalLength | +void Xdf::adjust_total_length | ( | ) | @@ -250,47 +221,47 @@ |
void Xdf::calcTotalLength | +void Xdf::calculate_total_length | ( | int | -sampleRate | ) | +sampling_rate | ) |
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.
+Calculates the global length (in samples).
+This is calculated by multiplying the rage from min_timestamp_
to max_timestamp_
across all channels by sampling_rate
.
sampleRate | is the sample rate you wish to use to calculate the total length. |
sampling_rate | The sampling rate used to calculate the total length. |
void Xdf::createLabels | +void Xdf::create_labels | ( | ) | @@ -298,13 +269,13 @@ |
void Xdf::freeUpTimeStamps | +void Xdf::free_up_timestamps | ( | ) | @@ -339,13 +310,13 @@ | ( | int | -userSrate | ) | +sampling_rate | ) |
Resample all streams and channel to a chosen sample rate.
+Resamples all streams and channels to sampling_rate
.
userSrate | is recommended to be between integer 1 and the highest sample rate of the current file. |
<tt>sampling_rate</tt> | in general should be between 1 and the highest sampling rate of the current file. |
int Xdf::writeEventsToXDF | -( | -std::string | -file_path | ) | -+ | size_t Xdf::channel_count_ = 0 |
The total number of channels.
-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
+std::vector<std::string> Xdf::dictionary_ | +
Stores unique event types with no repetitions.
std::vector<std::string> Xdf::dictionary | +std::vector<double> Xdf::effective_sampling_rates_ |
The vector to store unique event types with no repetitions.
Effective sampling rates of streams.
std::vector<std::pair<std::pair<eventName, eventTimeStamp>, int> > Xdf::eventMap | +std::vector<std::pair<std::pair<event_name_, event_timestamp_>, int> > Xdf::event_map_ |
The vector to store all the events across all streams. The format is <<events, timestamps>, streamNum>.
+Stores all events across all streams.
std::vector<uint16_t> Xdf::eventType | +std::vector<uint16_t> Xdf::event_type_ |
The vector to store events by their index in the dictionary.
Stores events by their indices in the dictionary.
std::string Xdf::fileHeader | +double Xdf::file_effective_sampling_rate_ = 0 |
Raw XML of the file header.
+If effective_sampling_rates_ in all the streams are the same, this is the value.
std::vector<std::string> Xdf::labels | +std::string Xdf::file_header_ |
The vector to store descriptive labels of each channel.
+Raw XML of the file header.
int Xdf::majSR = 0 | +std::vector<std::string> Xdf::labels_ |
The sample rate that has the most channels across all streams.
+Stores descriptive labels of each channel.
int Xdf::maxSR = 0 | +int Xdf::major_sampling_rate_ = 0 |
Highest sample rate across all streams.
+The sampling rate that was used by the most channels across all streams.
float Xdf::maxTS = 0 | +int Xdf::max_sampling_rate_ = 0 |
The largest time stamp across all streams.
+Max sampling rate across all streams.
float Xdf::minTS = 0 | +double Xdf::max_timestamp_ = 0 |
The smallest time stamp across all streams.
+The max timestamp across all streams.
std::vector<float> Xdf::offsets | +double Xdf::min_timestamp_ = 0 |
Offsets of each channel after using subtractMean() function
+The min timestamp across all streams.
std::set<double> Xdf::sampleRateMap | +std::vector<float> Xdf::offsets_ |
The vector to store all sample rates across all the streams.
+Offsets of each channel after using the detrend
method.
std::vector<int> Xdf::streamMap | +std::set<double> Xdf::sampling_rate_map_ |
A vector indexes which channels belong to which stream. The index is the same as channel number; the actual content is the stream Number
+Stores sampling rates of all the streams.
std::vector<Stream> Xdf::streams | +std::vector<int> Xdf::stream_map_ |
A vector to store all the streams of the current XDF file.
+Indexes which channels belong to which stream. The keys are channel numbers, the values are stream numbers.
size_t Xdf::totalCh = 0 | +std::vector<Stream> Xdf::streams_ |
The total number of channel count.
+Stores all streams of the current XDF file.
uint64_t Xdf::totalLen = 0 | +uint64_t Xdf::total_len_ = 0 |
The total length is the product of the range between the smallest time stamp and the largest multiplied by the major sample rate.
+The total length is the product of the range between the min timestamp and the max timestamp multiplied by major_sampling_rate_.
int Xdf::userAddedStream { 0 } | +int Xdf::user_added_stream_ {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.
+Used by SigViewer only: if user manually added events in SigViewer, the events will be stored in a new stream after all current streams with index user_added_stream_
.
std::vector<std::pair<std::string, double> > Xdf::userCreatedEvents | +std::vector<std::pair<std::string, double> > Xdf::user_created_events_ |
User created events in Sigviewer.
+Events created by user in SigViewer.
float Xdf::version | +float Xdf::version_ |
The version of XDF file
+The version of the XDF file.
▼ Documents | |
▼ GitHub | |
▼ libxdf | |
▼ libxdf | |
xdf.cpp | |
xdf.h | The header file of Xdf class |
- libxdf
- 0.92
+ Libxdf
- A static C++ library for loading XDF files
+ A C++ library for loading XDF files
|
+ Libxdf
+
+ A C++ library for loading XDF files
+ |
+
Libxdf is a cross-platform C++ library for loading multi-modal, multi-rate signals stored in XDF files. Libxdf is used in the biosignal viewing application SigViewer. It can also be integrated into other C++ applications.
+Libxdf is open-source, free, and actively maintained.
+Libxdf can be conveniently built either using qmake
or cmake
. Configuration files for both build tools are included with the source.
cmake
builds a static library by default, but you can build a shared library by setting the BUILD_SHARED_LIBS
variable (e.g. -DBUILD_SHARED_LIBS=ON
).
Libxdf is a built-in component of SigViewer. If you wish to build SigViewer from source, follow these steps:
+xdf.h
and libxdf.a
from the release page.xdf.h
into sigviewer/external/include
libxdf.a
into sigviewer/external/lib
Example: SigViewer using libxdf to display signals in an XDF file.
+Xdf
class and call the load_xdf
method.Example:
+To resample the signals, e.g. to 100Hz:
+The methods in libxdf must be called following a certain order. For instance, if you call the detrend
method before you load any data, it will cause undefined behavior.
The recommended order is shown here. Only load_xdf
is mandatory.
Libxdf depends on third party libraries Pugixml v1.8 for XML parsing and Smarc for resampling.
+Documentation was generated via Doxygen.
+Email author or report a new issue.
+