|
neuro_toolbox
|
Functions | |
| template<typename T > | |
| std::vector< T > | load_vector (std::string filename) |
| bool | file_exists (const std::string &filename) |
| template<typename T > | |
| std::vector< std::vector< T > > | load_matrix (const std::string filename, const int row, const int col) |
| template<typename T > | |
| std::vector< std::vector< T > > | adjmat_to_adjlist (const std::vector< std::vector< T >> &A, const double threshold=1e-8, std::string in_degree="row") |
| template<typename T > | |
| void | write_matrix_to_file (const std::vector< std::vector< T >> &A, const std::string filename) |
| template<typename T > | |
| void | write_vector_to_file (const std::vector< T > &v, const std::string filename) |
| void | spikes_to_file (const std::string filename, const std::vector< std::vector< double >> &spikes) |
| std::vector< float > | rand_uniform (const double low, const double high, const int size, const int seed=-1) |
| std::vector< int > | randint (const int low, const int high, const int size, const int seed=-1) |
| void | make_signal (std::vector< double > &signal, const int fs, const int num_points=1024, const double f1=50.25, const double f2=80.5, const double a1=1.0, const double a2=0.5) |
| void | fft (const std::vector< double > &signal, std::vector< double > &frequencies, std::vector< double > &litudes, const double fs) |
| template<typename T > | |
| std::vector< T > | flatten (const std::vector< std::vector< T >> &vec) |
| std::vector< double > | angle_arr (const fftw_complex *z, const int n, bool deg=false) |
| template<typename T > | |
| double | average (const std::vector< T > &vec, const int index=0) |
| void | hilbert_transform (const std::vector< double > &in_vec, fftw_complex *out_array) |
| std::vector< double > | unwrap (const std::vector< double > &in_vec) |
| double | calculate_phase_difference (const std::vector< double > &x) |
| double | calculate_phase_synchrony (const std::vector< std::vector< double >> &voltages) |
| double | get_wall_time () |
| double | get_cpu_time () |
| void | display_timing (double wtime, double cptime) |
| std::vector<std::vector<T> > NTB::adjmat_to_adjlist | ( | const std::vector< std::vector< T >> & | A, |
| const double | threshold = 1e-8, |
||
| std::string | in_degree = "row" |
||
| ) |
return adjacency list of given adjacency matrix
| A | input adjacency matrix |
| threshold | threshold for binarizing |
| in_degree | "row" or "col" to consider input edges on row or col, respectively |
example adjmat_to_adjlist<int>(A);
| std::vector<double> NTB::angle_arr | ( | const fftw_complex * | z, |
| const int | n, | ||
| bool | deg = false |
||
| ) |
Return the angle of the complex argument.
|
inline |
average the vector from element "index" to end of the vector
| vec | input vector |
| index | index to drop elements before that |
| double NTB::calculate_phase_difference | ( | const std::vector< double > & | x | ) |
| double NTB::calculate_phase_synchrony | ( | const std::vector< std::vector< double >> & | voltages | ) |
| void NTB::display_timing | ( | double | wtime, |
| double | cptime | ||
| ) |
Display wall time and cpu time on terminal
| void NTB::fft | ( | const std::vector< double > & | signal, |
| std::vector< double > & | frequencies, | ||
| std::vector< double > & | amplitudes, | ||
| const double | fs | ||
| ) |
discrete Fourier transform (DFT) from 1d read signal
| signal | [Input] input signal |
| freq | [input/output] output as frequency |
| amplitudes | [input/output] output as amplitudes |
| fs | frequency sampling in [s^1] |
|
inline |
check whether file with given name exist
| filename | [string] input file name |
| std::vector<T> NTB::flatten | ( | const std::vector< std::vector< T >> & | vec | ) |
Return a copy of the vector collapsed into one dimension
| vec | input vector of vectors |
| double NTB::get_cpu_time | ( | ) |
measure cpu passed time
| double NTB::get_wall_time | ( | ) |
measure real passed time
| void NTB::hilbert_transform | ( | const std::vector< double > & | in_vec, |
| fftw_complex * | out_array | ||
| ) |
Compute the analytic signal, using the Hilbert transform. equivalent to scipy.signal.hilbert
| input | vector |
| out_array | complex analytic signal |
|
inline |
Read matrix into vector of vector
| filename | [string] name of text file to read |
| row | [int] number of rows |
| col | [int] number of columns |
example std::vector<std::vector<int>> A = Neuro::read_matrix<int>( "data/matrix_integer.txt", 4, 3);
|
inline |
Read numbers from single column text file
| filename | [std::string] input file name |
example:
std::vector<double> vec = read_from_file<double>("my_file.txt");
exit if it does not found the input file
| void NTB::make_signal | ( | std::vector< double > & | signal, |
| const int | fs, | ||
| const int | num_points = 1024, |
||
| const double | f1 = 50.25, |
||
| const double | f2 = 80.5, |
||
| const double | a1 = 1.0, |
||
| const double | a2 = 0.5 |
||
| ) |
Generate two sine waves of different frequencies and amplitudes.
| signal | [input/output] 1d real vector as signal. |
| fs | frequency sampling [s^-1] |
| num_points | the numper of points in signal |
| f1 | frequency in [Hz] |
| f2 | frequency in [Hz] |
| a1 | amplitude |
| a2 | amplitude |
| std::vector<float> NTB::rand_uniform | ( | const double | low, |
| const double | high, | ||
| const int | size, | ||
| const int | seed = -1 |
||
| ) |
Random number distribution that produces floating-point values according to a uniform distribution, which is described by the following probability density function: P(X|a, b) = 1/(b-a), a<= x < b This distribution (also know as rectangular distribution) produces random numbers in a range [a,b) where all intervals of the same length within it are equally probable.
| low | Lower boundary of the output interval. All values generated will be greater than or equal to low. |
| high | Upper boundary of the output interval. All values generated will be less than or equal to high. |
| size | Lengh of output random numbers. |
| seed | if not defined a positive number, return the same random numbers |
| std::vector<int> NTB::randint | ( | const int | low, |
| const int | high, | ||
| const int | size, | ||
| const int | seed = -1 |
||
| ) |
Random number distribution that produces integer values according to a uniform discrete distribution, which is described by the following probability mass function: P(i|a,b) = 1/(b-a+1), a <= i <= b
| low | Lower boundary of the output interval. All values generated will be greater than or equal to low. |
| high | Upper boundary of the output interval. All values generated will be less than or equal to high. |
| size | Lengh of output random numbers. |
| seed | if not defined a positive number, return the same random numbers |
| void NTB::spikes_to_file | ( | const std::string | filename, |
| const std::vector< std::vector< double >> & | spikes | ||
| ) |
| std::vector<double> NTB::unwrap | ( | const std::vector< double > & | in_vec | ) |
Unwrap by changing deltas between values to 2*pi complement.
Unwrap radian phase in_vec by changing absolute jumps greater than pi to their 2*pi complement. equivalent to numpy.unwrap
| in_vec | input vector |
| void NTB::write_matrix_to_file | ( | const std::vector< std::vector< T >> & | A, |
| const std::string | filename | ||
| ) |
Write matrix to text file
| A | input vector of vector of type T. |
| filename | output text file name. |
| void NTB::write_vector_to_file | ( | const std::vector< T > & | v, |
| const std::string | filename | ||
| ) |
Write vector to text file
| v | input vector of type T |
| filename | output text file name. |
Exit if it could not open file to write successfully.
1.8.13