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,194 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% dec_di_gdtfd: decimated Doppler-independent kernel TFD ρ[nᵢ,bk], where b is an
|
|
3
|
+
% integer value and nᵢ is the set nᵢ ={ nᵢ | 1≤i≤U }, with 0≤nᵢ≤N-1
|
|
4
|
+
%
|
|
5
|
+
% Syntax: tfd=dec_di_gdtfd(x,lag_win_params,time_dec,freq_dec,Nfreq)
|
|
6
|
+
%
|
|
7
|
+
% Inputs:
|
|
8
|
+
% x = input signal (either real-valued signal of length-N or
|
|
9
|
+
% complex-valued analytic signal of length-2N)
|
|
10
|
+
%
|
|
11
|
+
% lag_win_params = lag window parameters in cell form:
|
|
12
|
+
% {win_length,win_type,win_param,lag_or_not} where
|
|
13
|
+
% - win_length is the sample length of the window
|
|
14
|
+
% - win_type is the type of window
|
|
15
|
+
% - [optional] win_param is the parameter of the window
|
|
16
|
+
% - [optional] lag_or_not is either 0 (define window in the lag
|
|
17
|
+
% domain, which is the default) or 0 (define window the frequency domain)
|
|
18
|
+
% e.g. {121, 'hamm'}; {121, 'tukey', 0.2}; {127,'cosh',0.01,0}
|
|
19
|
+
%
|
|
20
|
+
% time_dec = decimation factor a in the time domain; a/Ntime is integer
|
|
21
|
+
% freq_dec = decimation factor b in the frequency domain; b/Nfreq is integer
|
|
22
|
+
%
|
|
23
|
+
% Nfreq = frequency oversampling value; must be greater than length of lag window
|
|
24
|
+
%
|
|
25
|
+
% See also: DI_GDTFD, GET_ANALYTIC_SIGNAL, GEN_LAG_KERN, FFT
|
|
26
|
+
%
|
|
27
|
+
% Outputs:
|
|
28
|
+
% tfd = U x (b/Nfreq) time–frequency distribution
|
|
29
|
+
%
|
|
30
|
+
% Example:
|
|
31
|
+
% N=1024; Nfreq=128; ni=[100:4:900]; b=2;
|
|
32
|
+
% x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
|
|
33
|
+
%
|
|
34
|
+
% c=dec_di_gdtfd(x,{101,'hann'},ni,b,Nfreq);
|
|
35
|
+
% vtfd(c,x,1,ni);
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
% John M. O' Toole, University College Cork
|
|
39
|
+
% Started: 23-04-2014
|
|
40
|
+
%
|
|
41
|
+
% last update: Time-stamp: <2014-07-23 16:22:59 (otoolej)>
|
|
42
|
+
%-------------------------------------------------------------------------------
|
|
43
|
+
function tfd=dec_di_gdtfd(x,lag_win_params,time_dec,freq_dec,Nfreq)
|
|
44
|
+
if(nargin<2 || isempty(lag_win_params)), lag_win_params={101,'hamm'}; end
|
|
45
|
+
if(nargin<3 || isempty(time_dec)), time_dec=[]; end
|
|
46
|
+
if(nargin<4 || isempty(freq_dec)), freq_dec=1; end
|
|
47
|
+
if(nargin<5 || isempty(Nfreq)), Nfreq=[]; end
|
|
48
|
+
|
|
49
|
+
DBplot=0;
|
|
50
|
+
DBmem=0;
|
|
51
|
+
DBtest=0;
|
|
52
|
+
DBtime=0;
|
|
53
|
+
DBverbose=0;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if(DBtime), time_start=tic; end
|
|
57
|
+
%---------------------------------------------------------------------
|
|
58
|
+
% 1. convert real-valued signal to analytic signal of length 2N
|
|
59
|
+
%---------------------------------------------------------------------
|
|
60
|
+
[z,N2,N,Nh]=get_analytic_signal(x);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
%---------------------------------------------------------------------
|
|
64
|
+
% 2. generate time--lag signal function (for positive-lag values only)
|
|
65
|
+
%---------------------------------------------------------------------
|
|
66
|
+
[g2,P,Ph_floor,Nfreq]=gen_lag_kern(lag_win_params,N,Nfreq);
|
|
67
|
+
Nh=ceil(Nfreq/2);
|
|
68
|
+
Ph=ceil(P/2);
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
% check decimation parameters and return as sequence:
|
|
72
|
+
if(length(freq_dec)>1)
|
|
73
|
+
error('Frequency decimation parameter should be scalar');
|
|
74
|
+
end
|
|
75
|
+
[n_seq,U]=check_dec_params_seq(time_dec,N,'time',0);
|
|
76
|
+
[k_seq,J,freq_dec]=check_dec_params_seq(freq_dec,Nfreq,'frequency',1);
|
|
77
|
+
Jh=ceil(J/2); J_extend=2*Jh+2;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if(DBmem), s=whos; fprintf('start: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
81
|
+
tfd=zeros(U,J_extend);
|
|
82
|
+
if(J~=Nfreq)
|
|
83
|
+
m_real=1:Jh+1; m_imag=(J_extend-Jh):(J_extend);
|
|
84
|
+
else
|
|
85
|
+
m_real=1:Ph; m_imag=(J-Ph+1):J;
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
m=0:(Ph-1); mb=1:(Ph-1);
|
|
91
|
+
for in=1:U
|
|
92
|
+
n=n_seq(in);
|
|
93
|
+
inp=mod(n+m,N2); inn=mod(n-m,N2);
|
|
94
|
+
|
|
95
|
+
if(J~=Nfreq)
|
|
96
|
+
% need to fold signal function (for decimation in frequency-direction):
|
|
97
|
+
K_time_slice=zeros(1,Nfreq);
|
|
98
|
+
K_time_slice(m+1)=g2(m+1).*z(inp+1).*conj( z(inn+1) );
|
|
99
|
+
K_time_slice(Nfreq-mb+1)=conj(K_time_slice(mb+1));
|
|
100
|
+
|
|
101
|
+
R_fold=fold_vector_half(K_time_slice,J,Jh,freq_dec);
|
|
102
|
+
else
|
|
103
|
+
% or if not then do as usual:
|
|
104
|
+
K_time_slice(m+1)=g2(m+1).*z(inp+1).*conj( z(inn+1) );
|
|
105
|
+
|
|
106
|
+
R_fold=K_time_slice;
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
tfd(in,m_real)=real( R_fold );
|
|
110
|
+
tfd(in,m_imag)=imag( R_fold );
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if(DBmem), s=whos; fprintf('K: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
%-------------------------------------------------------------------------
|
|
117
|
+
% 3. Expand R for positive and negative lag values and DFT back to
|
|
118
|
+
% time--frequency domain
|
|
119
|
+
%-------------------------------------------------------------------------
|
|
120
|
+
if(J~=Nfreq)
|
|
121
|
+
m=0:Jh; mb=1:(Jh-1);
|
|
122
|
+
else
|
|
123
|
+
m=0:(Ph-1); mb=1:(Ph-1);
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
for n=0:2:(U-2)
|
|
128
|
+
R_even_half=complex(tfd(n+1,m_real),tfd(n+1,m_imag));
|
|
129
|
+
R_odd_half =complex(tfd(n+2,m_real),tfd(n+2,m_imag));
|
|
130
|
+
|
|
131
|
+
R_tslice_even=zeros(1,J); R_tslice_odd=zeros(1,J);
|
|
132
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
133
|
+
R_tslice_odd(m+1) =R_odd_half(m+1);
|
|
134
|
+
R_tslice_even(J-mb+1)=conj( R_even_half(mb+1) );
|
|
135
|
+
R_tslice_odd(J-mb+1) =conj( R_odd_half(mb+1) );
|
|
136
|
+
|
|
137
|
+
tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
138
|
+
|
|
139
|
+
tfd(n+1,1:J)=real(tfd_time_slice);
|
|
140
|
+
tfd(n+2,1:J)=imag(tfd_time_slice);
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
% one extra FFT if U is odd:
|
|
144
|
+
if(rem(U,2))
|
|
145
|
+
R_even_half=complex(tfd(U,m_real),tfd(U,m_imag));
|
|
146
|
+
R_tslice_even=zeros(1,J);
|
|
147
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
148
|
+
R_tslice_even(J-mb+1)=conj( R_even_half(mb+1) );
|
|
149
|
+
tfd_time_slice=fft( R_tslice_even );
|
|
150
|
+
|
|
151
|
+
tfd(U,1:J)=real(tfd_time_slice);
|
|
152
|
+
end
|
|
153
|
+
tfd=tfd(:,1:J);
|
|
154
|
+
|
|
155
|
+
if(DBmem), s=whos; fprintf('end: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
156
|
+
|
|
157
|
+
scale_factor=1/Nfreq;
|
|
158
|
+
tfd=tfd.*scale_factor;
|
|
159
|
+
|
|
160
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
%---------------------------------------------------------------------
|
|
164
|
+
% END; testing and plotting
|
|
165
|
+
%---------------------------------------------------------------------
|
|
166
|
+
if(DBtest)
|
|
167
|
+
if(DBtime), time_start=tic; end
|
|
168
|
+
tfd_test=full_gdtfd_testing_version(x,'pwvd',{P,lag_win_params{2:end}});
|
|
169
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
170
|
+
|
|
171
|
+
if(Nfreq==N)
|
|
172
|
+
dispEE(tfd_test(n_seq+1,k_seq+1),tfd);
|
|
173
|
+
else
|
|
174
|
+
b=N/Nfreq;
|
|
175
|
+
if( b==floor(b) )
|
|
176
|
+
dispEE(tfd_test(n_seq+1,(b.*k_seq)+1),tfd./b);
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
181
|
+
if(DBverbose)
|
|
182
|
+
fprintf('size=%dx%d; max=%g; total energ:%d\n', size(tfd,1), size(tfd,2), max(tfd(:)), ...
|
|
183
|
+
sum(tfd(:)));
|
|
184
|
+
end
|
|
185
|
+
if(DBplot)
|
|
186
|
+
figure(1); clf;
|
|
187
|
+
vtfd(tfd,real(x(1:N)));
|
|
188
|
+
|
|
189
|
+
figure(9); clf; hold all;
|
|
190
|
+
subplot(211); hold all; plot(sum(tfd')'); plot( abs(z(1:N)).^2 );
|
|
191
|
+
subplot(212); hold all; plot(sum(tfd')' - abs(z(n_seq+1)).^2 );
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% dec_li_gdtfd: decimated lag-independent kernel TFD ρ[an,kᵢ], where a is an integer
|
|
3
|
+
% value and kᵢ is the set kᵢ ={ kᵢ | 1≤i≤V }, with 0≤kᵢ≤N-1
|
|
4
|
+
%
|
|
5
|
+
% Syntax: tfd=dec_li_gdtfd(x,dopp_win_params,time_dec,freq_dec,Ntime)
|
|
6
|
+
%
|
|
7
|
+
% Inputs:
|
|
8
|
+
% x = input signal (either real-valued signal of length-N or
|
|
9
|
+
% complex-valued analytic signal of length-2N)
|
|
10
|
+
%
|
|
11
|
+
% dopp_win_params = Doppler window parameters in cell form:
|
|
12
|
+
% {win_length,win_type,win_param,Doppler_or_not} where
|
|
13
|
+
% - win_length is the sample length of the window
|
|
14
|
+
% - win_type is the type of window
|
|
15
|
+
% - [optional] win_param is the parameter of the window
|
|
16
|
+
% - [optional] Doppler_or_not is either 1 (define window in the Doppler
|
|
17
|
+
% domain, which is the default) or 0 (define window in the time domain)
|
|
18
|
+
% e.g. {121, 'hamm'}; {121, 'tukey', 0.2}; {127,'cosh',0.01,0}
|
|
19
|
+
%
|
|
20
|
+
% time_dec = decimation factor a in the time domain; a/Ntime is integer
|
|
21
|
+
% freq_dec = decimation factor b in the frequency domain; b/Nfreq is integer
|
|
22
|
+
%
|
|
23
|
+
% Ntime = time oversampling value; must be greater than length of Doppler window
|
|
24
|
+
%
|
|
25
|
+
% Outputs:
|
|
26
|
+
% tfd = (a/Ntime) x V time–frequency distribution
|
|
27
|
+
%
|
|
28
|
+
% See also: LI_GDTFD, GET_ANALYTIC_SIGNAL, GEN_DOPPLER_KERN, FFT
|
|
29
|
+
%
|
|
30
|
+
% Example:
|
|
31
|
+
% N=1024; Ntime=64; a=2; ki=[150:4:850];
|
|
32
|
+
% x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
|
|
33
|
+
%
|
|
34
|
+
% c=dec_li_gdtfd(x,{51,'hann'},a,ki,Ntime);
|
|
35
|
+
% vtfd(c,x,1,[],ki./(N*2));
|
|
36
|
+
|
|
37
|
+
% John M. O' Toole, University College Cork
|
|
38
|
+
% Started: 23-04-2014
|
|
39
|
+
%
|
|
40
|
+
% last update: Time-stamp: <2014-07-23 16:19:59 (otoolej)>
|
|
41
|
+
%-------------------------------------------------------------------------------
|
|
42
|
+
function tfd=dec_li_gdtfd(x,dopp_win_params,time_dec,freq_dec,Ntime)
|
|
43
|
+
if(nargin<2 || isempty(dopp_win_params)), dopp_win_params={51,'hann'}; end
|
|
44
|
+
if(nargin<3 || isempty(time_dec)), time_dec=1; end
|
|
45
|
+
if(nargin<4 || isempty(freq_dec)), freq_dec=1; end
|
|
46
|
+
if(nargin<5 || isempty(Ntime)), Ntime=[]; end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
DBplot=0;
|
|
50
|
+
DBmem=0;
|
|
51
|
+
DBtest=0;
|
|
52
|
+
DBtime=0;
|
|
53
|
+
DBverbose=0;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if(DBtime), time_start=tic; end
|
|
57
|
+
%---------------------------------------------------------------------
|
|
58
|
+
% 1. convert real-valued signal to analytic signal of length 2N
|
|
59
|
+
%---------------------------------------------------------------------
|
|
60
|
+
[z,N2,N,Nh]=get_analytic_signal(x);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
%---------------------------------------------------------------------
|
|
64
|
+
% 2. generate time--lag signal function (for positive-lag values only)
|
|
65
|
+
%---------------------------------------------------------------------
|
|
66
|
+
[G1,Q,Ntime]=gen_Doppler_kern(dopp_win_params,N,Ntime);
|
|
67
|
+
Qh=ceil(Q/2);
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
% check decimation parameters and return as sequence:
|
|
71
|
+
if(length(time_dec)>1)
|
|
72
|
+
error('Frequency decimation parameter should be scalar');
|
|
73
|
+
end
|
|
74
|
+
[n_seq,L,time_dec]=check_dec_params_seq(time_dec,Ntime,'time',1);
|
|
75
|
+
[k_seq,V]=check_dec_params_seq(freq_dec,N,'frequency',0);
|
|
76
|
+
Lh=ceil(L/2); L_extend=2*Lh+2;
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if(DBmem), s=whos; fprintf('start: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
80
|
+
tfd=zeros(L_extend,V);
|
|
81
|
+
if(L~=Ntime)
|
|
82
|
+
l_real=1:(Lh+1); l_imag=(L_extend-Lh):L_extend;
|
|
83
|
+
else
|
|
84
|
+
l_real=1:Qh; l_imag=(L-Qh+1):L;
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
Z=fft(z);
|
|
89
|
+
l=0:(Qh-1); lb=1:(Qh-1);
|
|
90
|
+
for ik=1:V
|
|
91
|
+
k=k_seq(ik);
|
|
92
|
+
inp=mod(k+l,N2); inn=mod(k-l,N2);
|
|
93
|
+
inpN=mod(k+l+N,N2); innN=mod(k-l-N,N2);
|
|
94
|
+
|
|
95
|
+
if(L~=Ntime)
|
|
96
|
+
K_doppler_slice=zeros(1,Ntime);
|
|
97
|
+
K_doppler_slice(l+1)=G1(l+1).*( Z(inp+1).*conj( Z(inn+1) ) + ...
|
|
98
|
+
Z(inpN+1).*conj( Z(innN+1) ) );
|
|
99
|
+
K_doppler_slice(Ntime-lb+1)=conj( K_doppler_slice(lb+1) );
|
|
100
|
+
|
|
101
|
+
R_fold=fold_vector_half(K_doppler_slice./2,L,Lh,time_dec);
|
|
102
|
+
else
|
|
103
|
+
|
|
104
|
+
K_doppler_slice=G1(l+1).*( Z(inp+1).*conj( Z(inn+1) ) + ...
|
|
105
|
+
Z(inpN+1).*conj( Z(innN+1) ) );
|
|
106
|
+
|
|
107
|
+
R_fold=K_doppler_slice;
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
tfd(l_real,ik)=real( R_fold );
|
|
111
|
+
tfd(l_imag,ik)=imag( R_fold );
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if(DBmem), s=whos; fprintf('K: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
%-------------------------------------------------------------------------
|
|
120
|
+
% 3. Expand R for positive and negative lag values and DFT back to
|
|
121
|
+
% time--frequency domain
|
|
122
|
+
%-------------------------------------------------------------------------
|
|
123
|
+
if(L~=Ntime)
|
|
124
|
+
l=0:Lh; lb=1:(Lh-1);
|
|
125
|
+
else
|
|
126
|
+
l=0:(Qh-1); lb=1:(Qh-1);
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
for k=0:2:(V-2)
|
|
130
|
+
R_even_half=complex(tfd(l_real,k+1),tfd(l_imag,k+1));
|
|
131
|
+
R_odd_half =complex(tfd(l_real,k+2),tfd(l_imag,k+2));
|
|
132
|
+
|
|
133
|
+
R_tslice_even=zeros(L,1); R_tslice_odd=zeros(L,1);
|
|
134
|
+
R_tslice_even(l+1)=R_even_half(l+1);
|
|
135
|
+
R_tslice_odd(l+1) =R_odd_half(l+1);
|
|
136
|
+
R_tslice_even(L-lb+1)=conj( R_even_half(lb+1) );
|
|
137
|
+
R_tslice_odd(L-lb+1) =conj( R_odd_half(lb+1) );
|
|
138
|
+
|
|
139
|
+
tfd_freq_slice=ifft( R_tslice_even+j.*R_tslice_odd );
|
|
140
|
+
|
|
141
|
+
tfd(1:L,k+1)=real(tfd_freq_slice);
|
|
142
|
+
tfd(1:L,k+2)=imag(tfd_freq_slice);
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
% one extra FFT if V is odd
|
|
146
|
+
if(rem(V,2))
|
|
147
|
+
R_even_half=complex(tfd(l_real,V),tfd(l_imag,V));
|
|
148
|
+
|
|
149
|
+
R_tslice_even=zeros(L,1);
|
|
150
|
+
R_tslice_even(l+1)=R_even_half(l+1);
|
|
151
|
+
R_tslice_even(L-lb+1)=conj( R_even_half(lb+1) );
|
|
152
|
+
|
|
153
|
+
tfd_freq_slice=ifft( R_tslice_even );
|
|
154
|
+
|
|
155
|
+
tfd(1:L,V)=real(tfd_freq_slice);
|
|
156
|
+
end
|
|
157
|
+
tfd=tfd(1:L,:);
|
|
158
|
+
|
|
159
|
+
if(DBmem), s=whos; fprintf('tfd (end): mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if(time_dec==1)
|
|
163
|
+
scale_factor=1/(2*N);
|
|
164
|
+
else
|
|
165
|
+
scale_factor=1/(N*time_dec);
|
|
166
|
+
end
|
|
167
|
+
tfd=tfd.*scale_factor;
|
|
168
|
+
|
|
169
|
+
if(DBtime), dispVars( ['time: ' num2str(toc(time_start))] ); end
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
%---------------------------------------------------------------------
|
|
173
|
+
% END; testing and plotting
|
|
174
|
+
%---------------------------------------------------------------------
|
|
175
|
+
if(DBtest)
|
|
176
|
+
if(DBtime), time_start=tic; end
|
|
177
|
+
tfd_test=full_gdtfd_testing_version(x,'swvd',{Q,dopp_win_params{2:end}});
|
|
178
|
+
if(DBtime), dispVars( ['testing time: ' num2str(toc(time_start))] ); end
|
|
179
|
+
if(Ntime==N)
|
|
180
|
+
dispEE(tfd_test(n_seq+1,k_seq+1),tfd);
|
|
181
|
+
else
|
|
182
|
+
a=N/Ntime;
|
|
183
|
+
if( a==floor(a) )
|
|
184
|
+
dispEE(tfd_test((a.*n_seq)+1,k_seq+1),tfd./a);
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
if(DBverbose)
|
|
189
|
+
fprintf('size=%dx%d; max=%g; total energ:%d\n', size(tfd,1), size(tfd,2), max(tfd(:)), ...
|
|
190
|
+
sum(tfd(:)));
|
|
191
|
+
end
|
|
192
|
+
if(DBplot)
|
|
193
|
+
figure(1); clf;
|
|
194
|
+
vtfd(tfd,real(x(1:N)));
|
|
195
|
+
|
|
196
|
+
figure(9); clf; hold all;
|
|
197
|
+
Z=fft(z);
|
|
198
|
+
subplot(211); hold all; plot(sum(tfd)); plot( abs(Z(1:N)).^2./(2*N) );
|
|
199
|
+
subplot(212); hold all; plot(sum(tfd)' - abs(Z(k_seq+1)).^2./(2*N) );
|
|
200
|
+
end
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% dec_nonsep_gdtfd: decimated TFD with non-separable kernel ρ[an,bk], where a,b are
|
|
3
|
+
% integer values
|
|
4
|
+
%
|
|
5
|
+
%
|
|
6
|
+
% Syntax: tfd=dec_nonsep_gdtfd(x,kern_type,kern_params,time_dec,freq_dec)
|
|
7
|
+
%
|
|
8
|
+
% Inputs:
|
|
9
|
+
% x = input signal (either real-valued signal of length-N or
|
|
10
|
+
% complex-valued analytic signal of length-2N)
|
|
11
|
+
%
|
|
12
|
+
% kern_type = { 'wvd' | 'swvd' | 'pwvd' | 'sep' | 'cw' | 'mb' }
|
|
13
|
+
% wvd - Wigner-Ville distribution
|
|
14
|
+
% swvd - Smoothed Wigner-Ville distribution
|
|
15
|
+
% (lag-independent kernel)
|
|
16
|
+
% pwvd - Pseudo Wigner-Ville distribution
|
|
17
|
+
% (Doppler-independent kernel)
|
|
18
|
+
% sep - Separable-kernel distribution
|
|
19
|
+
% (combintation of SWVD and PWVD)
|
|
20
|
+
% mb - Modified-B distribution
|
|
21
|
+
% cw - Choi-Williams distribution
|
|
22
|
+
%
|
|
23
|
+
% kern_params = cell of kernel parameters:
|
|
24
|
+
% wvd - {}
|
|
25
|
+
% swvd - {win_length,win_type,[win_param]}
|
|
26
|
+
% e.g. {11,'hamm'}
|
|
27
|
+
% pwvd - {win_length,win_type,[win_param]}
|
|
28
|
+
% e.g. {200,'cosh',0.1}
|
|
29
|
+
% sep - { {win1_length,win1_type,[win1_param]},
|
|
30
|
+
% {win2_length,win2_type,[win2_param]} }
|
|
31
|
+
% where win1 is the doppler window and win2 is the
|
|
32
|
+
% lag window, e.g. { {11,'hamm'}, {200,'cosh',0.1} }
|
|
33
|
+
% mb - {beta_parameter} in the range 1<beta<0
|
|
34
|
+
% cw - {sigma_parameter}
|
|
35
|
+
%
|
|
36
|
+
% time_dec = decimation factor a in the time domain; a/N is integer
|
|
37
|
+
% freq_dec = decimation factor b in the frequency domain; b/N is integer
|
|
38
|
+
%
|
|
39
|
+
% Outputs:
|
|
40
|
+
% tfd = a/N x b/N time–frequency distribution
|
|
41
|
+
%
|
|
42
|
+
% See also: NONSEP_GDTFD, GET_ANALYTIC_SIGNAL, GEN_DOPPLER_LAG_KERN, FFT
|
|
43
|
+
%
|
|
44
|
+
% Example:
|
|
45
|
+
% N=1024; a=2; b=8;
|
|
46
|
+
% x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
|
|
47
|
+
% c=dec_nonsep_gdtfd(x,'cw',{100},a,b);
|
|
48
|
+
% vtfd(c,x);
|
|
49
|
+
|
|
50
|
+
% John M. O' Toole, University College Cork
|
|
51
|
+
% Started: 23-04-2014
|
|
52
|
+
%
|
|
53
|
+
% last update: Time-stamp: <2014-09-15 13:19:16 (otoolej)>
|
|
54
|
+
%-------------------------------------------------------------------------------
|
|
55
|
+
function tfd=dec_nonsep_gdtfd(x,kern_type,kern_params,time_dec,freq_dec)
|
|
56
|
+
if(nargin<2 || isempty(kern_type)), kern_type='cw'; end
|
|
57
|
+
if(nargin<3 || isempty(kern_params)), kern_params=10; end
|
|
58
|
+
if(nargin<4 || isempty(time_dec)), time_dec=1; end
|
|
59
|
+
if(nargin<5 || isempty(freq_dec)), freq_dec=1; end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
DBplot=0;
|
|
63
|
+
DBmem=0;
|
|
64
|
+
DBtest=0;
|
|
65
|
+
DBtime=0;
|
|
66
|
+
DBverbose=0;
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if(DBtime), time_start=tic; end
|
|
70
|
+
%---------------------------------------------------------------------
|
|
71
|
+
% 1. convert real-valued signal to analytic signal of length 2N
|
|
72
|
+
%---------------------------------------------------------------------
|
|
73
|
+
[z,N2,N,Nh]=get_analytic_signal(x);
|
|
74
|
+
|
|
75
|
+
% if product-kernel then generate window now:
|
|
76
|
+
G1=get_prod_kernel(kern_type,kern_params,N);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
%---------------------------------------------------------------------
|
|
80
|
+
% 2. check decimation parameters
|
|
81
|
+
%---------------------------------------------------------------------
|
|
82
|
+
if(length(time_dec)>1 || length(freq_dec)>1)
|
|
83
|
+
error('Frequency and time decimation parameters should be scalar');
|
|
84
|
+
end
|
|
85
|
+
[n_seq,L,time_dec]=check_dec_params_seq(time_dec,N,'time',1);
|
|
86
|
+
[k_seq,J,freq_dec]=check_dec_params_seq(freq_dec,N,'frequency',1);
|
|
87
|
+
Jh=ceil(J/2); J_extend=2*Jh+2;
|
|
88
|
+
|
|
89
|
+
if(DBmem), s=whos; fprintf('start: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
90
|
+
|
|
91
|
+
tfd=zeros(L,J_extend);
|
|
92
|
+
m_real=1:Jh+1; m_imag=(J_extend-Jh):(J_extend);
|
|
93
|
+
|
|
94
|
+
if(DBmem), s=whos; fprintf('declare TFD: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
%---------------------------------------------------------------------
|
|
98
|
+
% 3. generate time--lag signal function (for positive-lag values only)
|
|
99
|
+
%---------------------------------------------------------------------
|
|
100
|
+
n=0:N-1; mb=1:Jh-1;
|
|
101
|
+
for m=0:Jh
|
|
102
|
+
|
|
103
|
+
%------------------------------------
|
|
104
|
+
% Fold in the lag direction
|
|
105
|
+
%------------------------------------
|
|
106
|
+
af_lag_slice=zeros(N,1);
|
|
107
|
+
for p=0:freq_dec-1
|
|
108
|
+
mmod=(p*J+m);
|
|
109
|
+
g_lag_slice=gen_Doppler_lag_kern(kern_type,kern_params,N,mmod+1);
|
|
110
|
+
|
|
111
|
+
if(mmod<=Nh)
|
|
112
|
+
inp=mod(n+mmod,N2); inn=mod(n-mmod,N2);
|
|
113
|
+
K_lag_slice=z(inp+1).*conj(z(inn+1));
|
|
114
|
+
else
|
|
115
|
+
inp=mod(n+N-mmod,N2); inn=mod(n-N+mmod,N2);
|
|
116
|
+
K_lag_slice=conj(z(inp+1)).*z(inn+1);
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
af_lag_slice=af_lag_slice + fft(K_lag_slice).*g_lag_slice;
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
%------------------------------------
|
|
123
|
+
% Fold in the Doppler direction
|
|
124
|
+
%------------------------------------
|
|
125
|
+
af_lag_fold=fold_vector_full(af_lag_slice,L,time_dec);
|
|
126
|
+
|
|
127
|
+
%------------------------------------
|
|
128
|
+
% DFT the lag slice to the time--lag
|
|
129
|
+
% domain.
|
|
130
|
+
%------------------------------------
|
|
131
|
+
R_lag_slice=ifft(af_lag_fold);
|
|
132
|
+
tfd(:,m_real(m+1))=real(R_lag_slice);
|
|
133
|
+
tfd(:,m_imag(m+1))=imag(R_lag_slice);
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
if(DBmem), s=whos; fprintf('R: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
138
|
+
|
|
139
|
+
%-------------------------------------------------------------------------
|
|
140
|
+
% 4. Expand R for positive and negative lag values and DFT back to
|
|
141
|
+
% time--frequency domain
|
|
142
|
+
%-------------------------------------------------------------------------
|
|
143
|
+
m=0:Jh; mb=1:(Jh-1);
|
|
144
|
+
for n=0:2:(L-2)
|
|
145
|
+
R_even_half=complex(tfd(n+1,m_real),tfd(n+1,m_imag));
|
|
146
|
+
R_odd_half =complex(tfd(n+2,m_real),tfd(n+2,m_imag));
|
|
147
|
+
|
|
148
|
+
R_tslice_even=zeros(J,1); R_tslice_odd=zeros(J,1);
|
|
149
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
150
|
+
R_tslice_odd(m+1) =R_odd_half(m+1);
|
|
151
|
+
R_tslice_even(J-mb+1)=conj( R_even_half(mb+1) );
|
|
152
|
+
R_tslice_odd(J-mb+1) =conj( R_odd_half(mb+1) );
|
|
153
|
+
|
|
154
|
+
tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
155
|
+
|
|
156
|
+
tfd(n+1,1:J)=real(tfd_time_slice);
|
|
157
|
+
tfd(n+2,1:J)=imag(tfd_time_slice);
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
% one extra FFT if L is odd:
|
|
162
|
+
if(rem(L,2))
|
|
163
|
+
R_even_half=complex(tfd(L,m_real),tfd(L,m_imag));
|
|
164
|
+
|
|
165
|
+
R_tslice_even=zeros(J,1);
|
|
166
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
167
|
+
R_tslice_even(J-mb+1)=conj( R_even_half(mb+1) );
|
|
168
|
+
|
|
169
|
+
tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
170
|
+
|
|
171
|
+
tfd(L,1:J)=real(tfd_time_slice);
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
tfd=tfd(:,1:J);
|
|
175
|
+
|
|
176
|
+
if(DBmem), s=whos; fprintf('end: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
177
|
+
|
|
178
|
+
scale_factor=1/N;
|
|
179
|
+
tfd=tfd.*scale_factor;
|
|
180
|
+
|
|
181
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
%---------------------------------------------------------------------
|
|
185
|
+
% END; testing and plotting
|
|
186
|
+
%---------------------------------------------------------------------
|
|
187
|
+
if(DBtest)
|
|
188
|
+
if(DBtime), time_start=tic; end
|
|
189
|
+
tfd_test=full_gdtfd_testing_version(x,kern_type,kern_params);
|
|
190
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
191
|
+
|
|
192
|
+
dispEE(tfd_test(n_seq+1,k_seq+1),tfd);
|
|
193
|
+
end
|
|
194
|
+
if(DBverbose)
|
|
195
|
+
fprintf('size=%dx%d; max=%g; total energ:%d\n', size(tfd,1), size(tfd,2), max(tfd(:)), ...
|
|
196
|
+
sum(tfd(:)));
|
|
197
|
+
end
|
|
198
|
+
if(DBplot)
|
|
199
|
+
figure(1); clf;
|
|
200
|
+
vtfd(tfd,real(x(1:N)));
|
|
201
|
+
|
|
202
|
+
figure(9); clf; hold all;
|
|
203
|
+
subplot(211); hold all; plot(sum(tfd')'); plot( abs(z(1:N)).^2 );
|
|
204
|
+
subplot(212); hold all; plot(sum(tfd')' - abs(z(n_seq+1)).^2 );
|
|
205
|
+
|
|
206
|
+
figure(10); clf; hold all;
|
|
207
|
+
Z=fft(z);
|
|
208
|
+
subplot(211); hold all; plot(sum(tfd)); plot( abs(Z(1:N)).^2./(2*N) );
|
|
209
|
+
subplot(212); hold all; plot(sum(tfd)' - abs(Z(k_seq+1)).^2./(2*N) );
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
function G1=get_prod_kernel(tfd_type,tfd_params,N)
|
|
215
|
+
%---------------------------------------------------------------------
|
|
216
|
+
% Generate window for product-kernel
|
|
217
|
+
%---------------------------------------------------------------------
|
|
218
|
+
|
|
219
|
+
if( strcmp(tfd_type,'RID')==1 || strcmp(tfd_type,'prod')==1 || ...
|
|
220
|
+
strcmp(tfd_type,'product')==1 )
|
|
221
|
+
|
|
222
|
+
% $$$ % oversample the window:
|
|
223
|
+
% $$$ L_dopp=N*N2;
|
|
224
|
+
|
|
225
|
+
G1=gen_Doppler_kern(tfd_params,N);
|
|
226
|
+
G1=real(G1);
|
|
227
|
+
else
|
|
228
|
+
G1=[];
|
|
229
|
+
end
|