- Author
- Abolfazl Ziaeemehr
- Version
- 0.1
- Date
- Nov. 2020
- Copyright
- GNU Public License
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
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 <algorithm>
int main(int argc, const char **argv)
{
std::vector<double> signal;
int fs = 1024;
double f1 = 50.5;
double f2 = 80.0;
double amp1 = 1.1;
double amp2 = 0.5;
int num_points = 4 * 1024;
std::vector<double> freq;
std::vector<double> amp;
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.