paradigma 0.1.2__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- paradigma/__init__.py +1 -3
- paradigma/constants.py +35 -0
- paradigma/feature_extraction.py +678 -0
- paradigma/gait_analysis.py +413 -0
- paradigma/gait_analysis_config.py +244 -0
- paradigma/heart_rate_analysis.py +127 -0
- paradigma/heart_rate_analysis_config.py +9 -0
- paradigma/heart_rate_util.py +173 -0
- paradigma/imu_preprocessing.py +229 -0
- paradigma/ppg/classifier/LR_PPG_quality.pkl +0 -0
- paradigma/ppg/classifier/LR_model.mat +0 -0
- paradigma/ppg/feat_extraction/acc_feature.m +20 -0
- paradigma/ppg/feat_extraction/peakdet.m +64 -0
- paradigma/ppg/feat_extraction/ppg_features.m +53 -0
- paradigma/ppg/glob_functions/extract_hr_segments.m +37 -0
- paradigma/ppg/glob_functions/extract_overlapping_segments.m +23 -0
- paradigma/ppg/glob_functions/jsonlab/AUTHORS.txt +41 -0
- paradigma/ppg/glob_functions/jsonlab/ChangeLog.txt +74 -0
- paradigma/ppg/glob_functions/jsonlab/LICENSE_BSD.txt +25 -0
- paradigma/ppg/glob_functions/jsonlab/LICENSE_GPLv3.txt +699 -0
- paradigma/ppg/glob_functions/jsonlab/README.txt +394 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/entries +368 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/demo_jsonlab_basic.m.svn-base +180 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/demo_ubjson_basic.m.svn-base +180 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example1.json.svn-base +23 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example2.json.svn-base +22 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example3.json.svn-base +11 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example4.json.svn-base +34 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_basictest.matlab.svn-base +662 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_selftest.m.svn-base +27 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_selftest.matlab.svn-base +144 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_speedtest.m.svn-base +21 -0
- paradigma/ppg/glob_functions/jsonlab/examples/demo_jsonlab_basic.m +180 -0
- paradigma/ppg/glob_functions/jsonlab/examples/demo_ubjson_basic.m +180 -0
- paradigma/ppg/glob_functions/jsonlab/examples/example1.json +23 -0
- paradigma/ppg/glob_functions/jsonlab/examples/example2.json +22 -0
- paradigma/ppg/glob_functions/jsonlab/examples/example3.json +11 -0
- paradigma/ppg/glob_functions/jsonlab/examples/example4.json +34 -0
- paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_basictest.matlab +662 -0
- paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_selftest.m +27 -0
- paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_selftest.matlab +144 -0
- paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_speedtest.m +21 -0
- paradigma/ppg/glob_functions/jsonlab/jsonopt.m +32 -0
- paradigma/ppg/glob_functions/jsonlab/loadjson.m +566 -0
- paradigma/ppg/glob_functions/jsonlab/loadubjson.m +528 -0
- paradigma/ppg/glob_functions/jsonlab/mergestruct.m +33 -0
- paradigma/ppg/glob_functions/jsonlab/savejson.m +475 -0
- paradigma/ppg/glob_functions/jsonlab/saveubjson.m +504 -0
- paradigma/ppg/glob_functions/jsonlab/varargin2struct.m +40 -0
- paradigma/ppg/glob_functions/sample_prob_final.m +49 -0
- paradigma/ppg/glob_functions/synchronization.m +76 -0
- paradigma/ppg/glob_functions/tsdf_scan_meta.m +22 -0
- paradigma/ppg/hr_functions/Long_TFD_JOT.m +37 -0
- paradigma/ppg/hr_functions/PPG_TFD_HR.m +59 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/.gitignore +4 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/CHANGELOG.md +23 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/LICENCE.md +27 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/README.md +251 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/README.pdf +0 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_Doppler_kern.m +142 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_Doppler_lag_kern.m +314 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_lag_kern.m +123 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/dec_tfd.m +154 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_di_gdtfd.m +194 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_li_gdtfd.m +200 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_nonsep_gdtfd.m +229 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_sep_gdtfd.m +241 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/di_gdtfd.m +157 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/li_gdtfd.m +190 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/nonsep_gdtfd.m +196 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/sep_gdtfd.m +199 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_tfd.m +144 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/load_curdir.m +13 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/pics/decimated_TFDs_examples.png +0 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/pics/full_TFDs_examples.png +0 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/check_dec_params_seq.m +79 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/dispEE.m +9 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/dispVars.m +26 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/disp_bytes.m +25 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/fold_vector_full.m +40 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/fold_vector_half.m +34 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/gen_LFM.m +29 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/get_analytic_signal.m +76 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/get_window.m +176 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/isreal_fn.m +11 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/padWin.m +97 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/vtfd.m +149 -0
- paradigma/ppg/preprocessing/preprocessing_imu.m +15 -0
- paradigma/ppg/preprocessing/preprocessing_ppg.m +13 -0
- paradigma/ppg_preprocessing.py +313 -0
- paradigma/preprocessing_config.py +64 -0
- paradigma/quantification.py +58 -0
- paradigma/tremor/TremorFeaturesAndClassification.m +345 -0
- paradigma/tremor/feat_extraction/DerivativesExtract.m +22 -0
- paradigma/tremor/feat_extraction/ExtractBandSignalsRMS.m +72 -0
- paradigma/tremor/feat_extraction/MFCCExtract.m +100 -0
- paradigma/tremor/feat_extraction/PSDBandPower.m +52 -0
- paradigma/tremor/feat_extraction/PSDEst.m +63 -0
- paradigma/tremor/feat_extraction/PSDExtrAxis.m +88 -0
- paradigma/tremor/feat_extraction/PSDExtrOpt.m +95 -0
- paradigma/tremor/preprocessing/InterpData.m +32 -0
- paradigma/tremor/weekly_aggregates/WeeklyAggregates.m +295 -0
- paradigma/util.py +50 -0
- paradigma/windowing.py +217 -0
- paradigma-0.2.0.dist-info/LICENSE +192 -0
- paradigma-0.2.0.dist-info/METADATA +58 -0
- paradigma-0.2.0.dist-info/RECORD +108 -0
- paradigma/dummy.py +0 -3
- paradigma-0.1.2.dist-info/LICENSE +0 -201
- paradigma-0.1.2.dist-info/METADATA +0 -18
- paradigma-0.1.2.dist-info/RECORD +0 -6
- {paradigma-0.1.2.dist-info → paradigma-0.2.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% dec_sep_gdtfd: Decimated TFD with separable kernel of the form g[l,m]=G1[l]g2[m]. For
|
|
3
|
+
% efficient implement define windows G1[l] and g2[m] as band-limited functions.
|
|
4
|
+
%
|
|
5
|
+
% TFD is decimated with integer factors a,b as ρ[an,bk]
|
|
6
|
+
%
|
|
7
|
+
% Syntax: tfd=dec_sep_gdtfd(x,dopp_win_params,lag_win_params,time_dec,freq_dec,Ntime,Nfreq)
|
|
8
|
+
%
|
|
9
|
+
% Inputs:
|
|
10
|
+
% x = input signal (either real-valued signal of length-N or
|
|
11
|
+
% complex-valued analytic signal of length-2N)
|
|
12
|
+
%
|
|
13
|
+
% dopp_win_params = Doppler window parameters in cell form:
|
|
14
|
+
% {win_length,win_type,win_param,Doppler_or_not} where
|
|
15
|
+
% - win_length is the sample length of the window
|
|
16
|
+
% - win_type is the type of window
|
|
17
|
+
% - [optional] win_param is the parameter of the window
|
|
18
|
+
% - [optional] Doppler_or_not is either 1 (define window in the Doppler
|
|
19
|
+
% domain, which is the default) or 0 (define window in the time domain)
|
|
20
|
+
% e.g. {121, 'hamm'}; {121, 'tukey', 0.2}; {127,'cosh',0.01,0}
|
|
21
|
+
%
|
|
22
|
+
% lag_win_params = lag window parameters in cell form:
|
|
23
|
+
% {win_length,win_type,win_param,lag_or_not} where
|
|
24
|
+
% - win_length is the sample length of the window
|
|
25
|
+
% - win_type is the type of window
|
|
26
|
+
% - [optional] win_param is the parameter of the window
|
|
27
|
+
% - [optional] lag_or_not is either 0 (define window in the lag
|
|
28
|
+
% domain, which is the default) or 1 (define window the frequency domain)
|
|
29
|
+
% e.g. {121, 'hamm'}; {121, 'tukey', 0.2}; {127,'cosh',0.01,0}
|
|
30
|
+
%
|
|
31
|
+
% time_dec = decimation factor a in the time domain; a/Ntime is integer
|
|
32
|
+
% freq_dec = decimation factor b in the frequency domain; b/Nfreq is integer
|
|
33
|
+
%
|
|
34
|
+
% Nfreq = frequency oversampling value; must be greater than length of lag window
|
|
35
|
+
% Ntime = time oversampling value; must be greater than length of Doppler window
|
|
36
|
+
%
|
|
37
|
+
% Outputs:
|
|
38
|
+
% tfd = (a/Ntime) x (b/Nfreq) time–frequency distribution
|
|
39
|
+
%
|
|
40
|
+
% See also: SEP_GDTFD, GET_ANALYTIC_SIGNAL, GEN_LAG_KERN, GEN_DOPPLER_KERN, FFT
|
|
41
|
+
%
|
|
42
|
+
% Example:
|
|
43
|
+
% N=1024; Ntime=64; Nfreq=128; a=1; b=2;
|
|
44
|
+
% x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
|
|
45
|
+
%
|
|
46
|
+
% c=dec_sep_gdtfd(x,{51,'hann'},{101,'hann'},a,b,Ntime,Nfreq);
|
|
47
|
+
% vtfd(c,x);
|
|
48
|
+
|
|
49
|
+
% John M. O' Toole, University College Cork
|
|
50
|
+
% Started: 24-04-2014
|
|
51
|
+
%
|
|
52
|
+
% last update: Time-stamp: <2014-07-23 15:25:51 (otoolej)>
|
|
53
|
+
%-------------------------------------------------------------------------------
|
|
54
|
+
function tfd=dec_sep_gdtfd(x,dopp_win_params,lag_win_params,time_dec,freq_dec,Ntime, ...
|
|
55
|
+
Nfreq)
|
|
56
|
+
if(nargin<2 || isempty(dopp_win_params)), dopp_win_params={51,'hann'}; end
|
|
57
|
+
if(nargin<3 || isempty(lag_win_params)), lag_win_params={151,'hann'}; end
|
|
58
|
+
if(nargin<4 || isempty(time_dec)), time_dec=1; end
|
|
59
|
+
if(nargin<5 || isempty(freq_dec)), freq_dec=1; end
|
|
60
|
+
if(nargin<6 || isempty(Ntime)), Ntime=[]; end
|
|
61
|
+
if(nargin<7 || isempty(Nfreq)), Nfreq=[]; end
|
|
62
|
+
|
|
63
|
+
DBplot=0;
|
|
64
|
+
DBmem=0;
|
|
65
|
+
DBtest=0;
|
|
66
|
+
DBtime=0;
|
|
67
|
+
DBverbose=0;
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if(DBtime), time_start=tic; end
|
|
71
|
+
%---------------------------------------------------------------------
|
|
72
|
+
% 1. convert real-valued signal to analytic signal of length 2N
|
|
73
|
+
%---------------------------------------------------------------------
|
|
74
|
+
[z,N2,N,Nh]=get_analytic_signal(x);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
%---------------------------------------------------------------------
|
|
78
|
+
% 2. generate kernel windows and check decimation parameters
|
|
79
|
+
%---------------------------------------------------------------------
|
|
80
|
+
[G1,Q,Ntime]=gen_Doppler_kern(dopp_win_params,N,Ntime);
|
|
81
|
+
Qh=ceil(Q/2);
|
|
82
|
+
|
|
83
|
+
[g2,P,Ph_floor,Nfreq]=gen_lag_kern(lag_win_params,N,Nfreq);
|
|
84
|
+
Nh=ceil(Nfreq/2); Ph=ceil(P/2);
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
% check decimation parameters and return as sequence:
|
|
88
|
+
if(length(time_dec)>1 || length(freq_dec)>1)
|
|
89
|
+
error('Frequency and time decimation parameters should be scalar');
|
|
90
|
+
end
|
|
91
|
+
[n_seq,L,time_dec]=check_dec_params_seq(time_dec,Ntime,'time',1);
|
|
92
|
+
[k_seq,J,freq_dec]=check_dec_params_seq(freq_dec,Nfreq,'frequency',1);
|
|
93
|
+
Jh=ceil(J/2); J_extend=2*Jh+2; P_extend=2*Ph+2;
|
|
94
|
+
|
|
95
|
+
if(DBmem), s=whos; fprintf('start: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
96
|
+
|
|
97
|
+
tfd=zeros(L,J_extend);
|
|
98
|
+
m_real=1:(Jh+1); m_imag=(J_extend-Jh):(J_extend);
|
|
99
|
+
|
|
100
|
+
if(DBverbose),
|
|
101
|
+
dispVars(N,Ntime,Nfreq,L,J,Jh,J_extend,P,Ph,Q,Qh,P_extend);
|
|
102
|
+
dispVars(length(m_real),length(m_imag),m_real(end),m_imag(1));
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if(DBmem), s=whos; fprintf('declare TFD: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
%---------------------------------------------------------------------
|
|
109
|
+
% 2. generate time--lag signal function (for positive-lag values only)
|
|
110
|
+
%---------------------------------------------------------------------
|
|
111
|
+
l=0:(Qh-1); lb=1:(Qh-1);
|
|
112
|
+
n=0:N-1;
|
|
113
|
+
for m=0:Jh
|
|
114
|
+
|
|
115
|
+
%-------------------------------------------------------------------------
|
|
116
|
+
% a) Form lag-slice of windowed time-lag function and then fold in
|
|
117
|
+
% the lag direction.
|
|
118
|
+
%-------------------------------------------------------------------------
|
|
119
|
+
R_lag_slice=zeros(N,1);
|
|
120
|
+
for p=0:freq_dec-1
|
|
121
|
+
mmod=p.*J+m;
|
|
122
|
+
|
|
123
|
+
if(mmod<=Ph)
|
|
124
|
+
inp=mod(n+mmod,N2); inn=mod(n-mmod,N2);
|
|
125
|
+
i1=mod(n+mmod,N2); i2=mod(n-mmod,N2);
|
|
126
|
+
|
|
127
|
+
R_lag_slice=R_lag_slice+z(inp+1).*conj(z(inn+1)).*g2(mmod+1);
|
|
128
|
+
elseif(mmod>Nfreq-Ph)
|
|
129
|
+
inp=mod(n+Nfreq-mmod,N2); inn=mod(n-Nfreq+mmod,N2);
|
|
130
|
+
|
|
131
|
+
R_lag_slice=R_lag_slice+conj(z(inp+1)).*z(inn+1).*g2(P-Nfreq+mmod+1);
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
%-------------------------------------------------------------------------
|
|
137
|
+
% b) DFT to the Doppler--lag domain..
|
|
138
|
+
%-------------------------------------------------------------------------
|
|
139
|
+
R_lag_slice=fft(R_lag_slice);
|
|
140
|
+
|
|
141
|
+
%-------------------------------------------------------------------------
|
|
142
|
+
% c) Multiply by Doppler window G1
|
|
143
|
+
%-------------------------------------------------------------------------
|
|
144
|
+
r_lag_slice=zeros(Ntime,1);
|
|
145
|
+
r_lag_slice(l+1)=R_lag_slice(l+1).*G1(l+1);
|
|
146
|
+
r_lag_slice(Ntime-lb+1)=R_lag_slice(N-lb+1).*G1(Q-lb+1);
|
|
147
|
+
|
|
148
|
+
%-------------------------------------------------------------------------
|
|
149
|
+
% d) Fold in the Doppler direction
|
|
150
|
+
%-------------------------------------------------------------------------
|
|
151
|
+
r_lag_fold=fold_vector_full(r_lag_slice,L,time_dec);
|
|
152
|
+
|
|
153
|
+
%-------------------------------------------------------------------------
|
|
154
|
+
% e) DFT the lag slice to the time--lag domain
|
|
155
|
+
%-------------------------------------------------------------------------
|
|
156
|
+
r_lag_fold=ifft(r_lag_fold);
|
|
157
|
+
|
|
158
|
+
tfd(:,m_real(m+1))=real(r_lag_fold);
|
|
159
|
+
tfd(:,m_imag(m+1))=imag(r_lag_fold);
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
if(DBmem), s=whos; fprintf('R: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
164
|
+
|
|
165
|
+
%-------------------------------------------------------------------------
|
|
166
|
+
% 4. Expand R for positive and negative lag values and DFT back to
|
|
167
|
+
% time--frequency domain
|
|
168
|
+
%-------------------------------------------------------------------------
|
|
169
|
+
m=0:Jh; mb=1:(Jh-1);
|
|
170
|
+
for n=0:2:(L-2)
|
|
171
|
+
R_even_half=complex(tfd(n+1,m_real),tfd(n+1,m_imag));
|
|
172
|
+
R_odd_half =complex(tfd(n+2,m_real),tfd(n+2,m_imag));
|
|
173
|
+
|
|
174
|
+
R_tslice_even=zeros(J,1); R_tslice_odd=zeros(J,1);
|
|
175
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
176
|
+
R_tslice_odd(m+1) =R_odd_half(m+1);
|
|
177
|
+
R_tslice_even(J-mb+1)=conj( R_even_half(mb+1) );
|
|
178
|
+
R_tslice_odd(J-mb+1) =conj( R_odd_half(mb+1) );
|
|
179
|
+
|
|
180
|
+
tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
181
|
+
|
|
182
|
+
tfd(n+1,1:J)=real(tfd_time_slice);
|
|
183
|
+
tfd(n+2,1:J)=imag(tfd_time_slice);
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
% one extra FFT if L is odd:
|
|
187
|
+
if(rem(L,2))
|
|
188
|
+
R_even_half=complex(tfd(L,m_real),tfd(L,m_imag));
|
|
189
|
+
|
|
190
|
+
R_tslice_even=zeros(J,1);
|
|
191
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
192
|
+
R_tslice_even(J-mb+1)=conj( R_even_half(mb+1) );
|
|
193
|
+
|
|
194
|
+
tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
195
|
+
|
|
196
|
+
tfd(L,1:J)=real(tfd_time_slice);
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
tfd=tfd(:,1:J);
|
|
200
|
+
|
|
201
|
+
if(DBmem), s=whos; fprintf('end: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
202
|
+
|
|
203
|
+
scale_factor=1/Nfreq;
|
|
204
|
+
tfd=tfd.*scale_factor;
|
|
205
|
+
|
|
206
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
207
|
+
|
|
208
|
+
%---------------------------------------------------------------------
|
|
209
|
+
% END; testing and plotting
|
|
210
|
+
%---------------------------------------------------------------------
|
|
211
|
+
if(DBtest)
|
|
212
|
+
if(DBtime), time_start=tic; end
|
|
213
|
+
tfd_test=full_gdtfd_testing_version(x,'sep',{dopp_win_params,lag_win_params});
|
|
214
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
215
|
+
|
|
216
|
+
a=N/Ntime; b=N/Nfreq;
|
|
217
|
+
if( a==floor(a) && b==floor(b) )
|
|
218
|
+
dispEE(tfd_test( (a.*n_seq)+1,(b.*k_seq)+1),tfd./(a*b));
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
% $$$ figure(100); clf; hold all;
|
|
222
|
+
% $$$ k=10; plot(tfd_test(n_seq+1,k_seq(k)+1)); plot(tfd(:,k+1));
|
|
223
|
+
% $$$ keyboard;
|
|
224
|
+
end
|
|
225
|
+
if(DBverbose)
|
|
226
|
+
fprintf('size=%dx%d; max=%g; total energ:%d\n', size(tfd,1), size(tfd,2), max(tfd(:)), ...
|
|
227
|
+
sum(tfd(:)));
|
|
228
|
+
end
|
|
229
|
+
if(DBplot)
|
|
230
|
+
figure(1); clf;
|
|
231
|
+
vtfd(tfd,real(x(1:N)));
|
|
232
|
+
|
|
233
|
+
% $$$ figure(9); clf; hold all;
|
|
234
|
+
% $$$ subplot(211); hold all; plot(sum(tfd')'); plot( abs(z(1:N)).^2 );
|
|
235
|
+
% $$$ subplot(212); hold all; plot(sum(tfd')' - abs(z(n_seq+1)).^2 );
|
|
236
|
+
% $$$
|
|
237
|
+
% $$$ figure(10); clf; hold all;
|
|
238
|
+
% $$$ Z=fft(z);
|
|
239
|
+
% $$$ subplot(211); hold all; plot(sum(tfd)); plot( abs(Z(1:N)).^2./(2*N) );
|
|
240
|
+
% $$$ subplot(212); hold all; plot(sum(tfd)' - abs(Z(k_seq+1)).^2./(2*N) );
|
|
241
|
+
end
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% di_gdtfd: TFD with Doppler-independent (DI) kernel g[l,m]=g₂[m]
|
|
3
|
+
%
|
|
4
|
+
% Syntax: tfd=di_gdtfd(x,lag_win_params,Nfreq)
|
|
5
|
+
%
|
|
6
|
+
% Inputs:
|
|
7
|
+
% x = input signal (either real-valued signal of length-N or
|
|
8
|
+
% complex-valued analytic signal of length-2N)
|
|
9
|
+
%
|
|
10
|
+
% lag_win_params = lag window parameters in cell form:
|
|
11
|
+
% {win_length,win_type,win_param,lag_or_not} where
|
|
12
|
+
% - win_length is the sample length of the window
|
|
13
|
+
% - win_type is the type of window
|
|
14
|
+
% - [optional] win_param is the parameter of the window
|
|
15
|
+
% - [optional] lag_or_not is either 0 (define window in the lag
|
|
16
|
+
% domain, which is the default) or 0 (define window the frequency domain)
|
|
17
|
+
% e.g. {121, 'hamm'}; {121, 'tukey', 0.2}; {127,'cosh',0.01,0}
|
|
18
|
+
%
|
|
19
|
+
% Nfreq = frequency oversampling value; must be greater than length of lag window
|
|
20
|
+
%
|
|
21
|
+
% Outputs:
|
|
22
|
+
% tfd = N x Nfreq time-frequency distribution
|
|
23
|
+
%
|
|
24
|
+
% See also: DEC_DI_GDTFD, GET_ANALYTIC_SIGNAL, GEN_LAG_KERN, FFT
|
|
25
|
+
%
|
|
26
|
+
% Example:
|
|
27
|
+
% N=512; Ntime=256; Nfreq=256;
|
|
28
|
+
% x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
|
|
29
|
+
%
|
|
30
|
+
% c=di_gdtfd(x,{51,'hann'},Nfreq);
|
|
31
|
+
% vtfd(c,x);
|
|
32
|
+
|
|
33
|
+
% John M. O' Toole, University College Cork
|
|
34
|
+
% Started: 16-04-2014
|
|
35
|
+
%
|
|
36
|
+
% last update: Time-stamp: <2014-07-23 16:31:30 (otoolej)>
|
|
37
|
+
%-------------------------------------------------------------------------------
|
|
38
|
+
function tfd=di_gdtfd(x,lag_win_params,Nfreq)
|
|
39
|
+
if(nargin<2 || isempty(lag_win_params)), lag_win_params={101,'hamm'}; end
|
|
40
|
+
if(nargin<3 || isempty(Nfreq)), Nfreq=[]; end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
DBplot=0;
|
|
44
|
+
DBmem=0;
|
|
45
|
+
DBcompare=0;
|
|
46
|
+
DBtest=0;
|
|
47
|
+
DBtime=0;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if(DBtime), time_start=tic; end
|
|
51
|
+
%---------------------------------------------------------------------
|
|
52
|
+
% 1. convert real-valued signal to analytic signal of length 2N
|
|
53
|
+
%---------------------------------------------------------------------
|
|
54
|
+
[z,N2,N,Nh]=get_analytic_signal(x);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
%---------------------------------------------------------------------
|
|
58
|
+
% 2. generate time--lag signal function (for positive-lag values only)
|
|
59
|
+
%---------------------------------------------------------------------
|
|
60
|
+
[g2,P,Ph_floor,Nfreq]=gen_lag_kern(lag_win_params,N,Nfreq);
|
|
61
|
+
Nh=ceil(Nfreq/2);
|
|
62
|
+
Ph=ceil(P/2);
|
|
63
|
+
|
|
64
|
+
if(DBmem), s=whos; fprintf('start: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
65
|
+
tfd=zeros(N,Nfreq);
|
|
66
|
+
m_real=1:Ph; m_imag=(Nfreq-Ph+1):Nfreq;
|
|
67
|
+
|
|
68
|
+
m=0:(Ph-1);
|
|
69
|
+
for n=0:N-1
|
|
70
|
+
inp=mod(n+m,N2); inn=mod(n-m,N2);
|
|
71
|
+
K_time_slice=g2(m+1).*z(inp+1).*conj( z(inn+1) );
|
|
72
|
+
|
|
73
|
+
tfd(n+1,m_real)=real( K_time_slice );
|
|
74
|
+
tfd(n+1,m_imag)=imag( K_time_slice );
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if(DBcompare)
|
|
79
|
+
K=zeros(N,Nh);
|
|
80
|
+
for n=0:N-1
|
|
81
|
+
inp=mod(n+m,N2); inn=mod(n-m,N2);
|
|
82
|
+
K(n+1,m+1)=g2(m+1).*z(inp+1).*conj( z(inn+1) );
|
|
83
|
+
end
|
|
84
|
+
Ktest=complex(tfd(:,m_real),tfd(:,m_imag));
|
|
85
|
+
dispEE(Ktest,K(:,m+1));
|
|
86
|
+
end
|
|
87
|
+
if(DBmem), s=whos; fprintf('K: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
%-------------------------------------------------------------------------
|
|
91
|
+
% 3. Expand R for positive and negative lag values and DFT back to
|
|
92
|
+
% time--frequency domain
|
|
93
|
+
%-------------------------------------------------------------------------
|
|
94
|
+
m=0:(Ph-1); mb=1:(Ph-1);
|
|
95
|
+
for n=0:2:N-2
|
|
96
|
+
R_even_half=complex(tfd(n+1,m_real),tfd(n+1,m_imag));
|
|
97
|
+
R_odd_half =complex(tfd(n+2,m_real),tfd(n+2,m_imag));
|
|
98
|
+
|
|
99
|
+
R_tslice_even=zeros(1,Nfreq); R_tslice_odd=zeros(1,Nfreq);
|
|
100
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
101
|
+
R_tslice_odd(m+1) =R_odd_half(m+1);
|
|
102
|
+
R_tslice_even(Nfreq-mb+1)=conj( R_even_half(mb+1) );
|
|
103
|
+
R_tslice_odd(Nfreq-mb+1) =conj( R_odd_half(mb+1) );
|
|
104
|
+
|
|
105
|
+
tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
106
|
+
|
|
107
|
+
tfd(n+1,:)=real(tfd_time_slice);
|
|
108
|
+
tfd(n+2,:)=imag(tfd_time_slice);
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if(DBmem), s=whos; fprintf('tfd: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if(DBcompare)
|
|
115
|
+
Rfull=zeros(N,Nfreq);
|
|
116
|
+
Rfull(:,m+1)=K(:,m+1);
|
|
117
|
+
Rfull(:,Nfreq-mb+1)=conj( Rfull(:,mb+1) );
|
|
118
|
+
|
|
119
|
+
tfd_test=fft( Rfull.' ).';
|
|
120
|
+
dispEE(tfd_test,tfd);
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if(DBmem), s=whos; fprintf('end: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
125
|
+
|
|
126
|
+
scale_factor=1/Nfreq;
|
|
127
|
+
tfd=tfd.*scale_factor;
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
%---------------------------------------------------------------------
|
|
134
|
+
% END; testing and plotting
|
|
135
|
+
%---------------------------------------------------------------------
|
|
136
|
+
if(DBtest)
|
|
137
|
+
if(DBtime), time_start=tic; end
|
|
138
|
+
tfd_test=full_gdtfd_testing_version(x,'pwvd',{P,lag_win_params{2:end}});
|
|
139
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
140
|
+
if(Nfreq==N)
|
|
141
|
+
dispEE(tfd_test,tfd);
|
|
142
|
+
else
|
|
143
|
+
b=N/Nfreq;
|
|
144
|
+
if( b==floor(b) )
|
|
145
|
+
dispEE(tfd_test(:,1:b:end),tfd./b);
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
if(DBplot)
|
|
150
|
+
figure(1); clf;
|
|
151
|
+
vtfd(tfd,real(x(1:N)));
|
|
152
|
+
|
|
153
|
+
figure(9); clf; hold all;
|
|
154
|
+
subplot(211); hold all; plot(sum(tfd')'); plot( abs(z(1:N)).^2 );
|
|
155
|
+
subplot(212); hold all; plot(sum(tfd')' - abs(z(1:N)).^2 );
|
|
156
|
+
end
|
|
157
|
+
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% li_gdtfd: TFD with lag-independent (LI) kernel g[l,m]=G₁[l]
|
|
3
|
+
%
|
|
4
|
+
% Syntax: tfd=li_gdtfd(x,dopp_win_params,Ntime)
|
|
5
|
+
%
|
|
6
|
+
% Inputs:
|
|
7
|
+
% x = input signal (either real-valued signal of length-N or
|
|
8
|
+
% complex-valued analytic signal of length-2N)
|
|
9
|
+
%
|
|
10
|
+
% dopp_win_params = Doppler window parameters in cell form:
|
|
11
|
+
% {win_length,win_type,win_param,Doppler_or_not} where
|
|
12
|
+
% - win_length is the sample length of the window
|
|
13
|
+
% - win_type is the type of window
|
|
14
|
+
% - [optional] win_param is the parameter of the window
|
|
15
|
+
% - [optional] Doppler_or_not is either 1 (define window in the Doppler
|
|
16
|
+
% domain, which is the default) or 0 (define window the time domain)
|
|
17
|
+
% e.g. {121, 'hamm'}; {121, 'tukey', 0.2}; {127,'cosh',0.01,0}
|
|
18
|
+
%
|
|
19
|
+
% Ntime = time oversampling value; must be greater than length of Doppler window
|
|
20
|
+
%
|
|
21
|
+
% Outputs:
|
|
22
|
+
% tfd = Ntime x N time-frequency distribution
|
|
23
|
+
%
|
|
24
|
+
% See also: DEC_LI_GDTFD, GET_ANALYTIC_SIGNAL, GEN_DOPPLER_KERN, FFT
|
|
25
|
+
%
|
|
26
|
+
% Example:
|
|
27
|
+
% N=10000; Ntime=256;
|
|
28
|
+
% x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
|
|
29
|
+
%
|
|
30
|
+
% c=li_gdtfd(x,{51,'hamm'},Ntime);
|
|
31
|
+
% vtfd(c,x);
|
|
32
|
+
%
|
|
33
|
+
% Example:
|
|
34
|
+
%
|
|
35
|
+
%
|
|
36
|
+
|
|
37
|
+
% John M. O' Toole, University College Cork
|
|
38
|
+
% Started: 16-04-2014
|
|
39
|
+
%
|
|
40
|
+
% last update: Time-stamp: <2014-07-23 15:28:16 (otoolej)>
|
|
41
|
+
%-------------------------------------------------------------------------------
|
|
42
|
+
function [tfd,G1]=li_gdtfd(x,dopp_win_params,Ntime)
|
|
43
|
+
if(nargin<2 || isempty(dopp_win_params)), dopp_win_params={11,'hamm',0,1}; end
|
|
44
|
+
if(nargin<3 || isempty(Ntime)), Ntime=[]; end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
DBplot=0;
|
|
48
|
+
DBmem=0;
|
|
49
|
+
DBcompare=0;
|
|
50
|
+
DBtest=0;
|
|
51
|
+
DBtime=0;
|
|
52
|
+
|
|
53
|
+
if(DBtime), time_start=tic; end
|
|
54
|
+
%---------------------------------------------------------------------
|
|
55
|
+
% 1. convert real-valued signal to analytic signal of length 2N
|
|
56
|
+
%---------------------------------------------------------------------
|
|
57
|
+
[z,N2,N,Nh]=get_analytic_signal(x);
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
%---------------------------------------------------------------------
|
|
61
|
+
% 2. generate Doppler--frequency signal function
|
|
62
|
+
% (for positive-Doppler values only)
|
|
63
|
+
%---------------------------------------------------------------------
|
|
64
|
+
[G1,Q,Ntime]=gen_Doppler_kern(dopp_win_params,N,Ntime);
|
|
65
|
+
Nh=ceil(Ntime/2);
|
|
66
|
+
Qh=ceil(Q/2);
|
|
67
|
+
|
|
68
|
+
Z=fft(z);
|
|
69
|
+
if(DBmem), s=whos; fprintf('start: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
70
|
+
tfd=zeros(Ntime,N);
|
|
71
|
+
l_real=1:Qh; l_imag=(Ntime-Qh+1):Ntime;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
l=0:(Qh-1);
|
|
75
|
+
for k=0:N-1
|
|
76
|
+
inp=mod(k+l,N2); inn=mod(k-l,N2);
|
|
77
|
+
inpN=mod(k+l+N,N2); innN=mod(k-l-N,N2);
|
|
78
|
+
K_doppler_slice=G1(l+1).*( Z(inp+1).*conj( Z(inn+1) ) + ...
|
|
79
|
+
Z(inpN+1).*conj( Z(innN+1) ) );
|
|
80
|
+
|
|
81
|
+
tfd(l_real,k+1)=real( K_doppler_slice )./2;
|
|
82
|
+
tfd(l_imag,k+1)=imag( K_doppler_slice )./2;
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
% $$$ Ktesting=zeros(N,ceil(N/2)+1); m=0:(ceil(N/2));
|
|
87
|
+
% $$$ for n=0:N-1
|
|
88
|
+
% $$$ inp=mod(n+m,N2); inn=mod(n-m,N2);
|
|
89
|
+
% $$$ Ktesting(n+1,m+1)=z(inp+1).*conj( z(inn+1) );
|
|
90
|
+
% $$$ end
|
|
91
|
+
% $$$ Kfull=zeros(N); mb=1:(ceil(N/2)-1);
|
|
92
|
+
% $$$ Kfull(:,m+1)=Ktesting(:,m+1);
|
|
93
|
+
% $$$ Kfull(:,N-mb+1)=conj( Ktesting(:,mb+1) );
|
|
94
|
+
% $$$
|
|
95
|
+
% $$$ Ktest=complex(tfd(l_real,:),tfd(l_imag,:));
|
|
96
|
+
% $$$ kk=fft(fft(Kfull.').');
|
|
97
|
+
% $$$ kk=kk(l+1,:).*2;
|
|
98
|
+
% $$$ dispVars(size(kk),size(Ktest));
|
|
99
|
+
% $$$ dispEE(Ktest,kk);
|
|
100
|
+
% $$$ figure(10); clf; vtfd(abs(Ktest));
|
|
101
|
+
% $$$ figure(11); clf; vtfd(abs(Ktest-kk));
|
|
102
|
+
|
|
103
|
+
if(DBcompare)
|
|
104
|
+
K=zeros(Nh,N);
|
|
105
|
+
for k=0:N-1
|
|
106
|
+
inp=mod(k+l,N2); inn=mod(k-l,N2);
|
|
107
|
+
inpN=mod(k+l+N,N2); innN=mod(k-l-N,N2);
|
|
108
|
+
K(l+1,k+1)=G1(l+1).*( Z(inp+1).*conj( Z(inn+1) ) + ...
|
|
109
|
+
Z(inpN+1).*conj( Z(innN+1) ) );
|
|
110
|
+
end
|
|
111
|
+
Ktest=complex(tfd(l_real,:),tfd(l_imag,:));
|
|
112
|
+
dispEE(Ktest,K(l+1,:));
|
|
113
|
+
end
|
|
114
|
+
if(DBmem), s=whos; fprintf('K: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
%-------------------------------------------------------------------------
|
|
120
|
+
% 3. Expand R for positive and negative lag values and DFT back to
|
|
121
|
+
% time--frequency domain
|
|
122
|
+
%-------------------------------------------------------------------------
|
|
123
|
+
l=0:(Qh-1); lb=1:(Qh-1);
|
|
124
|
+
for k=0:2:N-2
|
|
125
|
+
R_even_half=complex(tfd(l_real,k+1),tfd(l_imag,k+1));
|
|
126
|
+
R_odd_half =complex(tfd(l_real,k+2),tfd(l_imag,k+2));
|
|
127
|
+
|
|
128
|
+
R_tslice_even=zeros(Ntime,1); R_tslice_odd=zeros(Ntime,1);
|
|
129
|
+
R_tslice_even(l+1)=R_even_half(l+1);
|
|
130
|
+
R_tslice_odd(l+1) =R_odd_half(l+1);
|
|
131
|
+
R_tslice_even(Ntime-lb+1)=conj( R_even_half(lb+1) );
|
|
132
|
+
R_tslice_odd(Ntime-lb+1) =conj( R_odd_half(lb+1) );
|
|
133
|
+
|
|
134
|
+
tfd_time_slice=ifft( R_tslice_even+j.*R_tslice_odd );
|
|
135
|
+
|
|
136
|
+
tfd(:,k+1)=real(tfd_time_slice);
|
|
137
|
+
tfd(:,k+2)=imag(tfd_time_slice);
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if(DBmem), s=whos; fprintf('tfd: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if(DBcompare)
|
|
145
|
+
Rfull=zeros(Ntime,N);
|
|
146
|
+
Rfull(l+1,:)=K(l+1,:);
|
|
147
|
+
Rfull(Ntime-lb+1,:)=conj( Rfull(lb+1,:) );
|
|
148
|
+
|
|
149
|
+
tfd_test=ifft( Rfull );
|
|
150
|
+
dispEE(tfd_test,tfd);
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
if(DBmem), s=whos; fprintf('end: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
155
|
+
|
|
156
|
+
scale_factor=1/N;
|
|
157
|
+
tfd=tfd.*scale_factor;
|
|
158
|
+
|
|
159
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
%---------------------------------------------------------------------
|
|
163
|
+
% END; testing and plotting
|
|
164
|
+
%---------------------------------------------------------------------
|
|
165
|
+
if(DBtest)
|
|
166
|
+
if(DBtime), time_start=tic; end
|
|
167
|
+
tfd_test=full_gdtfd_testing_version(x,'swvd',dopp_win_params);
|
|
168
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
169
|
+
if(Ntime==N)
|
|
170
|
+
dispEE(tfd_test,tfd);
|
|
171
|
+
else
|
|
172
|
+
a=N/Ntime;
|
|
173
|
+
if( a==floor(a) )
|
|
174
|
+
dispEE(tfd_test(1:a:end,:),tfd./a);
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
if(DBplot)
|
|
179
|
+
figure(1); clf;
|
|
180
|
+
vtfd(tfd,real(x(1:N)));
|
|
181
|
+
|
|
182
|
+
figure(9); clf; hold all;
|
|
183
|
+
Z=fft(z);
|
|
184
|
+
subplot(211); hold all; plot(sum(tfd)); plot( abs(Z(1:N)).^2./(2*N) );
|
|
185
|
+
subplot(212); hold all; plot(sum(tfd)' - abs(Z(1:N)).^2./(2*N) );
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|