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,40 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% fold_vector_full: fold the vector for frequency decimation:
|
|
3
|
+
%
|
|
4
|
+
% y[n] = y[n] + sum_{p=0}^{a-l} x[pJ+n]
|
|
5
|
+
%
|
|
6
|
+
% for n=0,1,...,J-1
|
|
7
|
+
%
|
|
8
|
+
% which returns DFT{y[n]} = Y[ak]
|
|
9
|
+
%
|
|
10
|
+
% Syntax: y=fold_vector_full(x,J,a)
|
|
11
|
+
%
|
|
12
|
+
% Inputs:
|
|
13
|
+
% x,J,a -
|
|
14
|
+
%
|
|
15
|
+
% Outputs:
|
|
16
|
+
% y -
|
|
17
|
+
%
|
|
18
|
+
% Example:
|
|
19
|
+
%
|
|
20
|
+
%
|
|
21
|
+
|
|
22
|
+
% John M. O' Toole, University College Cork
|
|
23
|
+
% Started: 23-04-2014
|
|
24
|
+
%
|
|
25
|
+
% last update: Time-stamp: <2014-04-23 17:11:54 (otoolej)>
|
|
26
|
+
%-------------------------------------------------------------------------------
|
|
27
|
+
function y=fold_vector_full(x,J,a)
|
|
28
|
+
% Assume that all parameters (J,a) are sane.
|
|
29
|
+
|
|
30
|
+
y=zeros(J,1);
|
|
31
|
+
x=x(:);
|
|
32
|
+
|
|
33
|
+
n=0:J-1;
|
|
34
|
+
y(n+1)=x(n+1);
|
|
35
|
+
for p=1:a-1
|
|
36
|
+
y(n+1)=y(n+1)+x(p*J+n+1);
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
% scale by decimation factor:
|
|
40
|
+
y=y./a;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% fold_vector_half: Fold vector
|
|
3
|
+
%
|
|
4
|
+
% y[n] = y[n] + sum_{p=0}^{a-l} x[pJ+n]
|
|
5
|
+
%
|
|
6
|
+
% for n=0,1,...,Jh
|
|
7
|
+
%
|
|
8
|
+
% Syntax: y=fold_vector_half(x,J,Jh,a)
|
|
9
|
+
%
|
|
10
|
+
% Inputs:
|
|
11
|
+
% x,J,Jh,a -
|
|
12
|
+
%
|
|
13
|
+
% Outputs:
|
|
14
|
+
% y -
|
|
15
|
+
%
|
|
16
|
+
% Example:
|
|
17
|
+
%
|
|
18
|
+
%
|
|
19
|
+
|
|
20
|
+
% John M. O' Toole, University College Cork
|
|
21
|
+
% Started: 23-04-2014
|
|
22
|
+
%
|
|
23
|
+
% last update: Time-stamp: <2014-04-23 14:05:04 (otoolej)>
|
|
24
|
+
%-------------------------------------------------------------------------------
|
|
25
|
+
function y=fold_vector_half(x,J,Jh,a)
|
|
26
|
+
% Assume that all parameters (J,Jh,a) are sane.
|
|
27
|
+
|
|
28
|
+
y=zeros(Jh+1,1);
|
|
29
|
+
x=x(:);
|
|
30
|
+
|
|
31
|
+
n=0:(Jh);
|
|
32
|
+
for p=0:a-1
|
|
33
|
+
y(n+1)=y(n+1)+x(p*J+n+1);
|
|
34
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% Generate a linear frequency modulated (LFM) signal
|
|
3
|
+
%
|
|
4
|
+
% USE: sig=gen_LFM(N,fstart,fstop,phase)
|
|
5
|
+
%
|
|
6
|
+
% INPUT:
|
|
7
|
+
% N = length of LFM signal
|
|
8
|
+
% fstart = starting frequency
|
|
9
|
+
% fend = ending frequency
|
|
10
|
+
% phase = (optional) phase offset
|
|
11
|
+
%
|
|
12
|
+
% OUTPUT:
|
|
13
|
+
% sig = LFM signal of length-N
|
|
14
|
+
%
|
|
15
|
+
% EXAMPLE:
|
|
16
|
+
% N=256; fstart=0.1; fend=0.4;
|
|
17
|
+
% x=gen_LFM(N,fstart,fend);
|
|
18
|
+
% plot(x);
|
|
19
|
+
%-------------------------------------------------------------------------------
|
|
20
|
+
function sig=gen_LFM(N,fstart,fstop,phase)
|
|
21
|
+
if(nargin<1 || isempty(N)) N=128; end
|
|
22
|
+
if(nargin<2 || isempty(fstart)) fstart=0.1; end
|
|
23
|
+
if(nargin<3 || isempty(fstop)) fstop=0.4; end
|
|
24
|
+
if(nargin<4 || isempty(phase)) phase=0; end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
n=0:N-1;
|
|
29
|
+
sig=cos( 2*pi.*(fstart.*n + ((fstop-fstart)/(2*N)).*(n.^2)) + phase );
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% get_analytic_signal: analytic signal as per [1]
|
|
3
|
+
%
|
|
4
|
+
% Syntax: [z,N2,N,Nh]=get_analytic_signal(z)
|
|
5
|
+
%
|
|
6
|
+
% INPUT:
|
|
7
|
+
% s = real-valued signal
|
|
8
|
+
%
|
|
9
|
+
% OUTPUT:
|
|
10
|
+
% z = complex-valued analytic signal
|
|
11
|
+
%
|
|
12
|
+
% EXAMPLE:
|
|
13
|
+
% N=64; f=0.1; N2=2*N;
|
|
14
|
+
% s=cos( 2*pi*f.*(0:N-1));
|
|
15
|
+
% z=get_analytic_signal(s);
|
|
16
|
+
% plot(1:N2,real(z),1:N2,imag(z));
|
|
17
|
+
% legend('real','imaginary');
|
|
18
|
+
%
|
|
19
|
+
%
|
|
20
|
+
% [1] J. M. O' Toole, M. Mesbah, and B. Boashash, "A New Discrete Analytic Signal for
|
|
21
|
+
% Reducing Aliasing in the Discrete Wigner-Ville Distribution", IEEE Trans. on Signal
|
|
22
|
+
% Processing, vol. 56, no. 11, pp. 5427-5434, Nov. 2008.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
% John M. O' Toole, University College Cork
|
|
26
|
+
% Started: 14-04-2014
|
|
27
|
+
%
|
|
28
|
+
% last update: Time-stamp: <2016-08-11 17:18:41 (otoolej)>
|
|
29
|
+
%-------------------------------------------------------------------------------
|
|
30
|
+
function [z,N2,N,Nh]=get_analytic_signal(z)
|
|
31
|
+
if(rem(length(z),2))
|
|
32
|
+
warn_str=sprintf(['odd-length signal.\nCurrently, code works for even-length signal ' ...
|
|
33
|
+
'only.\n\nRemoving last sample of the signal to force to ' ...
|
|
34
|
+
'even-length.\n']);
|
|
35
|
+
warning(warn_str);
|
|
36
|
+
z=z(1:(end-1));
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if(isreal(z))
|
|
41
|
+
z=gen_analytic(z);
|
|
42
|
+
else
|
|
43
|
+
warn_str=sprintf(['using complex-valued signal; assuming this is an analytic signal ' ...
|
|
44
|
+
'zero-padded to length-2N?\n\n If unsure, input the real part ' ...
|
|
45
|
+
'of signal only, i.e. real(x)\n'] );
|
|
46
|
+
warning(warn_str);
|
|
47
|
+
end
|
|
48
|
+
N2=length(z); N=N2/2; Nh=ceil(N/2);
|
|
49
|
+
|
|
50
|
+
if(N~=fix(N))
|
|
51
|
+
error('Analytic signal must be length 2N.');
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
function z=gen_analytic(s1)
|
|
57
|
+
%---------------------------------------------------------------------
|
|
58
|
+
% generate the analytic signal (with zero-padding in the time-direction)
|
|
59
|
+
%---------------------------------------------------------------------
|
|
60
|
+
s1=real(s1);
|
|
61
|
+
N=length(s1); N2=2*N;
|
|
62
|
+
|
|
63
|
+
% 1. zero-pad N-point signal to 2N
|
|
64
|
+
s1=[s1(:); zeros(N,1)];
|
|
65
|
+
S1=fft(s1);
|
|
66
|
+
|
|
67
|
+
% 2. Get analytic signal of 2N-point signal
|
|
68
|
+
H=zeros(N2,1);
|
|
69
|
+
H([1 N+1])=1;
|
|
70
|
+
H(2:N)=2;
|
|
71
|
+
z_cb=ifft(S1.*H);
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
% 3. Force the second half of the time-domain signal to zero.
|
|
75
|
+
z=[z_cb(1:N); zeros(N,1)];
|
|
76
|
+
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
%--------------------------------------------------------------------------------
|
|
2
|
+
% General function to calculate a window function (mostly a wrapper for the existing
|
|
3
|
+
% window functions).
|
|
4
|
+
%
|
|
5
|
+
% USE: win = get_window( win_length, win_type, [win_param], [DFT_WINDOW], [Npad] )
|
|
6
|
+
%
|
|
7
|
+
% INPUT:
|
|
8
|
+
% win_length = length of window
|
|
9
|
+
% win_type = type of window: { 'delta' | 'rect' | 'bart' | 'hamm'
|
|
10
|
+
% | 'hann' | 'tukey' | 'gauss' | 'cosh' | 'blackmanharris' }
|
|
11
|
+
% win_param = (optional) window parameter.
|
|
12
|
+
% DFT_WINDOW = (optional) parameter { 0 | 1 }.
|
|
13
|
+
% If 1 returns DFT of window.
|
|
14
|
+
% Npad = (optional) zero-pad window to length Npad.
|
|
15
|
+
%
|
|
16
|
+
% OUTPUT:
|
|
17
|
+
% win = window
|
|
18
|
+
%
|
|
19
|
+
% See also: BARTLETT, HANNING, HAMMING, GAUSSWIN, TUKEYWIN, CIRCSHIFT, FFT
|
|
20
|
+
%
|
|
21
|
+
% EXAMPLE
|
|
22
|
+
% N=64;
|
|
23
|
+
% win=get_window(N,'tukey',0.4,0,2*N);
|
|
24
|
+
% plot(win);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
% Copyright (C) 2007,2008 John M. O' Toole, The University of Queensland
|
|
28
|
+
%
|
|
29
|
+
% This program is free software: you can redistribute it and/or modify
|
|
30
|
+
% it under the terms of the GNU General Public License as published by
|
|
31
|
+
% the Free Software Foundation, either version 3 of the License, or
|
|
32
|
+
% (at your option) any later version.
|
|
33
|
+
%
|
|
34
|
+
% This program is distributed in the hope that it will be useful,
|
|
35
|
+
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
36
|
+
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
37
|
+
% GNU General Public License for more details.
|
|
38
|
+
%
|
|
39
|
+
% You should have received a copy of the GNU General Public License
|
|
40
|
+
% along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
41
|
+
%--------------------------------------------------------------------------------
|
|
42
|
+
function win = get_window( win_length, win_type, win_param, DFT_WINDOW, Npad )
|
|
43
|
+
if( nargin<3 ) win_param=[]; end
|
|
44
|
+
if( nargin<4 ) DFT_WINDOW=0; end
|
|
45
|
+
if( nargin<5 ) Npad=0; end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
win=get_win(win_length,win_type,win_param,DFT_WINDOW);
|
|
49
|
+
win=shift_win(win);
|
|
50
|
+
|
|
51
|
+
if(Npad>0)
|
|
52
|
+
win=pad_win(win,Npad);
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
function win=get_win(win_length, win_type, win_param, DFT_WINDOW )
|
|
58
|
+
%--------------------------------------------------------------------------------
|
|
59
|
+
% Get the window. Negative indices are first.
|
|
60
|
+
%--------------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
switch win_type
|
|
63
|
+
case 'delta'
|
|
64
|
+
win=zeros(win_length,1);
|
|
65
|
+
wh = floor(win_length/2);
|
|
66
|
+
win(wh+1)=1;
|
|
67
|
+
case 'rect'
|
|
68
|
+
win(1:win_length) = 1;
|
|
69
|
+
case {'bart', 'bartlett'}
|
|
70
|
+
win = bartlett( win_length );
|
|
71
|
+
case {'hamm', 'hamming'}
|
|
72
|
+
win = hamming( win_length );
|
|
73
|
+
case {'hann', 'hanning'}
|
|
74
|
+
win = hanning( win_length );
|
|
75
|
+
case 'tukey'
|
|
76
|
+
% NOTE: seems to be problem with Octave's (v2.9.12) tukeywin.m for N odd.
|
|
77
|
+
if(isempty(win_param))
|
|
78
|
+
win = tukeywin( win_length );
|
|
79
|
+
else
|
|
80
|
+
win = tukeywin( win_length, win_param );
|
|
81
|
+
end
|
|
82
|
+
case 'gauss'
|
|
83
|
+
if(isempty(win_param))
|
|
84
|
+
win = gausswin( win_length );
|
|
85
|
+
else
|
|
86
|
+
win = gausswin( win_length, win_param );
|
|
87
|
+
end
|
|
88
|
+
case 'cosh'
|
|
89
|
+
win_hlf = fix( win_length / 2);
|
|
90
|
+
|
|
91
|
+
if(isempty(win_param))
|
|
92
|
+
win_param = 0.01;
|
|
93
|
+
end
|
|
94
|
+
for m = -win_hlf:win_hlf
|
|
95
|
+
win(mod(m,win_length)+1) = cosh( m ).^( -2 * win_param );
|
|
96
|
+
end
|
|
97
|
+
win = fftshift(win);
|
|
98
|
+
case {'blackmanharris', 'bmh'}
|
|
99
|
+
win = blackmanharris(win_length, 'symmetric');
|
|
100
|
+
case {'nuttall'}
|
|
101
|
+
win = nuttallwin(win_length, 'symmetric');
|
|
102
|
+
case {'dolph', 'chebwin'}
|
|
103
|
+
win = chebwin(win_length, win_param);
|
|
104
|
+
|
|
105
|
+
otherwise
|
|
106
|
+
error(['Unknown window type ' win_type]);
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
%---------------------------------------------------------------------
|
|
111
|
+
% If want the DFT of win
|
|
112
|
+
%---------------------------------------------------------------------
|
|
113
|
+
if(DFT_WINDOW)
|
|
114
|
+
win=circshift(win(:),ceil(win_length/2));
|
|
115
|
+
win=fft(win);
|
|
116
|
+
win=circshift(win(:),floor(win_length/2));
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
function w=shift_win(w)
|
|
121
|
+
%--------------------------------------------------------------------------------
|
|
122
|
+
% Shift the window so that positive indices are first.
|
|
123
|
+
%--------------------------------------------------------------------------------
|
|
124
|
+
N=length(w);
|
|
125
|
+
w=circshift(w(:),ceil(N/2));
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
function w_pad=pad_win(w,Npad)
|
|
130
|
+
%--------------------------------------------------------------------------------
|
|
131
|
+
%
|
|
132
|
+
% Pad window to Npad.
|
|
133
|
+
%
|
|
134
|
+
% Presume that positive window indices are first.
|
|
135
|
+
%
|
|
136
|
+
% When N is even use method described in [1]
|
|
137
|
+
%
|
|
138
|
+
% References:
|
|
139
|
+
% [1] S. Lawrence Marple, Jr., Computing the discrete-time analytic
|
|
140
|
+
% signal via FFT, IEEE Transactions on Signal Processing, Vol. 47,
|
|
141
|
+
% No. 9, September 1999, pp.2600--2603.
|
|
142
|
+
%
|
|
143
|
+
%--------------------------------------------------------------------------------
|
|
144
|
+
w=w(:);
|
|
145
|
+
w_pad=zeros(Npad,1);
|
|
146
|
+
N=length(w);
|
|
147
|
+
Nh=floor(N/2);
|
|
148
|
+
if(Npad<N) error('Npad is less than N'); end
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
% Trival case:
|
|
152
|
+
if(N==Npad)
|
|
153
|
+
w_pad=w;
|
|
154
|
+
return;
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
% For N odd:
|
|
159
|
+
if( rem(N,2)==1 )
|
|
160
|
+
n=0:Nh;
|
|
161
|
+
w_pad(n+1)=w(n+1);
|
|
162
|
+
n=1:Nh;
|
|
163
|
+
w_pad(Npad-n+1)=w(N-n+1);
|
|
164
|
+
|
|
165
|
+
% For N even:
|
|
166
|
+
% split the Nyquist frequency in two and distribute over positive
|
|
167
|
+
% and negative indices.
|
|
168
|
+
else
|
|
169
|
+
n=0:(Nh-1);
|
|
170
|
+
w_pad(n+1)=w(n+1);
|
|
171
|
+
w_pad(Nh+1)=w(Nh+1)/2;
|
|
172
|
+
|
|
173
|
+
n=1:Nh-1;
|
|
174
|
+
w_pad(Npad-n+1)=w(N-n+1);
|
|
175
|
+
w_pad(Npad-Nh+1)=w(Nh+1)/2;
|
|
176
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
%--------------------------------------------------------------------------------
|
|
2
|
+
%
|
|
3
|
+
% Pad window to Npad.
|
|
4
|
+
%
|
|
5
|
+
% Presume that positive window indices are first.
|
|
6
|
+
%
|
|
7
|
+
% USE: w_pad=padWin(w,Npad)
|
|
8
|
+
%
|
|
9
|
+
% INPUT:
|
|
10
|
+
% w = window (vector) of length N
|
|
11
|
+
% Npad = pad window to length N (Npad>N)
|
|
12
|
+
%
|
|
13
|
+
% OUTPUT:
|
|
14
|
+
% w_pad = window of length N zeropadded to length Npad
|
|
15
|
+
%
|
|
16
|
+
%
|
|
17
|
+
% When N is even use method described in [1]
|
|
18
|
+
%
|
|
19
|
+
% References:
|
|
20
|
+
% [1] S. Lawrence Marple, Jr., Computing the discrete-time analytic
|
|
21
|
+
% signal via FFT, IEEE Transactions on Signal Processing, Vol. 47,
|
|
22
|
+
% No. 9, September 1999, pp.2600--2603.
|
|
23
|
+
%
|
|
24
|
+
%
|
|
25
|
+
% STARTED: 04-01-2008
|
|
26
|
+
|
|
27
|
+
% Copyright (c) 2010, John M. O' Toole, The University of Queensland
|
|
28
|
+
% All rights reserved.
|
|
29
|
+
%
|
|
30
|
+
% Redistribution and use in source and binary forms, with or without
|
|
31
|
+
% modification, are permitted provided that the following
|
|
32
|
+
% conditions are met:
|
|
33
|
+
% * Redistributions of source code must retain the above
|
|
34
|
+
% copyright notice, this list of conditions and the following
|
|
35
|
+
% disclaimer.
|
|
36
|
+
% * Redistributions in binary form must reproduce the above
|
|
37
|
+
% copyright notice, this list of conditions and the following
|
|
38
|
+
% disclaimer in the documentation and/or other materials
|
|
39
|
+
% provided with the distribution.
|
|
40
|
+
% * Neither the name of the The University of Queensland nor the
|
|
41
|
+
% names of its contributors may be used to endorse or promote
|
|
42
|
+
% products derived from this software without specific prior
|
|
43
|
+
% written permission.
|
|
44
|
+
%
|
|
45
|
+
% THIS SOFTWARE IS PROVIDED BY JOHN M. O' TOOLE ''AS IS'' AND ANY
|
|
46
|
+
% EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
47
|
+
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
48
|
+
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JOHN M. O' TOOLE BE
|
|
49
|
+
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
50
|
+
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
51
|
+
% OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
52
|
+
% BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
53
|
+
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
54
|
+
% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
55
|
+
% USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
56
|
+
% DAMAGE.
|
|
57
|
+
%--------------------------------------------------------------------------------
|
|
58
|
+
function w_pad=padWin(w,Npad)
|
|
59
|
+
DB=0;
|
|
60
|
+
w=w(:);
|
|
61
|
+
w_pad=zeros(Npad,1);
|
|
62
|
+
N=length(w);
|
|
63
|
+
Nh=floor(N/2);
|
|
64
|
+
if(DB) dispVars(N,Npad); end
|
|
65
|
+
if(Npad<N) error('Npad is less than N'); end
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
% Trival case:
|
|
69
|
+
if(N==Npad)
|
|
70
|
+
w_pad=w;
|
|
71
|
+
return;
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
% For N odd:
|
|
76
|
+
if( rem(N,2)==1 )
|
|
77
|
+
if(DB) dispDB('odd'); end
|
|
78
|
+
n=0:Nh;
|
|
79
|
+
w_pad(n+1)=w(n+1);
|
|
80
|
+
n=1:Nh;
|
|
81
|
+
w_pad(Npad-n+1)=w(N-n+1);
|
|
82
|
+
|
|
83
|
+
% For N even:
|
|
84
|
+
% split the Nyquist frequency in two and distribute over positive
|
|
85
|
+
% and negative indices.
|
|
86
|
+
else
|
|
87
|
+
if(DB) dispDB('even'); end
|
|
88
|
+
n=0:(Nh-1);
|
|
89
|
+
w_pad(n+1)=w(n+1);
|
|
90
|
+
w_pad(Nh+1)=w(Nh+1)/2;
|
|
91
|
+
|
|
92
|
+
n=1:Nh-1;
|
|
93
|
+
w_pad(Npad-n+1)=w(N-n+1);
|
|
94
|
+
w_pad(Npad-Nh+1)=w(Nh+1)/2;
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
%-------------------------------------------------------------------------------
|
|
2
|
+
% Plot TFD and time/frequency plots
|
|
3
|
+
%
|
|
4
|
+
% USE: vtfd(tfd,sig,Fs)
|
|
5
|
+
%
|
|
6
|
+
% INPUT:
|
|
7
|
+
% tfd - the time-frequency distribution
|
|
8
|
+
% sig - time-domain signal
|
|
9
|
+
% Fs - sampling frequency
|
|
10
|
+
|
|
11
|
+
%
|
|
12
|
+
% Copyright (c) 2010, John M. O' Toole, The University of Queensland
|
|
13
|
+
% All rights reserved.
|
|
14
|
+
%
|
|
15
|
+
% Redistribution and use in source and binary forms, with or without
|
|
16
|
+
% modification, are permitted provided that the following
|
|
17
|
+
% conditions are met:
|
|
18
|
+
% * Redistributions of source code must retain the above
|
|
19
|
+
% copyright notice, this list of conditions and the following
|
|
20
|
+
% disclaimer.
|
|
21
|
+
% * Redistributions in binary form must reproduce the above
|
|
22
|
+
% copyright notice, this list of conditions and the following
|
|
23
|
+
% disclaimer in the documentation and/or other materials
|
|
24
|
+
% provided with the distribution.
|
|
25
|
+
% * Neither the name of the The University of Queensland nor the
|
|
26
|
+
% names of its contributors may be used to endorse or promote
|
|
27
|
+
% products derived from this software without specific prior
|
|
28
|
+
% written permission.
|
|
29
|
+
%
|
|
30
|
+
% THIS SOFTWARE IS PROVIDED BY JOHN M. O' TOOLE ''AS IS'' AND ANY
|
|
31
|
+
% EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
32
|
+
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
33
|
+
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JOHN M. O' TOOLE BE
|
|
34
|
+
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
35
|
+
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
36
|
+
% OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
37
|
+
% BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
38
|
+
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
39
|
+
% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
40
|
+
% USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
41
|
+
% DAMAGE.
|
|
42
|
+
%-------------------------------------------------------------------------------
|
|
43
|
+
function [h_image,h_time,h_freq]=vtfd(tfd,s1,FS,n,k)
|
|
44
|
+
if(nargin<3 || isempty(FS))
|
|
45
|
+
FS=1;
|
|
46
|
+
end
|
|
47
|
+
if(nargin<2 || isempty(s1))
|
|
48
|
+
TFD_ONLY=1;
|
|
49
|
+
Ntime=size(tfd,1);
|
|
50
|
+
else
|
|
51
|
+
TFD_ONLY=0;
|
|
52
|
+
Ntime=length(s1);
|
|
53
|
+
end
|
|
54
|
+
if(nargin<4 || isempty(n)), n=[]; end
|
|
55
|
+
if(nargin<5 || isempty(k)), k=[]; end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
[N,M]=size(tfd);
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
% $$$ clf;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
%---------------------------------------------------------------------
|
|
65
|
+
% Frame sizes:
|
|
66
|
+
%---------------------------------------------------------------------
|
|
67
|
+
X_AXIS_WIDTH=0.75;
|
|
68
|
+
Y_AXIS_HEIGHT=0.75;
|
|
69
|
+
X_AXIS_START=0.23;
|
|
70
|
+
Y_AXIS_START=0.23;
|
|
71
|
+
TIME_FREQ_PLOTS_WIDTH=0.15;
|
|
72
|
+
TIME_FREQ_PLOTS_GAP=0.07;
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
%---------------------------------------------------------------------
|
|
76
|
+
% X/Y tick labels
|
|
77
|
+
%---------------------------------------------------------------------
|
|
78
|
+
if(isempty(n))
|
|
79
|
+
ntime=1:Ntime; ntime=ntime./FS;
|
|
80
|
+
n=linspace(ntime(1),ntime(end),N);
|
|
81
|
+
else
|
|
82
|
+
ntime=n;
|
|
83
|
+
end
|
|
84
|
+
Mh_time=ceil(Ntime/2); Mh=ceil(M/2);
|
|
85
|
+
if(isempty(k))
|
|
86
|
+
|
|
87
|
+
k=linspace(0,0.5,Mh);
|
|
88
|
+
k_time=linspace(0,0.5,Mh_time);
|
|
89
|
+
k=k.*FS;
|
|
90
|
+
else
|
|
91
|
+
k_time=k;
|
|
92
|
+
end
|
|
93
|
+
% $$$ keyboard;
|
|
94
|
+
|
|
95
|
+
if(TFD_ONLY)
|
|
96
|
+
imagesc(k,n,tfd); axis('xy');
|
|
97
|
+
|
|
98
|
+
% seems to bug with Octave and gnuplot, so have to force square:
|
|
99
|
+
if(is_octave), axis('square'); end
|
|
100
|
+
|
|
101
|
+
else
|
|
102
|
+
%---------------------------------------------------------------------
|
|
103
|
+
% 1. time plot
|
|
104
|
+
%---------------------------------------------------------------------
|
|
105
|
+
s1=real(s1);
|
|
106
|
+
h_time=subplot(2,2,1);
|
|
107
|
+
set(h_time,'position',[(X_AXIS_START-TIME_FREQ_PLOTS_WIDTH-TIME_FREQ_PLOTS_GAP) ...
|
|
108
|
+
Y_AXIS_START TIME_FREQ_PLOTS_WIDTH ...
|
|
109
|
+
Y_AXIS_HEIGHT]);
|
|
110
|
+
plot(s1,1:length(s1));
|
|
111
|
+
axis('tight');
|
|
112
|
+
grid('on');
|
|
113
|
+
set(h_time,'xticklabel',[]); set(h_time,'yticklabel',[]);
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
%---------------------------------------------------------------------
|
|
117
|
+
% 2. freq plot
|
|
118
|
+
%---------------------------------------------------------------------
|
|
119
|
+
S1=fft(s1);
|
|
120
|
+
h_freq=subplot(2,2,4);
|
|
121
|
+
set(h_freq,'position',[X_AXIS_START (Y_AXIS_START- ...
|
|
122
|
+
TIME_FREQ_PLOTS_WIDTH-TIME_FREQ_PLOTS_GAP) ...
|
|
123
|
+
X_AXIS_WIDTH TIME_FREQ_PLOTS_WIDTH]);
|
|
124
|
+
plot(1:Mh_time,abs(S1(1:Mh_time)).^2);
|
|
125
|
+
axis('tight');
|
|
126
|
+
grid('on');
|
|
127
|
+
set(h_freq,'xticklabel',[]); set(h_freq,'yticklabel',[]);
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
%---------------------------------------------------------------------
|
|
131
|
+
% 2. time-freq plot
|
|
132
|
+
%---------------------------------------------------------------------
|
|
133
|
+
h_image=subplot(2,2,2);
|
|
134
|
+
set(h_image,'position',[X_AXIS_START Y_AXIS_START X_AXIS_WIDTH ...
|
|
135
|
+
Y_AXIS_HEIGHT]);
|
|
136
|
+
|
|
137
|
+
imagesc(k,n,tfd); axis('xy');
|
|
138
|
+
|
|
139
|
+
% seems to bug with Octave and gnuplot, so have to force square:
|
|
140
|
+
if(is_octave), axis('square'); end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
function r = is_octave ()
|
|
145
|
+
persistent x;
|
|
146
|
+
if (isempty (x))
|
|
147
|
+
x = exist ('OCTAVE_VERSION', 'builtin');
|
|
148
|
+
end
|
|
149
|
+
r = x;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function [IMU_filt, t_tar] = preprocessing_imu(t_orig, IMU_sample, fs_imu)
|
|
2
|
+
%%----Preprocessing of the IMU pipeline----%%
|
|
3
|
+
% Resampling to a uniform sampling rate at 30 Hz
|
|
4
|
+
t_tar = t_orig(1):1/fs_imu:t_orig(end); % Correct target for resampling (by usage of t_start = t_orig(1) and t_end = t_orig(end));
|
|
5
|
+
signal_resampled = spline(t_orig, IMU_sample', t_tar);
|
|
6
|
+
|
|
7
|
+
% High-pass filter for detrending
|
|
8
|
+
[b,a]=butter(4,0.2/(fs_imu/2),'high'); % high-pass filter for gravity removal
|
|
9
|
+
IMU_filt = filtfilt(b,a,double(signal_resampled'));
|
|
10
|
+
|
|
11
|
+
% [zhi,phi,khi] = butter(4,0.2,'high');
|
|
12
|
+
% soshi = zp2sos(zhi,phi,khi);
|
|
13
|
+
% IMU_filt2 = filtfilt(soshi,double(signal_resampled'));
|
|
14
|
+
end
|
|
15
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function [PPG_data, t_tar] = preprocessing_ppg(t_orig, PPG_sample, fs_ppg)
|
|
2
|
+
|
|
3
|
+
% Resampling to a uniform sampling rate at 30 Hz
|
|
4
|
+
t_tar = t_orig(1):1/fs_ppg:t_orig(end); % Correct target for resampling (by usage of t_start and t_end);
|
|
5
|
+
signal_resampled = spline(t_orig, PPG_sample, t_tar); % Spline interpolation used for resampling
|
|
6
|
+
|
|
7
|
+
% Band-pass filter for detrending
|
|
8
|
+
|
|
9
|
+
[b,a]=butter(4,[0.4, 3.5]/(fs_ppg/2),'bandpass'); % band-pass filter for detrending
|
|
10
|
+
PPG_filt = filtfilt(b,a,double(signal_resampled)); % Apply filter
|
|
11
|
+
PPG_data = PPG_filt'; % In case of a sample package error where PPG_filt consists of multiple "parts"
|
|
12
|
+
|
|
13
|
+
end
|