paradigma 0.1.5__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.5.dist-info/LICENSE +0 -201
- paradigma-0.1.5.dist-info/METADATA +0 -18
- paradigma-0.1.5.dist-info/RECORD +0 -6
- {paradigma-0.1.5.dist-info → paradigma-0.2.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% nonsep_gdtfd: Time-frequency distribution (quadratic class) with non-separable kernel
|
|
3
|
+
%
|
|
4
|
+
% Syntax: [tfd,g]=nonsep_gdtfd(x,kern_type,kern_params)
|
|
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 = { 'wvd' | 'swvd' | 'pwvd' | 'sep' | 'cw' | 'mb' }
|
|
11
|
+
% wvd - Wigner-Ville distribution
|
|
12
|
+
% swvd - Smoothed Wigner-Ville distribution
|
|
13
|
+
% (lag-independent kernel)
|
|
14
|
+
% pwvd - Pseudo Wigner-Ville distribution
|
|
15
|
+
% (Doppler-independent kernel)
|
|
16
|
+
% sep - Separable-kernel distribution
|
|
17
|
+
% (combintation of SWVD and PWVD)
|
|
18
|
+
% mb - Modified-B distribution
|
|
19
|
+
% cw - Choi-Williams distribution
|
|
20
|
+
%
|
|
21
|
+
% kern_params = cell of kernel parameters:
|
|
22
|
+
% wvd - {}
|
|
23
|
+
% swvd - {win_length,win_type,[win_param]}
|
|
24
|
+
% e.g. {11,'hamm'}
|
|
25
|
+
% pwvd - {win_length,win_type,[win_param]}
|
|
26
|
+
% e.g. {200,'cosh',0.1
|
|
27
|
+
% sep - { {win1_length,win1_type,[win1_param]},
|
|
28
|
+
% {win2_length,win2_type,[win2_param]}
|
|
29
|
+
% where win1 is the doppler window and win2 is the
|
|
30
|
+
% lag window, e.g. { {11,'hamm'}, {200,'cosh',0.1} }
|
|
31
|
+
% mb - {beta_parameter} in the range 1<beta<0
|
|
32
|
+
% cw - {sigma_parameter}
|
|
33
|
+
%
|
|
34
|
+
% Outputs:
|
|
35
|
+
% tfd = N x N time-frequency distribution
|
|
36
|
+
%
|
|
37
|
+
% See also: DEC_NONSEP_GDTFD, GET_ANALYTIC_SIGNAL, GEN_DOPPLER_LAG_KERN, FFT
|
|
38
|
+
%
|
|
39
|
+
% Example:
|
|
40
|
+
% N=128;
|
|
41
|
+
% x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
|
|
42
|
+
%
|
|
43
|
+
% c=nonsep_gdtfd(x,'cw',{100});
|
|
44
|
+
% vtfd(c,x);
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
% John M. O' Toole, University College Cork
|
|
48
|
+
% Started: 14-04-2014
|
|
49
|
+
%
|
|
50
|
+
% last update: Time-stamp: <2016-08-25 17:39:48 (otoolej)>
|
|
51
|
+
%-------------------------------------------------------------------------------
|
|
52
|
+
function tfd=nonsep_gdtfd(x,kern_type,kern_params)
|
|
53
|
+
if(nargin<2 || isempty(kern_type)), kern_type='cw'; end
|
|
54
|
+
if(nargin<3 || isempty(kern_params)), kern_params=10; end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
DBplot=0;
|
|
58
|
+
DBmem=0;
|
|
59
|
+
DBcompare=0;
|
|
60
|
+
DBtest=0;
|
|
61
|
+
DBtime=0;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if(DBtime), time_start=tic; end
|
|
65
|
+
%---------------------------------------------------------------------
|
|
66
|
+
% 1. convert real-valued signal to analytic signal of length 2N
|
|
67
|
+
%---------------------------------------------------------------------
|
|
68
|
+
[z,N2,N,Nh]=get_analytic_signal(x);
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
%---------------------------------------------------------------------
|
|
72
|
+
% 2. generate time--lag signal function (for positive-lag values only)
|
|
73
|
+
%---------------------------------------------------------------------
|
|
74
|
+
if(DBmem), s=whos; fprintf('start: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
75
|
+
tfd=zeros(N,N);
|
|
76
|
+
m_real=1:Nh; m_imag=(Nh+1):N;
|
|
77
|
+
|
|
78
|
+
m=0:(Nh-1);
|
|
79
|
+
for n=0:N-1
|
|
80
|
+
inp=mod(n+m,N2); inn=mod(n-m,N2);
|
|
81
|
+
K_time_slice=z(inp+1).*conj( z(inn+1) );
|
|
82
|
+
|
|
83
|
+
tfd(n+1,m_real)=real( K_time_slice );
|
|
84
|
+
tfd(n+1,m_imag)=imag( K_time_slice );
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
if(DBcompare)
|
|
88
|
+
for n=0:N-1
|
|
89
|
+
inp=mod(n+m,N2); inn=mod(n-m,N2);
|
|
90
|
+
K(n+1,m+1)=z(inp+1).*conj( z(inn+1) );
|
|
91
|
+
end
|
|
92
|
+
Ktest=complex(tfd(:,m_real),tfd(:,m_imag));
|
|
93
|
+
dispEE(Ktest,K);
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if(DBmem), s=whos; fprintf('K: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
98
|
+
|
|
99
|
+
% $$$ if(strcmp(kern_type,'wvd'))
|
|
100
|
+
% $$$ for n=0:2:N-2
|
|
101
|
+
% $$$
|
|
102
|
+
% $$$ tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
103
|
+
% $$$
|
|
104
|
+
% $$$ tfd(n+1,:)=real(tfd_time_slice);
|
|
105
|
+
% $$$ tfd(n+2,:)=imag(tfd_time_slice);
|
|
106
|
+
% $$$ end
|
|
107
|
+
% $$$
|
|
108
|
+
% $$$
|
|
109
|
+
% $$$ dispVars('here');
|
|
110
|
+
% $$$ return;
|
|
111
|
+
% $$$ end
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
%-------------------------------------------------------------------------
|
|
115
|
+
% 3. multiply kernel and signal function in the Doppler-lag domain
|
|
116
|
+
%-------------------------------------------------------------------------
|
|
117
|
+
for m=0:Nh-1
|
|
118
|
+
g_lag_slice=gen_Doppler_lag_kern(kern_type,kern_params,N,m+1);
|
|
119
|
+
|
|
120
|
+
R_lag_slice=ifft( fft( complex(tfd(:,m_real(m+1)),tfd(:,m_imag(m+1))) ).*g_lag_slice );
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
tfd(:,m_real(m+1))=real( R_lag_slice );
|
|
124
|
+
tfd(:,m_imag(m+1))=imag( R_lag_slice );
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
if(DBcompare)
|
|
128
|
+
g=gen_Doppler_lag_kern(kern_type,kern_params,N);
|
|
129
|
+
R=ifft( fft(K).*g(:,1:Nh) );
|
|
130
|
+
Rtest=complex(tfd(:,m_real),tfd(:,m_imag));
|
|
131
|
+
dispEE(Rtest,R);
|
|
132
|
+
clear g;
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
if(DBmem), s=whos; fprintf('R: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
%-------------------------------------------------------------------------
|
|
142
|
+
% 4. Expand R for positive and negative lag values and DFT back to
|
|
143
|
+
% time--frequency domain
|
|
144
|
+
%-------------------------------------------------------------------------
|
|
145
|
+
m=0:(Nh-1); mb=1:(Nh-1);
|
|
146
|
+
for n=0:2:N-2
|
|
147
|
+
R_even_half=complex(tfd(n+1,m_real),tfd(n+1,m_imag));
|
|
148
|
+
R_odd_half =complex(tfd(n+2,m_real),tfd(n+2,m_imag));
|
|
149
|
+
|
|
150
|
+
R_tslice_even=zeros(1,N); R_tslice_odd=zeros(1,N);
|
|
151
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
152
|
+
R_tslice_odd(m+1) =R_odd_half(m+1);
|
|
153
|
+
R_tslice_even(N-mb+1)=conj( R_even_half(mb+1) );
|
|
154
|
+
R_tslice_odd(N-mb+1) =conj( R_odd_half(mb+1) );
|
|
155
|
+
|
|
156
|
+
tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
157
|
+
|
|
158
|
+
tfd(n+1,:)=real(tfd_time_slice);
|
|
159
|
+
tfd(n+2,:)=imag(tfd_time_slice);
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if(DBmem), s=whos; fprintf('tfd: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
if(DBcompare)
|
|
166
|
+
Rfull=zeros(N);
|
|
167
|
+
Rfull(:,m+1)=R;
|
|
168
|
+
Rfull(:,N-mb+1)=conj( Rfull(:,mb+1) );
|
|
169
|
+
|
|
170
|
+
tfd_test=fft( Rfull.' ).';
|
|
171
|
+
dispEE(tfd_test,tfd);
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
if(DBmem), s=whos; fprintf('end: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
175
|
+
tfd=tfd./N;
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
179
|
+
|
|
180
|
+
if(DBtest)
|
|
181
|
+
if(DBtime), time_start=tic; end
|
|
182
|
+
tfd_test=full_gdtfd_testing_version(x,kern_type,kern_params);
|
|
183
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
184
|
+
dispEE(tfd_test,tfd);
|
|
185
|
+
end
|
|
186
|
+
if(DBplot)
|
|
187
|
+
figure(1); clf;
|
|
188
|
+
vtfd(tfd,real(x(1:N)));
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
tfd = tfd';
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% sep_gdtfd: Time--frequency distribution (quadratic class) with separable kernel of
|
|
3
|
+
% the form g[l,m]=G₁[l]g₂[m]
|
|
4
|
+
%
|
|
5
|
+
% Syntax: tfd=sep_gdtfd(x,dopp_win_params,lag_win_params,Ntime,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
|
+
% 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 the time domain)
|
|
18
|
+
% e.g. {121, 'hamm'}; {121, 'tukey', 0.2}; {127,'cosh',0.01,0}
|
|
19
|
+
%
|
|
20
|
+
% lag_win_params = lag window parameters in cell form:
|
|
21
|
+
% {win_length,win_type,win_param,lag_or_not} where
|
|
22
|
+
% - win_length is the sample length of the window
|
|
23
|
+
% - win_type is the type of window
|
|
24
|
+
% - [optional] win_param is the parameter of the window
|
|
25
|
+
% - [optional] lag_or_not is either 0 (define window in the lag
|
|
26
|
+
% domain, which is the default) or 0 (define window the frequency domain)
|
|
27
|
+
% e.g. {121, 'hamm'}; {121, 'tukey', 0.2}; {127,'cosh',0.01,0}
|
|
28
|
+
%
|
|
29
|
+
% Nfreq = frequency oversampling value; must be greater than length of lag window
|
|
30
|
+
% Ntime = time oversampling value; must be greater than length of Doppler window
|
|
31
|
+
%
|
|
32
|
+
% Outputs:
|
|
33
|
+
% tfd = Ntime x Nfreq time-frequency distribution
|
|
34
|
+
%
|
|
35
|
+
% See also: DEC_SEP_GDTFD, GET_ANALYTIC_SIGNAL, GEN_LAG_KERN, GEN_DOPPLER_KERN, FFT
|
|
36
|
+
%
|
|
37
|
+
% Example:
|
|
38
|
+
% N=10000; Ntime=256; Nfreq=256;
|
|
39
|
+
% x=gen_LFM(N,0.1,0.3)+gen_LFM(N,0.4,0.1);
|
|
40
|
+
%
|
|
41
|
+
% c=sep_gdtfd(x,{51,'hann'},{171,'hann'},Ntime,Nfreq);
|
|
42
|
+
% vtfd(c,x);
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
% John M. O' Toole, University College Cork
|
|
46
|
+
% Started: 16-04-2014
|
|
47
|
+
%
|
|
48
|
+
% last update: Time-stamp: <2019-02-19 15:12:35 (otoolej)>
|
|
49
|
+
%-------------------------------------------------------------------------------
|
|
50
|
+
function tfd=sep_gdtfd(x,dopp_win_params,lag_win_params,Ntime,Nfreq)
|
|
51
|
+
if(nargin<4 || isempty(Ntime)), Ntime=[]; end
|
|
52
|
+
if(nargin<5 || isempty(Nfreq)), Nfreq=[]; end
|
|
53
|
+
|
|
54
|
+
DBplot=0;
|
|
55
|
+
DBmem=0;
|
|
56
|
+
DBcompare=0;
|
|
57
|
+
DBtest=0;
|
|
58
|
+
DBtime=0;
|
|
59
|
+
|
|
60
|
+
if(DBtime), time_start=tic; end
|
|
61
|
+
%---------------------------------------------------------------------
|
|
62
|
+
% 1. convert real-valued signal to analytic signal of length 2N
|
|
63
|
+
%---------------------------------------------------------------------
|
|
64
|
+
[z,N2,N,Nh]=get_analytic_signal(x);
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
%---------------------------------------------------------------------
|
|
68
|
+
% 2. compute lag and Doppler windows
|
|
69
|
+
%---------------------------------------------------------------------
|
|
70
|
+
[g2,P,Ph_floor,Nfreq]=gen_lag_kern(lag_win_params,N,Nfreq);
|
|
71
|
+
Nh_freq=ceil(Nfreq/2);
|
|
72
|
+
Ph=ceil(P/2);
|
|
73
|
+
[G1,Q,Ntime,G1_pad]=gen_Doppler_kern(dopp_win_params,N,Ntime);
|
|
74
|
+
Nh_time=ceil(Ntime/2);
|
|
75
|
+
Qh=ceil(Q/2);
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
%---------------------------------------------------------------------
|
|
79
|
+
% 3. convolve signal function with kernel (multiplication in the
|
|
80
|
+
% Doppler--lag domain). Do this in stages to minimise memory
|
|
81
|
+
%---------------------------------------------------------------------
|
|
82
|
+
if(DBmem), s=whos; fprintf('start: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
83
|
+
tfd=zeros(Ntime,Nfreq);
|
|
84
|
+
|
|
85
|
+
if(DBmem), s=whos; fprintf('tfd declare: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
86
|
+
|
|
87
|
+
n=0:N-1; l=0:(Qh-1); lb=1:(Qh-1);
|
|
88
|
+
for m=0:(Ph-1);
|
|
89
|
+
inp=mod(n+m,N2); inn=mod(n-m,N2);
|
|
90
|
+
K_lag_slice=g2(m+1).*z(inp+1).*conj( z(inn+1) );
|
|
91
|
+
|
|
92
|
+
K_lag_slice=fft(K_lag_slice);
|
|
93
|
+
|
|
94
|
+
R_lag_slice=zeros(Ntime,1);
|
|
95
|
+
R_lag_slice(l+1)=K_lag_slice(l+1).*G1(l+1);
|
|
96
|
+
R_lag_slice(Ntime-lb+1)=K_lag_slice(N-lb+1).*G1(Q-lb+1);
|
|
97
|
+
|
|
98
|
+
R_lag_slice=ifft(R_lag_slice);
|
|
99
|
+
|
|
100
|
+
tfd(:,m+1)=real( R_lag_slice );
|
|
101
|
+
tfd(:,m+Nh_freq+1)=imag( R_lag_slice );
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if(DBmem), s=whos; fprintf('R: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
if(DBcompare)
|
|
109
|
+
K=zeros(N,Nh_freq);
|
|
110
|
+
m=0:(Ph-1);
|
|
111
|
+
for n=0:N-1
|
|
112
|
+
inp=mod(n+m,N2); inn=mod(n-m,N2);
|
|
113
|
+
K(n+1,m+1)=g2(m+1).*z(inp+1).*conj( z(inn+1) );
|
|
114
|
+
end
|
|
115
|
+
af=fft(K);
|
|
116
|
+
|
|
117
|
+
R=zeros(Ntime,Nh_freq);
|
|
118
|
+
for m=0:Ph-1
|
|
119
|
+
R(l+1,m+1)=af(l+1,m+1).*G1(l+1);
|
|
120
|
+
R(Ntime-lb+1,m+1)=af(N-lb+1,m+1).*G1(Q-lb+1);
|
|
121
|
+
|
|
122
|
+
R(:,m+1)=ifft(R(:,m+1));
|
|
123
|
+
end
|
|
124
|
+
Rtest=complex(tfd(:,1:Nh_freq),tfd(:,(Nh_freq+1):end));
|
|
125
|
+
dispEE(R,Rtest);
|
|
126
|
+
clear Rtest K af;
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
%-------------------------------------------------------------------------
|
|
131
|
+
% 4. Expand R for positive and negative lag values and DFT back to
|
|
132
|
+
% time--frequency domain
|
|
133
|
+
%-------------------------------------------------------------------------
|
|
134
|
+
m=0:(Ph-1); mb=1:(Ph-1);
|
|
135
|
+
k_real=1:Nh_freq; k_imag=(Nh_freq+1):Nfreq;
|
|
136
|
+
|
|
137
|
+
for n=0:2:Ntime-2
|
|
138
|
+
R_even_half=complex(tfd(n+1,k_real),tfd(n+1,k_imag));
|
|
139
|
+
R_odd_half =complex(tfd(n+2,k_real),tfd(n+2,k_imag));
|
|
140
|
+
|
|
141
|
+
R_tslice_even=zeros(1,Nfreq); R_tslice_odd=zeros(1,Nfreq);
|
|
142
|
+
R_tslice_even(m+1)=R_even_half(m+1);
|
|
143
|
+
R_tslice_odd(m+1) =R_odd_half(m+1);
|
|
144
|
+
R_tslice_even(Nfreq-mb+1)=conj( R_even_half(mb+1) );
|
|
145
|
+
R_tslice_odd(Nfreq-mb+1) =conj( R_odd_half(mb+1) );
|
|
146
|
+
|
|
147
|
+
tfd_time_slice=fft( R_tslice_even+j.*R_tslice_odd );
|
|
148
|
+
|
|
149
|
+
tfd(n+1,:)=real(tfd_time_slice);
|
|
150
|
+
tfd(n+2,:)=imag(tfd_time_slice);
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
if(DBmem), s=whos; fprintf('tfd (end): mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
if(DBcompare)
|
|
157
|
+
Rfull=zeros(Ntime,Nfreq);
|
|
158
|
+
Rfull(:,m+1)=R(:,m+1);
|
|
159
|
+
Rfull(:,Nfreq-mb+1)=conj( Rfull(:,mb+1) );
|
|
160
|
+
|
|
161
|
+
tfd_test=fft( Rfull.' ).';
|
|
162
|
+
dispEE(tfd_test,tfd);
|
|
163
|
+
clear R test_test;
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
scale_factor=1/Nfreq;
|
|
167
|
+
tfd=tfd.*scale_factor;
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
%---------------------------------------------------------------------
|
|
171
|
+
% END; testing and plotting
|
|
172
|
+
%---------------------------------------------------------------------
|
|
173
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
174
|
+
|
|
175
|
+
if(DBtest) % && Ntime==N && Nfreq==N)
|
|
176
|
+
if(DBtime)
|
|
177
|
+
dispVars( toc(time_start) );
|
|
178
|
+
time_start=tic;
|
|
179
|
+
end
|
|
180
|
+
tfd_test=full_gdtfd_testing_version(x,'sep',{dopp_win_params,lag_win_params});
|
|
181
|
+
|
|
182
|
+
if(DBtime), dispVars( toc(time_start) ); end
|
|
183
|
+
|
|
184
|
+
% $$$ dispVars( sum(tfd_test(:)), sum(tfd(:)) );
|
|
185
|
+
if(Ntime==N && Nfreq==N)
|
|
186
|
+
dispEE(tfd_test,tfd);
|
|
187
|
+
else
|
|
188
|
+
a=N/Ntime; b=N/Nfreq;
|
|
189
|
+
if( a==floor(a) && b==floor(b) )
|
|
190
|
+
dispEE(tfd_test(1:a:end,1:b:end),tfd./(a*b));
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
if(DBplot)
|
|
195
|
+
figure(1); clf;
|
|
196
|
+
vtfd(tfd,real(x(1:N)));
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% full_tfd:
|
|
3
|
+
%
|
|
4
|
+
% Syntax: tf=full_tfd(x,kern_type,kern_params,Ntime,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
|
+
% 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
|
+
% Outputs:
|
|
38
|
+
% tf = time-frequency distribution of size N x N (nonseparable kernel),
|
|
39
|
+
% or Ntime x N (lag-independent kernel),
|
|
40
|
+
% or N x Nfreq (Doppler-independent kernel),
|
|
41
|
+
% or Ntime x Nfreq (separable kernel)
|
|
42
|
+
%
|
|
43
|
+
% See also: NONSEP_GDTFD, SEP_GDTFD, LI_GDTFD, DI_GDTFD
|
|
44
|
+
%
|
|
45
|
+
% Examples:
|
|
46
|
+
% N=512;
|
|
47
|
+
% x=gen_LFM(N,0.1,0.3) + gen_LFM(N,0.4,0.04);
|
|
48
|
+
%
|
|
49
|
+
% % nonseparable kernel (Choi-Williams kernel):
|
|
50
|
+
% tf=full_tfd(x,'nonsep',{'cw',10});
|
|
51
|
+
% figure(1); clf; vtfd(tf,x);
|
|
52
|
+
%
|
|
53
|
+
% % separable kernel:
|
|
54
|
+
% tf=full_tfd(x,'sep',{{51,'hann'},{101,'hann'}},256,256);
|
|
55
|
+
% figure(2); clf; vtfd(tf,x);
|
|
56
|
+
%
|
|
57
|
+
% % Doppler-independent kernel:
|
|
58
|
+
% tf=full_tfd(x,'DI',{101,'hann'},256,[]);
|
|
59
|
+
% figure(3); clf; vtfd(tf,x);
|
|
60
|
+
%
|
|
61
|
+
% % lag-independent kernel:
|
|
62
|
+
% tf=full_tfd(x,'LI',{51,'hann'},[],256);
|
|
63
|
+
% figure(4); clf; vtfd(tf,x);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
% John M. O' Toole, University College Cork
|
|
68
|
+
% Started: 11-06-2014
|
|
69
|
+
%
|
|
70
|
+
% last update: Time-stamp: <2017-05-30 10:00:46 (otoolej)>
|
|
71
|
+
%-------------------------------------------------------------------------------
|
|
72
|
+
function tf=full_tfd(x,kern_type,kern_params,Ntime,Nfreq)
|
|
73
|
+
if(nargin<2 || isempty(kern_type)), kern_type='sep'; end
|
|
74
|
+
if(nargin<3 || isempty(kern_params)), kern_params={{51,'hann'},{101,'hann'}}; end
|
|
75
|
+
if(nargin<4 || isempty(Ntime)), Ntime=[]; end
|
|
76
|
+
if(nargin<5 || isempty(Nfreq)), Nfreq=[]; end
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
% set to 1 if want to see how much memory is used:
|
|
80
|
+
DBmem=1;
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
kern_type=lower(kern_type);
|
|
84
|
+
switch kern_type
|
|
85
|
+
case { 'nonsep', 'ns', 'nonseparable', 'non-separable', 'non-sep' }
|
|
86
|
+
%---------------------------------------------------------------------
|
|
87
|
+
% 1. Non-separable kernel; Doppler-lag form: g[l,m]
|
|
88
|
+
%---------------------------------------------------------------------
|
|
89
|
+
nonsep_params=[];
|
|
90
|
+
if(~iscell(kern_params))
|
|
91
|
+
nonsep_name=kern_params;
|
|
92
|
+
else
|
|
93
|
+
nonsep_name=kern_params{1};
|
|
94
|
+
if(length(kern_params)>1)
|
|
95
|
+
nonsep_params=kern_params{2};
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
tf=nonsep_gdtfd(x,nonsep_name,nonsep_params);
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
case { 'sep', 'separable' }
|
|
103
|
+
%---------------------------------------------------------------------
|
|
104
|
+
% 2. separable kernel; Doppler-lag form: G1[l]g2[m]
|
|
105
|
+
%---------------------------------------------------------------------
|
|
106
|
+
if(~iscell(kern_params) | (iscell(kern_params) & length(kern_params)<2) )
|
|
107
|
+
error(['separable kernel parameters should be of the form: ' ...
|
|
108
|
+
'{ {dopp_win_length,dopp_win_name}, {lag_win_length,lag_win_name} }']);
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
tf=sep_gdtfd(x,kern_params{1},kern_params{2},Ntime,Nfreq);
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
case { 'di', 'doppler-independent', 'dopp.-indep', 'dopp-indep', 'pwvd', 'p-wvd' }
|
|
115
|
+
%---------------------------------------------------------------------
|
|
116
|
+
% 3. Doppler-independent kernel: Doppler-lag form: g2[m]
|
|
117
|
+
%---------------------------------------------------------------------
|
|
118
|
+
if(~iscell(kern_params))
|
|
119
|
+
error(['Doppler-independent kernel parameters should be of the form: ' ...
|
|
120
|
+
'{win_length,win_name}']);
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
tf=di_gdtfd(x,kern_params,Nfreq);
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
case { 'li', 'lag-independent', 'lag-indep', 'swvd', 's-wvd' }
|
|
128
|
+
%---------------------------------------------------------------------
|
|
129
|
+
% 4. Lag-independent kernel: Doppler-lag form: G1[l]
|
|
130
|
+
%---------------------------------------------------------------------
|
|
131
|
+
if(~iscell(kern_params))
|
|
132
|
+
error(['lag-independent kernel parameters should be of the form: ' ...
|
|
133
|
+
'{win_length,win_name}']);
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
tf=li_gdtfd(x,kern_params,Ntime);
|
|
137
|
+
|
|
138
|
+
otherwise
|
|
139
|
+
warning('kern_type should be either: nonsep, sep, DI, or LI');
|
|
140
|
+
tf=[];
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if(DBmem), s=whos; fprintf('total memory used: mem=%s\n',disp_bytes(sum([s.bytes]))); end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
% what directory is this file in?
|
|
3
|
+
cur_full_path=mfilename('fullpath');
|
|
4
|
+
cur_fname=mfilename();
|
|
5
|
+
i=findstr(cur_full_path,cur_fname);
|
|
6
|
+
cur_dir=cur_full_path(1:(i-1));
|
|
7
|
+
|
|
8
|
+
% add the paths:
|
|
9
|
+
addpath( genpath(cur_dir) );
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
clear cur_full_path cur_fname cur_dir;
|
|
13
|
+
|
|
Binary file
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% check_dec_params_seq: Check and return arbitrary set from {k_1,k_2,...,k_J} samples
|
|
3
|
+
% could be for n (time) sample points also.
|
|
4
|
+
%
|
|
5
|
+
% Syntax: k=check_dec_params_seq(dec_param,N,time_freq_str)
|
|
6
|
+
%
|
|
7
|
+
% Inputs:
|
|
8
|
+
% dec_param,N,time_freq_str -
|
|
9
|
+
%
|
|
10
|
+
% Outputs:
|
|
11
|
+
% k -
|
|
12
|
+
%
|
|
13
|
+
% Example:
|
|
14
|
+
%
|
|
15
|
+
%
|
|
16
|
+
|
|
17
|
+
% John M. O' Toole, University College Cork
|
|
18
|
+
% Started: 23-04-2014
|
|
19
|
+
%
|
|
20
|
+
% last update: Time-stamp: <2014-04-23 15:36:55 (otoolej)>
|
|
21
|
+
%-------------------------------------------------------------------------------
|
|
22
|
+
function [k,Nfreq,dec_param]=check_dec_params_seq(dec_param,N,time_freq_str,check_param)
|
|
23
|
+
if(nargin<3 || isempty(time_freq_str)), time_freq_str='Frequency'; end
|
|
24
|
+
if(nargin<4 || isempty(check_param)), check_param=1; end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
%---------------------------------------------------------------------
|
|
29
|
+
% 0. check if parameters are ok:
|
|
30
|
+
%---------------------------------------------------------------------
|
|
31
|
+
dec_param=unique(dec_param);
|
|
32
|
+
|
|
33
|
+
if(~all(dec_param==fix(dec_param)))
|
|
34
|
+
error([time_freq_str ' decimation parameters must be integers.']);
|
|
35
|
+
end
|
|
36
|
+
if(any(dec_param>=N) || any(dec_param<0))
|
|
37
|
+
error([time_freq_str ' decimation values need to within 0<=k<=N-1']);
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
%---------------------------------------------------------------------
|
|
42
|
+
% 1. set parameters:
|
|
43
|
+
%---------------------------------------------------------------------
|
|
44
|
+
if(length(dec_param)==1)
|
|
45
|
+
% decimation parameter is not a sequence:
|
|
46
|
+
if(check_param)
|
|
47
|
+
dec_param=check_dec_value(dec_param,N,time_freq_str);
|
|
48
|
+
end
|
|
49
|
+
k=0:dec_param:N-1;
|
|
50
|
+
|
|
51
|
+
elseif(length(dec_param)>1)
|
|
52
|
+
k=dec_param;
|
|
53
|
+
else
|
|
54
|
+
k=0:N-1;
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if(any(k>=N) || any(k<0))
|
|
59
|
+
error([time_freq_str ' decimation values need to within 0<=k<=N-1']);
|
|
60
|
+
end
|
|
61
|
+
Nfreq=length(k);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
function dec_param=check_dec_value(dec_param,N,time_freq_str)
|
|
65
|
+
%---------------------------------------------------------------------
|
|
66
|
+
% check (or set) that N/a is an integer
|
|
67
|
+
%---------------------------------------------------------------------
|
|
68
|
+
if(rem(N,dec_param))
|
|
69
|
+
warning(['N not divisable by ' time_freq_str ' decimation factor. Increasing....']);
|
|
70
|
+
while( rem(N,dec_param) )
|
|
71
|
+
dec_param=dec_param+1;
|
|
72
|
+
end
|
|
73
|
+
disp( ['... decimation factor now=' num2str(dec_param)]);
|
|
74
|
+
if(dec_param>=N)
|
|
75
|
+
error([time_freq_str ' decimation factor is equal to N. N is prime? Pick smaller ' ...
|
|
76
|
+
'decimation parameter']);
|
|
77
|
+
dec_param=1;
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
%% disp error between two matrices ..
|
|
2
|
+
function dispEE( a, b );
|
|
3
|
+
|
|
4
|
+
ee = a - b;
|
|
5
|
+
diff_re = max( abs(real(ee(:))) );
|
|
6
|
+
diff_im = max( abs(imag(ee(:))) );
|
|
7
|
+
a_name=deblank(inputname(1));
|
|
8
|
+
b_name=deblank(inputname(2));
|
|
9
|
+
fprintf('<< %s - %s = %g + j%g >>\n',a_name,b_name,diff_re,diff_im);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% Display variables to standard output
|
|
3
|
+
%
|
|
4
|
+
% DATE: 07-09-2010
|
|
5
|
+
%-------------------------------------------------------------------------------
|
|
6
|
+
function dispVars( varargin )
|
|
7
|
+
% $$$ for i=1:nargin
|
|
8
|
+
% $$$ keyboard;
|
|
9
|
+
% $$$ varargin{i}
|
|
10
|
+
% $$$ end
|
|
11
|
+
|
|
12
|
+
str = '';
|
|
13
|
+
for i=1:nargin
|
|
14
|
+
if( iscell(varargin{i}) )
|
|
15
|
+
for j=1:length(varargin{i})
|
|
16
|
+
str = [ str ' |' char(inputname(i)) '(' num2str(j) ') =' ...
|
|
17
|
+
num2str(varargin{i}{j}) ];
|
|
18
|
+
end
|
|
19
|
+
else
|
|
20
|
+
|
|
21
|
+
str = strcat(str,' |',char(inputname(i)),'=',num2str(varargin{i}));
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
disp(str);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function str = disp_bytes(NumBytes)
|
|
2
|
+
% BYTES2STR Private function to take integer bytes and convert it to
|
|
3
|
+
% scale-appropriate size.
|
|
4
|
+
%
|
|
5
|
+
|
|
6
|
+
% taken from 'StackOverflow' response, by 'MatlabSorter', 31/1/11
|
|
7
|
+
|
|
8
|
+
scale = floor(log(NumBytes)/log(1024));
|
|
9
|
+
switch scale
|
|
10
|
+
case 0
|
|
11
|
+
str = [sprintf('%.0f',NumBytes) ' b'];
|
|
12
|
+
case 1
|
|
13
|
+
str = [sprintf('%.2f',NumBytes/(1024)) ' kb'];
|
|
14
|
+
case 2
|
|
15
|
+
str = [sprintf('%.2f',NumBytes/(1024^2)) ' Mb'];
|
|
16
|
+
case 3
|
|
17
|
+
str = [sprintf('%.2f',NumBytes/(1024^3)) ' Gb'];
|
|
18
|
+
case 4
|
|
19
|
+
str = [sprintf('%.2f',NumBytes/(1024^4)) ' Tb'];
|
|
20
|
+
case -inf
|
|
21
|
+
% Size occasionally returned as zero (eg some Java objects).
|
|
22
|
+
str = 'Not Available';
|
|
23
|
+
otherwise
|
|
24
|
+
str = 'Over a petabyte!!!';
|
|
25
|
+
end
|