forked from amborsa10/lfpRatiometer-Basic
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlfpRatiometer.h
More file actions
79 lines (62 loc) · 1.85 KB
/
lfpRatiometer.h
File metadata and controls
79 lines (62 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef LFPRATIOMETER_H
#define LFPRATIOMETER_H
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <complex.h>
#include <vector>
#include <iostream>
#include <fftw3.h>
class lfpRatiometer {
public:
// constructor
lfpRatiometer(int N_input, double sampling_input);
// destructor
~lfpRatiometer(void);
// execute
void execute();
protected:
private:
int N; // time window in samples
int f_size; // nonredundant size of DFT
double sampling; // sampling rate (Hz)
double *in; // pointer to (windowed) time series
std::vector<double> in_raw; // vector to hold raw time series
fftw_complex *out; // pointer to DFT
fftw_plan p; // stores FFTW3 plan
std::vector<double> allfreqs;
std::vector<double> psd;
double lf_hf_ratio;
double lf_low;
double lf_high;
double hf_low;
double hf_high;
std::vector<double> window; // time domain of window
double s2; // window scaling factor
// method sets window as rectangle
void window_rect(){
window.clear();
s2 = 0;
for (int j=0; j<N; j++){
double val = 1;
window.push_back(val);
s2 = s2 + val*val;
}
}
// method sets window as Hamming
// supposed to be consistent with MATLAB hamming() function
void window_hamming(){
window.clear();
s2 = 0;
double pi = atan(1) * 4;
for (int j=0; j<N; j++){
double z = 2*pi*j/(N-1);
double val = 0.54 - 0.46*cos(z);
window.push_back(val);
s2 = s2 + val*val;
}
}
void makePSD();
void getRatio();
};
#endif