neuro_toolbox
HEADER FILES only C++ library for analysis of neurophysiological and simulated data.
Author
Abolfazl Ziaeemehr
Version
0.1
Date
Nov. 2020

Installation

There is no need for installation. It's a header file only library. You just need to put the header files in a directory and pass the address of the directory to the make file or directly pass it to the terminal using -I PATH_TO_HEADER_FILES and also include the header file

{c++}
#include "neuro_toolbox.hpp"

and access to the content with NTB:: namespace.

Testing

neuro_toolbox use catch2 unittest. To use tests

cd src/tests
make clean
make all
# or test each header file seperately
make signal_proccesing
make random_generators
make IO

for auto-generated documentation you need to have doxygen installed on your machine.

# on linux machines use
sudo apt-get install doxygen
cd doc
doxygen

which produce html files.

Quick start

input/output

neuro_toolbox use Function templates i.e. you can call the functions with different type of data

for exampel to read a colum from file you can use:

{c++}
std::vector<int> vec = NTB::load_vector<int>("file_with_int_numbers.txt");
std::vector<float> vec = NTB::load_vector<float>("file_with_float_numbers.txt");
std::vector<double> vec = NTB::load_vector<double>("file_with_double_numbers.txt");

Signal Processing

The following example make a test signal with mixture of two frequencies and different amplitudes. Then use NTB::fft to apply discrete fourier transform and print the maximum amplitude and it's frequency.

{c++}
#include "neuro_toolbox.hpp"
#include <algorithm>
int main(int argc, const char **argv)
{
std::vector<double> signal;
int fs = 1024; //frequency sampling
double f1 = 50.5; // frequency1 [Hz]
double f2 = 80.0; // frequency2 [Hz]
double amp1 = 1.1; // amplitude of frequency1
double amp2 = 0.5; // amplitude of frequency2
int num_points = 4 * 1024; // number of sample points in signal
NTB::make_signal(signal, fs, num_points, f1, f2, amp1, amp2);
std::vector<double> freq;
std::vector<double> amp;
NTB::fft(signal, freq, amp, fs); // apply fft on real 1D signal
// for (size_t i = 0; i < freq.size(); ++i)
// {
// std::cout << freq[i] << "\t" << amp[i] << "\n";
// }
std::vector<double>::iterator result;
result = std::max_element(amp.begin(), amp.end());
auto index = std::distance(amp.begin(), result);
std::cout << "index : " << index << "\n";
std::cout << "frequency : " << freq[index] << "\n";
std::cout << "amplitude : " << *result << "\n";
return 0;
}

for more examples you can refer to the examples or tests directory.