paradigma 0.1.5__py3-none-any.whl → 0.3.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.
Files changed (112) hide show
  1. paradigma/__init__.py +1 -3
  2. paradigma/constants.py +65 -0
  3. paradigma/feature_extraction.py +703 -0
  4. paradigma/gait_analysis.py +415 -0
  5. paradigma/gait_analysis_config.py +266 -0
  6. paradigma/heart_rate_analysis.py +127 -0
  7. paradigma/heart_rate_analysis_config.py +9 -0
  8. paradigma/heart_rate_util.py +173 -0
  9. paradigma/imu_preprocessing.py +232 -0
  10. paradigma/ppg/classifier/LR_PPG_quality.pkl +0 -0
  11. paradigma/ppg/classifier/LR_model.mat +0 -0
  12. paradigma/ppg/feat_extraction/acc_feature.m +20 -0
  13. paradigma/ppg/feat_extraction/peakdet.m +64 -0
  14. paradigma/ppg/feat_extraction/ppg_features.m +53 -0
  15. paradigma/ppg/glob_functions/extract_hr_segments.m +37 -0
  16. paradigma/ppg/glob_functions/extract_overlapping_segments.m +23 -0
  17. paradigma/ppg/glob_functions/jsonlab/AUTHORS.txt +41 -0
  18. paradigma/ppg/glob_functions/jsonlab/ChangeLog.txt +74 -0
  19. paradigma/ppg/glob_functions/jsonlab/LICENSE_BSD.txt +25 -0
  20. paradigma/ppg/glob_functions/jsonlab/LICENSE_GPLv3.txt +699 -0
  21. paradigma/ppg/glob_functions/jsonlab/README.txt +394 -0
  22. paradigma/ppg/glob_functions/jsonlab/examples/.svn/entries +368 -0
  23. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/demo_jsonlab_basic.m.svn-base +180 -0
  24. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/demo_ubjson_basic.m.svn-base +180 -0
  25. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example1.json.svn-base +23 -0
  26. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example2.json.svn-base +22 -0
  27. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example3.json.svn-base +11 -0
  28. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example4.json.svn-base +34 -0
  29. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_basictest.matlab.svn-base +662 -0
  30. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_selftest.m.svn-base +27 -0
  31. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_selftest.matlab.svn-base +144 -0
  32. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_speedtest.m.svn-base +21 -0
  33. paradigma/ppg/glob_functions/jsonlab/examples/demo_jsonlab_basic.m +180 -0
  34. paradigma/ppg/glob_functions/jsonlab/examples/demo_ubjson_basic.m +180 -0
  35. paradigma/ppg/glob_functions/jsonlab/examples/example1.json +23 -0
  36. paradigma/ppg/glob_functions/jsonlab/examples/example2.json +22 -0
  37. paradigma/ppg/glob_functions/jsonlab/examples/example3.json +11 -0
  38. paradigma/ppg/glob_functions/jsonlab/examples/example4.json +34 -0
  39. paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_basictest.matlab +662 -0
  40. paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_selftest.m +27 -0
  41. paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_selftest.matlab +144 -0
  42. paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_speedtest.m +21 -0
  43. paradigma/ppg/glob_functions/jsonlab/jsonopt.m +32 -0
  44. paradigma/ppg/glob_functions/jsonlab/loadjson.m +566 -0
  45. paradigma/ppg/glob_functions/jsonlab/loadubjson.m +528 -0
  46. paradigma/ppg/glob_functions/jsonlab/mergestruct.m +33 -0
  47. paradigma/ppg/glob_functions/jsonlab/savejson.m +475 -0
  48. paradigma/ppg/glob_functions/jsonlab/saveubjson.m +504 -0
  49. paradigma/ppg/glob_functions/jsonlab/varargin2struct.m +40 -0
  50. paradigma/ppg/glob_functions/sample_prob_final.m +49 -0
  51. paradigma/ppg/glob_functions/synchronization.m +76 -0
  52. paradigma/ppg/glob_functions/tsdf_scan_meta.m +22 -0
  53. paradigma/ppg/hr_functions/Long_TFD_JOT.m +37 -0
  54. paradigma/ppg/hr_functions/PPG_TFD_HR.m +59 -0
  55. paradigma/ppg/hr_functions/TFD toolbox JOT/.gitignore +4 -0
  56. paradigma/ppg/hr_functions/TFD toolbox JOT/CHANGELOG.md +23 -0
  57. paradigma/ppg/hr_functions/TFD toolbox JOT/LICENCE.md +27 -0
  58. paradigma/ppg/hr_functions/TFD toolbox JOT/README.md +251 -0
  59. paradigma/ppg/hr_functions/TFD toolbox JOT/README.pdf +0 -0
  60. paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_Doppler_kern.m +142 -0
  61. paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_Doppler_lag_kern.m +314 -0
  62. paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_lag_kern.m +123 -0
  63. paradigma/ppg/hr_functions/TFD toolbox JOT/dec_tfd.m +154 -0
  64. paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_di_gdtfd.m +194 -0
  65. paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_li_gdtfd.m +200 -0
  66. paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_nonsep_gdtfd.m +229 -0
  67. paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_sep_gdtfd.m +241 -0
  68. paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/di_gdtfd.m +157 -0
  69. paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/li_gdtfd.m +190 -0
  70. paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/nonsep_gdtfd.m +196 -0
  71. paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/sep_gdtfd.m +199 -0
  72. paradigma/ppg/hr_functions/TFD toolbox JOT/full_tfd.m +144 -0
  73. paradigma/ppg/hr_functions/TFD toolbox JOT/load_curdir.m +13 -0
  74. paradigma/ppg/hr_functions/TFD toolbox JOT/pics/decimated_TFDs_examples.png +0 -0
  75. paradigma/ppg/hr_functions/TFD toolbox JOT/pics/full_TFDs_examples.png +0 -0
  76. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/check_dec_params_seq.m +79 -0
  77. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/dispEE.m +9 -0
  78. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/dispVars.m +26 -0
  79. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/disp_bytes.m +25 -0
  80. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/fold_vector_full.m +40 -0
  81. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/fold_vector_half.m +34 -0
  82. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/gen_LFM.m +29 -0
  83. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/get_analytic_signal.m +76 -0
  84. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/get_window.m +176 -0
  85. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/isreal_fn.m +11 -0
  86. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/padWin.m +97 -0
  87. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/vtfd.m +149 -0
  88. paradigma/ppg/preprocessing/preprocessing_imu.m +15 -0
  89. paradigma/ppg/preprocessing/preprocessing_ppg.m +13 -0
  90. paradigma/ppg_preprocessing.py +313 -0
  91. paradigma/preprocessing_config.py +69 -0
  92. paradigma/quantification.py +58 -0
  93. paradigma/tremor/TremorFeaturesAndClassification.m +345 -0
  94. paradigma/tremor/feat_extraction/DerivativesExtract.m +22 -0
  95. paradigma/tremor/feat_extraction/ExtractBandSignalsRMS.m +72 -0
  96. paradigma/tremor/feat_extraction/MFCCExtract.m +100 -0
  97. paradigma/tremor/feat_extraction/PSDBandPower.m +52 -0
  98. paradigma/tremor/feat_extraction/PSDEst.m +63 -0
  99. paradigma/tremor/feat_extraction/PSDExtrAxis.m +88 -0
  100. paradigma/tremor/feat_extraction/PSDExtrOpt.m +95 -0
  101. paradigma/tremor/preprocessing/InterpData.m +32 -0
  102. paradigma/tremor/weekly_aggregates/WeeklyAggregates.m +295 -0
  103. paradigma/util.py +50 -0
  104. paradigma/windowing.py +219 -0
  105. paradigma-0.3.0.dist-info/LICENSE +192 -0
  106. paradigma-0.3.0.dist-info/METADATA +79 -0
  107. paradigma-0.3.0.dist-info/RECORD +108 -0
  108. paradigma/dummy.py +0 -3
  109. paradigma-0.1.5.dist-info/LICENSE +0 -201
  110. paradigma-0.1.5.dist-info/METADATA +0 -18
  111. paradigma-0.1.5.dist-info/RECORD +0 -6
  112. {paradigma-0.1.5.dist-info → paradigma-0.3.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,314 @@
1
+ %-------------------------------------------------------------------------------
2
+ % gen_Doppler_lag_kern: Doppler--lag kernel (for GDTFD definition)
3
+ %
4
+ % Syntax: kern=gen_Doppler_lag_kern(kern_type,kern_params,N)
5
+ %
6
+ % Input:
7
+ % kern_type = { 'wvd' | 'swvd' | 'pwvd' | 'sep' | 'cw' | 'mb'}
8
+ % wvd - kernel for Wigner-Ville distribution
9
+ % swvd - kernel for smoothed Wigner-Ville distribution
10
+ % (lag-independent kernel)
11
+ % pwvd - kernel for pseudo Wigner-Ville distribution
12
+ % (Doppler-independent kernel)
13
+ % sep - kernel for separable kernel (combintation of SWVD and PWVD)
14
+ % cw - kernel for Choi-Williams distribution
15
+ % mb - kernel for Modified-B distribution
16
+ %
17
+ % kern_params = cell of kernel parameters:
18
+ % wvd - {}
19
+ % swvd - {win_length,win_type,[win_param],[Doppler_or_time]}
20
+ % e.g. {11,'hamm',0,1}
21
+ % the parameter Doppler_or_time is either
22
+ % 0 = to define window in the time-domain
23
+ % 1 = to define window in the Doppler-domain
24
+ % pwvd - {win_length,win_type,[win_param]}
25
+ % e.g. {200,'cosh',0.1}
26
+ % sep - { {win1_length,win1_type,[win1_param]},
27
+ % {win2_length,win2_type,[win2_param]}
28
+ % where win1 is the Doppler window and win2 is the lag window.
29
+ % e.g. { {11,'hamm'}, {200,'cosh',0.1} }
30
+ % cw - {sigma_parameter}
31
+ % mb - {beta_parameter} in the range 1<beta<0
32
+ %
33
+ % N = signal length.
34
+ %
35
+ % Output:
36
+ % g = Doppler--lag smoothing kernel
37
+ %
38
+ % See also: GEN_LAG_KERN, GEN_DOPPLER_KERN, GET_WINDOW, PADWIN
39
+ %
40
+ % Example:
41
+ % N=128;
42
+ % g=gen_Doppler_lag_kern( 'sep',{{N-1,'cosh',0.1,1},{51,'hamm'}},N);
43
+ % clf; mesh( fftshift(g) );
44
+ % xlabel('lag'); ylabel('Doppler');
45
+ % title('Separable kernel');
46
+ %
47
+
48
+ % John M. O' Toole, University College Cork
49
+ % Started: 14-04-2014
50
+ %
51
+ % last update: Time-stamp: <2018-01-21 04:51:27 (otoolej)>
52
+ %-------------------------------------------------------------------------------
53
+ function g=gen_Doppler_lag_kern(kern_type,kern_params,N,lag_index,G1)
54
+ if(nargin<3), error('need 3 input arguments'); end
55
+ if(nargin<4 || isempty(lag_index)), lag_index=[]; end
56
+ if(nargin<5 || isempty(G1)), G1=[]; end
57
+
58
+
59
+
60
+ DBplot=0;
61
+
62
+ lag_sample=2;
63
+ doppler_sample=1/N;
64
+
65
+ if(isempty(lag_index))
66
+ lag_index=1:N;
67
+ g=zeros(N);
68
+ else
69
+ g=zeros(N,1:length(lag_index));
70
+ end
71
+
72
+
73
+
74
+ if(~iscell(kern_params))
75
+ tmp_params{1}=kern_params;
76
+ kern_params=tmp_params;
77
+ end
78
+
79
+ g=get_kern(g,lag_index,kern_type,kern_params,doppler_sample,lag_sample,N,G1);
80
+
81
+
82
+ % All kernels are real valued.
83
+ g=real(g);
84
+
85
+ if(DBplot)
86
+ figure(1); clf;
87
+ if(length(lag_index)==1)
88
+ plot( g );
89
+ else
90
+ mesh( fftshift(g) );
91
+ end
92
+ xlabel('lag'); ylabel('Doppler');
93
+ title('Separable kernel');
94
+ end
95
+
96
+
97
+
98
+
99
+ function g=get_kern(g,lag_index,kernel_type,kernel_params,doppler_sample_rate, ...
100
+ lag_sample_rate,N,G1)
101
+ %---------------------------------------------------------------------
102
+ % generate the kernels for a given sample rate
103
+ %---------------------------------------------------------------------
104
+ if(nargin<8 || isempty(G1)), G1=[]; end
105
+
106
+ [Nd,Nl]=size(g);
107
+ l=length(kernel_params);
108
+
109
+
110
+ switch kernel_type
111
+
112
+ case {'wvd'}
113
+ g(:,:)=1;
114
+
115
+
116
+ %---------------------------------------------------------------------
117
+ % Smoothed Wigner-Ville (Lag Independent (LI) kernel)
118
+ % g(l/NT,mT) = W(l/NT)
119
+ %---------------------------------------------------------------------
120
+ case 'swvd'
121
+
122
+ if( l<2 )
123
+ error('Need at least two window parameters for SWVD');
124
+ end
125
+ win_length=kernel_params{1};
126
+ win_type=kernel_params{2};
127
+ win_param=0; win_param2=1;
128
+ if( l>=3 ) win_param=kernel_params{3}; end
129
+ if( l>=4 ) win_param2=kernel_params{4}; end
130
+
131
+
132
+ G1=get_window(win_length,win_type,win_param);
133
+ G1=padWin(G1,Nd);
134
+
135
+
136
+ % Define window in the time-domain (this is the usual practice):
137
+ % But could also define in the doppler-domain.
138
+ if( win_param2==0 )
139
+ G1=fft(G1);
140
+ G1=G1./G1(1);
141
+ end
142
+
143
+ if( isreal_fn(ifft(G1))==0 )
144
+ warning('Window function g1(t) is NOT real valued.');
145
+ end
146
+
147
+ for m=1:Nl
148
+ g(:,m) = G1;
149
+ end
150
+
151
+
152
+ %---------------------------------------------------------------------
153
+ % Pseudo-Wigner-Ville (Doppler Independent (DI) kernel)
154
+ % g(l/NT,mT) = g2(mT)
155
+ %---------------------------------------------------------------------
156
+ case 'pwvd'
157
+
158
+ if( l<2 )
159
+ error('Need at least two window parameters for PWVD');
160
+ end
161
+ P=kernel_params{1};
162
+ win_type=kernel_params{2};
163
+ win_param=0; win_param2=0;
164
+ if( l>2 ) win_param=kernel_params{3}; end
165
+ if( l>3 ) win_param2=kernel_params{4}; end
166
+
167
+ g2=get_window(P,win_type,win_param,win_param2);
168
+
169
+ g2=padWin(g2(:),N);
170
+ g2=g2(lag_index);
171
+
172
+ if( Nd==Nl && isreal_fn(fft(g2))==0 )
173
+ warning('Window function G2(f) is NOT real valued.');
174
+ end
175
+
176
+ for l=0:Nd-1
177
+ g(l+1,:)=g2;
178
+ end
179
+
180
+ %---------------------------------------------------------------------
181
+ % Seperable Kernel
182
+ %
183
+ % g(l/NT,mT) = G1(l/NT)g2(mT)
184
+ %
185
+ %---------------------------------------------------------------------
186
+ case { 'sep', 'sep-full' }
187
+
188
+ if(l<2)
189
+ error('Need at least two windows parameters.');
190
+ end
191
+
192
+ g1=get_kern(g,lag_index,'swvd',kernel_params{1},doppler_sample_rate,lag_sample_rate,N);
193
+ g2=get_kern(g,lag_index,'pwvd',kernel_params{2},doppler_sample_rate,lag_sample_rate,N);
194
+ g=g1.*g2;
195
+
196
+
197
+ %---------------------------------------------------------------------
198
+ % Choi-Williams
199
+ %
200
+ % g(l/NT,mT) = exp( -(2 pi m l/N)^2/ sigma )
201
+ %
202
+ %---------------------------------------------------------------------
203
+ case {'cw', 'choi-williams', 'choi-will'}
204
+
205
+ if(l>=1)
206
+ sigma=kernel_params{1};
207
+ else
208
+ sigma=11;
209
+ end
210
+ Ndh=ceil(Nd/2);
211
+ Nlh=ceil(Nl/2);
212
+
213
+
214
+ % if just at one-lag index:
215
+ if(length(lag_index)==1)
216
+ g(1)=1;
217
+ m=lag_index-1;
218
+ if(m==(N-1))
219
+ g(:)=0;
220
+ elseif(m==0)
221
+ g(:)=1;
222
+ else
223
+ if(m>ceil(N/2)) m=N-m; end
224
+
225
+ const = ((2*pi)^2)/sigma;
226
+ u=1:Ndh-1;
227
+ u1=u.*doppler_sample_rate; m1=m*lag_sample_rate;
228
+
229
+ g(u+1) = exp( -const.*(u1.*m1).^2 ).';
230
+ g(Nd-u+1)=g(u+1);
231
+ end
232
+
233
+ % or for the whole thing:
234
+ else
235
+ g(1,1:Nl)=1; g(1:Nd,1)=1;
236
+
237
+ const = ((2*pi)^2)/sigma;
238
+ u=1:Ndh-1;
239
+ for m=1:Nlh-1
240
+
241
+ u1=u.*doppler_sample_rate; m1=m*lag_sample_rate;
242
+ g(u+1,m+1)=exp( -const.*(u1.*m1).^2 ).';
243
+
244
+ g(Nd-u+1,m+1)=g(u+1,m+1);
245
+ g(u+1,Nl-m+1)=g(u+1,m+1);
246
+ g(Nd-u+1,Nl-m+1)=g(u+1,m+1);
247
+ end
248
+ end
249
+
250
+ %---------------------------------------------------------------------
251
+ % Product kernel (sometimes called a RID kernel)
252
+ %
253
+ % g(l/NT,2mT)=H(l2m/N)
254
+ %---------------------------------------------------------------------
255
+ case { 'prod', 'RID', 'product' }
256
+
257
+ % NOT WORKING:
258
+ % $$$ if(length(lag_index)==1)
259
+ % $$$ m=lag_index;
260
+ % $$$
261
+ % $$$ g(1)=1;
262
+ % $$$ if(m==N)
263
+ % $$$ g(:)=0;
264
+ % $$$ else
265
+ % $$$ if(m>ceil(N/2)) m=N-m; end
266
+ % $$$
267
+ % $$$ u=1:floor(Nd/2);
268
+ % $$$ im=mod(u*m,length(G1));
269
+ % $$$
270
+ % $$$ g(u+1)=G1(im+1);
271
+ % $$$ g(Nd-u+1)=g(u+1);
272
+ % $$$ end
273
+ % $$$ else
274
+ % $$$ keyboard;
275
+ % $$$ if(isempty(G1))
276
+ % $$$ [d,d2,d3,G1]=gen_Doppler_kern(kernel_params,N,N);
277
+ % $$$ end
278
+ % $$$ Ndh=ceil(Nd/2); Nlh=ceil(Nl/2);
279
+ % $$$ g=zeros(Nd,Nl);
280
+ % $$$
281
+ % $$$ g(1,1:Nl)=G1(1); g(1:Nd,1)=G1(1);
282
+ % $$$
283
+ % $$$ u=1:Ndh-1;
284
+ % $$$ for m=1:Nlh-1
285
+ % $$$ g(u+1,m+1)=G1( mod(u.*m,N)+1 );
286
+ % $$$
287
+ % $$$ % $$$ g(Nd-u+1,m+1)=g(u+1,m+1);
288
+ % $$$ % $$$ g(u+1,Nl-m+1)=g(u+1,m+1);
289
+ % $$$ % $$$ g(Nd-u+1,Nl-m+1)=g(u+1,m+1);
290
+ % $$$ end
291
+ % $$$
292
+ % $$$ end
293
+
294
+
295
+ %---------------------------------------------------------------------
296
+ % Modified-B (a specific SWVD or LAG INDEPENDENT kernel)
297
+ %
298
+ % G(nT,mT) = cosh^{-2*beta}(n) (defined in time--lag domain)
299
+ %---------------------------------------------------------------------
300
+ case { 'mb', 'modified-b' }
301
+
302
+ G1=get_kern(g,lag_index,'swvd',{N-1,'cosh',kernel_params{1}}, ...
303
+ doppler_sample_rate,lag_sample_rate,N);
304
+
305
+ for m=1:Nl
306
+ g(:,m) = G1;
307
+ end
308
+
309
+
310
+ otherwise
311
+ error(['Unknown kernel type: ' kernel_type]);
312
+
313
+ end
314
+
@@ -0,0 +1,123 @@
1
+ %-------------------------------------------------------------------------------
2
+ % gen_lag_kern: smoothing window for Lag-kernel g2[m]; provides some checking of
3
+ % the parameters
4
+ %
5
+ % Syntax: [g2,P,Ph_floor,Nfreq]=gen_lag_kern(win_params,N,Nfreq)
6
+ %
7
+ %
8
+ % Input:
9
+ % win_params - cell of {win_length,win_type,[win_param],[lag_or_freq]}
10
+ % e.g. {11,'hamm',0,1}
11
+ % the parameter lag_or_freq is either:
12
+ % 0 = to define window in the lag-domain
13
+ % 1 = to define window in the frequency-domain
14
+ % N - lenght of signal
15
+ % Nfreq - number of sample points in the frequency direction
16
+ %
17
+ % Output:
18
+ % g2 - lag kernel g_2(2mT)
19
+ % P - length of g2 (as may have changed)
20
+ % Ph_floor - floor(P/2)
21
+ % Nfreq - Nfreq (as may have changed)
22
+ %
23
+ % See also: GEN_DOPPLER_KERN, GEN_DOPPLER_LAG_KERN, GET_WINDOW, PADWIN
24
+ %
25
+ % Example:
26
+ % g2=get_lag_kernel({61,'hann'},128,512);
27
+ %
28
+
29
+ % John M. O' Toole, University College Cork
30
+ % Started: 16-04-2014
31
+ %
32
+ % last update: Time-stamp: <2021-08-24 17:42:46 (otoolej)>
33
+ %-------------------------------------------------------------------------------
34
+ function [g2,P,Ph_floor,Nfreq]=gen_lag_kern(win_params,N,Nfreq)
35
+ if(nargin<3 || isempty(Nfreq)), Nfreq=[]; end
36
+
37
+
38
+ DBplot=0;
39
+
40
+
41
+ %---------------------------------------------------------------------
42
+ % 1. make sure parameters are ok
43
+ %---------------------------------------------------------------------
44
+ P=win_params{1};
45
+ % window length can not be greater than N:
46
+ if(P>N)
47
+ warning('length of g2 too long: chopping down length N');
48
+ P=N;
49
+ end
50
+ % force window length to be odd-value:
51
+ if(P/2==fix(P/2))
52
+ P=P-1;
53
+ warning(['Forcing P to be odd. P is now P=',num2str(P)]);
54
+ end
55
+ Ph_floor=floor(P/2);
56
+
57
+
58
+ l=length(win_params);
59
+ if( l<2 )
60
+ error('Need at least two window parameters');
61
+ end
62
+
63
+ if(isempty(Nfreq)), Nfreq=P+1; end
64
+
65
+ if(Nfreq<(P+1))
66
+ warning('Nfreq is too short: increasing length to (P+1)');
67
+ Nfreq=P+1;
68
+ end
69
+
70
+ if(rem(Nfreq,2))
71
+ Ntime=Ntime+1;
72
+ warning(['Forcing Ntime to be even. Ntime is now Ntime=',num2str(Ntime)]);
73
+ end
74
+
75
+
76
+ %---------------------------------------------------------------------
77
+ % 2. call function to generate window
78
+ %---------------------------------------------------------------------
79
+ win_type=win_params{2};
80
+ if( l>=3 ) win_extra_param=win_params{3}; else, win_extra_param=[]; end
81
+ if( l>3 ) win_dft_param=win_params{4}; else, win_dft_param=0; end
82
+
83
+
84
+ g2=get_window(P,win_type,win_extra_param,win_dft_param);
85
+ g2=g2(:);
86
+
87
+ g2_pad=padWin(g2,Nfreq);
88
+
89
+
90
+ %---------------------------------------------------------------------
91
+ % 3. [OPTIONAL] post-process window
92
+ %---------------------------------------------------------------------
93
+ % a. if normalizing window:
94
+ if(length(win_params)>4)
95
+ if(strcmpi(win_params{5},'y')==1)
96
+ g2=g2./sum(g2);
97
+ end
98
+ end
99
+
100
+ % b. if (time) reversing window
101
+ if(length(win_params)>5 )
102
+ g2=shiftWin(g2);
103
+ g2_pad=shiftWin(g2_pad);
104
+ end
105
+
106
+
107
+ if(DBplot)
108
+ figure(20); clf; hold all;
109
+ subplot(211); plot(g2_pad);
110
+ subplot(212); plot(g2);
111
+ end
112
+
113
+
114
+ function w=shiftWin(w)
115
+ %---------------------------------------------------------------------
116
+ % shift window to centre
117
+ %---------------------------------------------------------------------
118
+ w=circshift(w(:),ceil(length(w)/2));
119
+
120
+
121
+
122
+
123
+
@@ -0,0 +1,154 @@
1
+ %-------------------------------------------------------------------------------
2
+ % dec_tfd: Generate decimated (or sub-sampled) time-frequency distributions
3
+ %
4
+ % Syntax: tf=dec_tfd(x,kern_type,kern_params,Ntime,Nfreq,time_dec,freq_dec)
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
+ % kern_type = kernel type, either nonseparable, separable, Doppler-independent
11
+ % (DI) or lag-independent (LI): { 'nonsep' | 'sep' | 'DI' | 'LI' }
12
+ %
13
+ % kern_params = kernel parameters; different depending on kernel type
14
+ %
15
+ % if nonseparable kernel, then form: { kern_name, kern_param}
16
+ % e.g. tf=full_tfd( x, 'nonsep', { 'cw', 100 } );
17
+ %
18
+ % if Doppler-independent kernel, then of the form:
19
+ % { window_length, window_type, [window_parameter (optional)] }
20
+ % e.g. tf=full_tfd( x, 'DI', {101,'hann'} );
21
+ %
22
+ % if lag-independent kernel, then of the form:
23
+ % { window_length, window_type, [window_parameter (optional)] }
24
+ % e.g. tf=full_tfd( x, 'LI', {101,'cosh',0.01} );
25
+ %
26
+ % if separable kernel, then of the form: { doppler_window, lag_window }
27
+ % where doppler_window is of the form: { window_length, window_type,
28
+ % [window_parameter (optional)] }; same format for lag window
29
+ % e.g. tf=full_tfd( x, 'sep', { {101, 'cosh', 0.05}, {101,'hann'} } );
30
+ %
31
+ % Ntime = over-sampling in the time direction; only applicable for separable
32
+ % and lag-independent kernels
33
+ %
34
+ % Nfreq = over-sampling in the frequency direction; only applicable for separable
35
+ % and Doppler-independent kernels
36
+ %
37
+ % time_dec = decimation factor in the time domain; for the Doppler-independent kernel
38
+ % this value can be either a vector or a scalar; for all other kernel types this
39
+ % value is an integer scalar a.
40
+ %
41
+ % freq_dec = decimation factor in the frequency domain; for the lag-independent kernel
42
+ % this value can be either a vector or a scalar; for all other kernel types this
43
+ % value is an integer scalar b.
44
+ %
45
+ % Outputs:
46
+ % tf - time-frequency distribution of size (a/N) x (b/N) (non-separable kernel),
47
+ % or (a/Ntime) x (b/Nfreq) (separable kernel),
48
+ % or U x (b/Nfreq) (Doppler-independent kernel, U is length of time_dec vector),
49
+ % or (a/Ntime) x V (lag-independent kernel, V is length of freq_dec vector)
50
+ %
51
+ % See also: DEC_NONSEP_GDTFD, DEC_SEP_GDTFD, DEC_LI_GDTFD, DEC_DI_GDTFD
52
+ %
53
+ % Example:
54
+ % N=1024; Ntime=64; Nfreq=128;
55
+ % a=2; b=2;
56
+ % ni=[100:2:900]; ki=[150:2:850];
57
+ %
58
+ % x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
59
+ %
60
+ % % non-separable kernel:
61
+ % c=dec_tfd(x,'nonsep',{'cw',100},N,N,a*4,b*4);
62
+ % figure(1); clf; vtfd(c,x);
63
+ %
64
+ % % separable kernel:
65
+ % c=dec_tfd(x,'sep',{{51,'hann'},{101,'hann'}},Ntime,Nfreq,a,b);
66
+ % figure(2); clf; vtfd(c,x);
67
+ %
68
+ % % Doppler-independent kernel:
69
+ % c=dec_tfd(x,'DI',{101,'hann'},N,Nfreq,ni,b);
70
+ % figure(3); clf; vtfd(c,x,1,ni);
71
+ %
72
+ % % lag-independent kernel:
73
+ % c=dec_tfd(x,'LI',{51,'hann'},Ntime,N,a,ki);
74
+ % figure(4); clf; vtfd(c,x,1,[],ki./(N*2));
75
+
76
+ % John M. O' Toole, University College Cork
77
+ % Started: 23-07-2014
78
+ %
79
+ % last update: Time-stamp: <2019-06-05 17:05:19 (otoolej)>
80
+ %-------------------------------------------------------------------------------
81
+ function tf=dec_tfd(x,kern_type,kern_params,Ntime,Nfreq,time_dec,freq_dec)
82
+ if(nargin<2 || isempty(kern_type)), kern_type='sep'; end
83
+ if(nargin<3 || isempty(kern_params)), kern_params={{51,'hann'},{101,'hann'}}; end
84
+ if(nargin<4 || isempty(time_dec)), time_dec=[]; end
85
+ if(nargin<5 || isempty(freq_dec)), freq_dec=[]; end
86
+ if(nargin<6 || isempty(Ntime)), Ntime=[]; end
87
+ if(nargin<7 || isempty(Nfreq)), Nfreq=[]; end
88
+
89
+
90
+ % set to 1 if want to see how much memory is used:
91
+ DBmem=0;
92
+
93
+
94
+ kern_type=lower(kern_type);
95
+ switch kern_type
96
+ case { 'nonsep', 'ns', 'nonseparable', 'non-separable', 'non-sep' }
97
+ %---------------------------------------------------------------------
98
+ % 1. Non-separable kernel; Doppler-lag form: g[l,m]
99
+ %---------------------------------------------------------------------
100
+ nonsep_params=[];
101
+ if(~iscell(kern_params))
102
+ nonsep_name=kern_params;
103
+ else
104
+ nonsep_name=kern_params{1};
105
+ if(length(kern_params)>1)
106
+ nonsep_params=kern_params{2};
107
+ end
108
+ end
109
+
110
+ tf=dec_nonsep_gdtfd(x,nonsep_name,nonsep_params,time_dec,freq_dec);
111
+
112
+
113
+ case { 'sep', 'separable' }
114
+ %---------------------------------------------------------------------
115
+ % 2. separable kernel; Doppler-lag form: G1[l]g2[m]
116
+ %---------------------------------------------------------------------
117
+ if(~iscell(kern_params) | (iscell(kern_params) & length(kern_params)<2) )
118
+ error(['separable kernel parameters should be of the form: ' ...
119
+ '{ {dopp_win_length,dopp_win_name}, {lag_win_length,lag_win_name} }']);
120
+ end
121
+
122
+ tf=dec_sep_gdtfd(x,kern_params{1},kern_params{2},time_dec,freq_dec,Ntime,Nfreq);
123
+
124
+
125
+ case { 'di', 'doppler-independent', 'dopp.-indep', 'dopp-indep', 'pwvd', 'p-wvd' }
126
+ %---------------------------------------------------------------------
127
+ % 3. Doppler-independent kernel: Doppler-lag form: g2[m]
128
+ %---------------------------------------------------------------------
129
+ if(~iscell(kern_params))
130
+ error(['Doppler-independent kernel parameters should be of the form: ' ...
131
+ '{win_length,win_name}']);
132
+ end
133
+
134
+ tf=dec_di_gdtfd(x,kern_params,time_dec,freq_dec,Nfreq);
135
+
136
+
137
+ case { 'li', 'lag-independent', 'lag-indep', 'swvd', 's-wvd' }
138
+ %---------------------------------------------------------------------
139
+ % 4. Lag-independent kernel: Doppler-lag form: G1[l]
140
+ %---------------------------------------------------------------------
141
+ if(~iscell(kern_params))
142
+ error(['lag-independent kernel parameters should be of the form: ' ...
143
+ '{win_length,win_name}']);
144
+ end
145
+
146
+ tf=dec_li_gdtfd(x,kern_params,time_dec,freq_dec,Ntime);
147
+
148
+ otherwise
149
+ warning('kern_type should be either: nonsep, sep, DI, or LI');
150
+ tf=[];
151
+ end
152
+
153
+
154
+ if(DBmem), s=whos; fprintf('total memory used: mem=%s\n',disp_bytes(sum([s.bytes]))); end