paradigma 0.1.2__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- paradigma/__init__.py +1 -3
- paradigma/constants.py +35 -0
- paradigma/feature_extraction.py +678 -0
- paradigma/gait_analysis.py +413 -0
- paradigma/gait_analysis_config.py +244 -0
- paradigma/heart_rate_analysis.py +127 -0
- paradigma/heart_rate_analysis_config.py +9 -0
- paradigma/heart_rate_util.py +173 -0
- paradigma/imu_preprocessing.py +229 -0
- paradigma/ppg/classifier/LR_PPG_quality.pkl +0 -0
- paradigma/ppg/classifier/LR_model.mat +0 -0
- paradigma/ppg/feat_extraction/acc_feature.m +20 -0
- paradigma/ppg/feat_extraction/peakdet.m +64 -0
- paradigma/ppg/feat_extraction/ppg_features.m +53 -0
- paradigma/ppg/glob_functions/extract_hr_segments.m +37 -0
- paradigma/ppg/glob_functions/extract_overlapping_segments.m +23 -0
- paradigma/ppg/glob_functions/jsonlab/AUTHORS.txt +41 -0
- paradigma/ppg/glob_functions/jsonlab/ChangeLog.txt +74 -0
- paradigma/ppg/glob_functions/jsonlab/LICENSE_BSD.txt +25 -0
- paradigma/ppg/glob_functions/jsonlab/LICENSE_GPLv3.txt +699 -0
- paradigma/ppg/glob_functions/jsonlab/README.txt +394 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/entries +368 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/demo_jsonlab_basic.m.svn-base +180 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/demo_ubjson_basic.m.svn-base +180 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example1.json.svn-base +23 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example2.json.svn-base +22 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example3.json.svn-base +11 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example4.json.svn-base +34 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_basictest.matlab.svn-base +662 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_selftest.m.svn-base +27 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_selftest.matlab.svn-base +144 -0
- paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_speedtest.m.svn-base +21 -0
- paradigma/ppg/glob_functions/jsonlab/examples/demo_jsonlab_basic.m +180 -0
- paradigma/ppg/glob_functions/jsonlab/examples/demo_ubjson_basic.m +180 -0
- paradigma/ppg/glob_functions/jsonlab/examples/example1.json +23 -0
- paradigma/ppg/glob_functions/jsonlab/examples/example2.json +22 -0
- paradigma/ppg/glob_functions/jsonlab/examples/example3.json +11 -0
- paradigma/ppg/glob_functions/jsonlab/examples/example4.json +34 -0
- paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_basictest.matlab +662 -0
- paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_selftest.m +27 -0
- paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_selftest.matlab +144 -0
- paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_speedtest.m +21 -0
- paradigma/ppg/glob_functions/jsonlab/jsonopt.m +32 -0
- paradigma/ppg/glob_functions/jsonlab/loadjson.m +566 -0
- paradigma/ppg/glob_functions/jsonlab/loadubjson.m +528 -0
- paradigma/ppg/glob_functions/jsonlab/mergestruct.m +33 -0
- paradigma/ppg/glob_functions/jsonlab/savejson.m +475 -0
- paradigma/ppg/glob_functions/jsonlab/saveubjson.m +504 -0
- paradigma/ppg/glob_functions/jsonlab/varargin2struct.m +40 -0
- paradigma/ppg/glob_functions/sample_prob_final.m +49 -0
- paradigma/ppg/glob_functions/synchronization.m +76 -0
- paradigma/ppg/glob_functions/tsdf_scan_meta.m +22 -0
- paradigma/ppg/hr_functions/Long_TFD_JOT.m +37 -0
- paradigma/ppg/hr_functions/PPG_TFD_HR.m +59 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/.gitignore +4 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/CHANGELOG.md +23 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/LICENCE.md +27 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/README.md +251 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/README.pdf +0 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_Doppler_kern.m +142 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_Doppler_lag_kern.m +314 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_lag_kern.m +123 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/dec_tfd.m +154 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_di_gdtfd.m +194 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_li_gdtfd.m +200 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_nonsep_gdtfd.m +229 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_sep_gdtfd.m +241 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/di_gdtfd.m +157 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/li_gdtfd.m +190 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/nonsep_gdtfd.m +196 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/sep_gdtfd.m +199 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/full_tfd.m +144 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/load_curdir.m +13 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/pics/decimated_TFDs_examples.png +0 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/pics/full_TFDs_examples.png +0 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/check_dec_params_seq.m +79 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/dispEE.m +9 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/dispVars.m +26 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/disp_bytes.m +25 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/fold_vector_full.m +40 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/fold_vector_half.m +34 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/gen_LFM.m +29 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/get_analytic_signal.m +76 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/get_window.m +176 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/isreal_fn.m +11 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/padWin.m +97 -0
- paradigma/ppg/hr_functions/TFD toolbox JOT/utils/vtfd.m +149 -0
- paradigma/ppg/preprocessing/preprocessing_imu.m +15 -0
- paradigma/ppg/preprocessing/preprocessing_ppg.m +13 -0
- paradigma/ppg_preprocessing.py +313 -0
- paradigma/preprocessing_config.py +64 -0
- paradigma/quantification.py +58 -0
- paradigma/tremor/TremorFeaturesAndClassification.m +345 -0
- paradigma/tremor/feat_extraction/DerivativesExtract.m +22 -0
- paradigma/tremor/feat_extraction/ExtractBandSignalsRMS.m +72 -0
- paradigma/tremor/feat_extraction/MFCCExtract.m +100 -0
- paradigma/tremor/feat_extraction/PSDBandPower.m +52 -0
- paradigma/tremor/feat_extraction/PSDEst.m +63 -0
- paradigma/tremor/feat_extraction/PSDExtrAxis.m +88 -0
- paradigma/tremor/feat_extraction/PSDExtrOpt.m +95 -0
- paradigma/tremor/preprocessing/InterpData.m +32 -0
- paradigma/tremor/weekly_aggregates/WeeklyAggregates.m +295 -0
- paradigma/util.py +50 -0
- paradigma/windowing.py +217 -0
- paradigma-0.2.0.dist-info/LICENSE +192 -0
- paradigma-0.2.0.dist-info/METADATA +58 -0
- paradigma-0.2.0.dist-info/RECORD +108 -0
- paradigma/dummy.py +0 -3
- paradigma-0.1.2.dist-info/LICENSE +0 -201
- paradigma-0.1.2.dist-info/METADATA +0 -18
- paradigma-0.1.2.dist-info/RECORD +0 -6
- {paradigma-0.1.2.dist-info → paradigma-0.2.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
function json=saveubjson(rootname,obj,varargin)
|
|
2
|
+
%
|
|
3
|
+
% json=saveubjson(rootname,obj,filename)
|
|
4
|
+
% or
|
|
5
|
+
% json=saveubjson(rootname,obj,opt)
|
|
6
|
+
% json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
|
|
7
|
+
%
|
|
8
|
+
% convert a MATLAB object (cell, struct or array) into a Universal
|
|
9
|
+
% Binary JSON (UBJSON) binary string
|
|
10
|
+
%
|
|
11
|
+
% author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
|
|
12
|
+
% created on 2013/08/17
|
|
13
|
+
%
|
|
14
|
+
% $Id: saveubjson.m 460 2015-01-03 00:30:45Z fangq $
|
|
15
|
+
%
|
|
16
|
+
% input:
|
|
17
|
+
% rootname: the name of the root-object, when set to '', the root name
|
|
18
|
+
% is ignored, however, when opt.ForceRootName is set to 1 (see below),
|
|
19
|
+
% the MATLAB variable name will be used as the root name.
|
|
20
|
+
% obj: a MATLAB object (array, cell, cell array, struct, struct array)
|
|
21
|
+
% filename: a string for the file name to save the output UBJSON data
|
|
22
|
+
% opt: a struct for additional options, ignore to use default values.
|
|
23
|
+
% opt can have the following fields (first in [.|.] is the default)
|
|
24
|
+
%
|
|
25
|
+
% opt.FileName [''|string]: a file name to save the output JSON data
|
|
26
|
+
% opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
|
|
27
|
+
% array in JSON array format; if sets to 1, an
|
|
28
|
+
% array will be shown as a struct with fields
|
|
29
|
+
% "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
|
|
30
|
+
% sparse arrays, the non-zero elements will be
|
|
31
|
+
% saved to _ArrayData_ field in triplet-format i.e.
|
|
32
|
+
% (ix,iy,val) and "_ArrayIsSparse_" will be added
|
|
33
|
+
% with a value of 1; for a complex array, the
|
|
34
|
+
% _ArrayData_ array will include two columns
|
|
35
|
+
% (4 for sparse) to record the real and imaginary
|
|
36
|
+
% parts, and also "_ArrayIsComplex_":1 is added.
|
|
37
|
+
% opt.ParseLogical [1|0]: if this is set to 1, logical array elem
|
|
38
|
+
% will use true/false rather than 1/0.
|
|
39
|
+
% opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
|
|
40
|
+
% numerical element will be shown without a square
|
|
41
|
+
% bracket, unless it is the root object; if 0, square
|
|
42
|
+
% brackets are forced for any numerical arrays.
|
|
43
|
+
% opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
|
|
44
|
+
% will use the name of the passed obj variable as the
|
|
45
|
+
% root object name; if obj is an expression and
|
|
46
|
+
% does not have a name, 'root' will be used; if this
|
|
47
|
+
% is set to 0 and rootname is empty, the root level
|
|
48
|
+
% will be merged down to the lower level.
|
|
49
|
+
% opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
|
|
50
|
+
% for example, if opt.JSON='foo', the JSON data is
|
|
51
|
+
% wrapped inside a function call as 'foo(...);'
|
|
52
|
+
% opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson
|
|
53
|
+
% back to the string form
|
|
54
|
+
%
|
|
55
|
+
% opt can be replaced by a list of ('param',value) pairs. The param
|
|
56
|
+
% string is equivallent to a field in opt and is case sensitive.
|
|
57
|
+
% output:
|
|
58
|
+
% json: a binary string in the UBJSON format (see http://ubjson.org)
|
|
59
|
+
%
|
|
60
|
+
% examples:
|
|
61
|
+
% jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],...
|
|
62
|
+
% 'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
|
|
63
|
+
% 'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
|
|
64
|
+
% 2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
|
|
65
|
+
% 'MeshCreator','FangQ','MeshTitle','T6 Cube',...
|
|
66
|
+
% 'SpecialData',[nan, inf, -inf]);
|
|
67
|
+
% saveubjson('jsonmesh',jsonmesh)
|
|
68
|
+
% saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')
|
|
69
|
+
%
|
|
70
|
+
% license:
|
|
71
|
+
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
|
|
72
|
+
%
|
|
73
|
+
% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
|
|
74
|
+
%
|
|
75
|
+
|
|
76
|
+
if(nargin==1)
|
|
77
|
+
varname=inputname(1);
|
|
78
|
+
obj=rootname;
|
|
79
|
+
if(isempty(varname))
|
|
80
|
+
varname='root';
|
|
81
|
+
end
|
|
82
|
+
rootname=varname;
|
|
83
|
+
else
|
|
84
|
+
varname=inputname(2);
|
|
85
|
+
end
|
|
86
|
+
if(length(varargin)==1 && ischar(varargin{1}))
|
|
87
|
+
opt=struct('FileName',varargin{1});
|
|
88
|
+
else
|
|
89
|
+
opt=varargin2struct(varargin{:});
|
|
90
|
+
end
|
|
91
|
+
opt.IsOctave=exist('OCTAVE_VERSION','builtin');
|
|
92
|
+
rootisarray=0;
|
|
93
|
+
rootlevel=1;
|
|
94
|
+
forceroot=jsonopt('ForceRootName',0,opt);
|
|
95
|
+
if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0)
|
|
96
|
+
rootisarray=1;
|
|
97
|
+
rootlevel=0;
|
|
98
|
+
else
|
|
99
|
+
if(isempty(rootname))
|
|
100
|
+
rootname=varname;
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot)
|
|
104
|
+
rootname='root';
|
|
105
|
+
end
|
|
106
|
+
json=obj2ubjson(rootname,obj,rootlevel,opt);
|
|
107
|
+
if(~rootisarray)
|
|
108
|
+
json=['{' json '}'];
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
jsonp=jsonopt('JSONP','',opt);
|
|
112
|
+
if(~isempty(jsonp))
|
|
113
|
+
json=[jsonp '(' json ')'];
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
% save to a file if FileName is set, suggested by Patrick Rapin
|
|
117
|
+
if(~isempty(jsonopt('FileName','',opt)))
|
|
118
|
+
fid = fopen(opt.FileName, 'wb');
|
|
119
|
+
fwrite(fid,json);
|
|
120
|
+
fclose(fid);
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
%%-------------------------------------------------------------------------
|
|
124
|
+
function txt=obj2ubjson(name,item,level,varargin)
|
|
125
|
+
|
|
126
|
+
if(iscell(item))
|
|
127
|
+
txt=cell2ubjson(name,item,level,varargin{:});
|
|
128
|
+
elseif(isstruct(item))
|
|
129
|
+
txt=struct2ubjson(name,item,level,varargin{:});
|
|
130
|
+
elseif(ischar(item))
|
|
131
|
+
txt=str2ubjson(name,item,level,varargin{:});
|
|
132
|
+
else
|
|
133
|
+
txt=mat2ubjson(name,item,level,varargin{:});
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
%%-------------------------------------------------------------------------
|
|
137
|
+
function txt=cell2ubjson(name,item,level,varargin)
|
|
138
|
+
txt='';
|
|
139
|
+
if(~iscell(item))
|
|
140
|
+
error('input is not a cell');
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
dim=size(item);
|
|
144
|
+
if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
|
|
145
|
+
item=reshape(item,dim(1),numel(item)/dim(1));
|
|
146
|
+
dim=size(item);
|
|
147
|
+
end
|
|
148
|
+
len=numel(item); % let's handle 1D cell first
|
|
149
|
+
if(len>1)
|
|
150
|
+
if(~isempty(name))
|
|
151
|
+
txt=[S_(checkname(name,varargin{:})) '[']; name='';
|
|
152
|
+
else
|
|
153
|
+
txt='[';
|
|
154
|
+
end
|
|
155
|
+
elseif(len==0)
|
|
156
|
+
if(~isempty(name))
|
|
157
|
+
txt=[S_(checkname(name,varargin{:})) 'Z']; name='';
|
|
158
|
+
else
|
|
159
|
+
txt='Z';
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
for j=1:dim(2)
|
|
163
|
+
if(dim(1)>1) txt=[txt '[']; end
|
|
164
|
+
for i=1:dim(1)
|
|
165
|
+
txt=[txt obj2ubjson(name,item{i,j},level+(len>1),varargin{:})];
|
|
166
|
+
end
|
|
167
|
+
if(dim(1)>1) txt=[txt ']']; end
|
|
168
|
+
end
|
|
169
|
+
if(len>1) txt=[txt ']']; end
|
|
170
|
+
|
|
171
|
+
%%-------------------------------------------------------------------------
|
|
172
|
+
function txt=struct2ubjson(name,item,level,varargin)
|
|
173
|
+
txt='';
|
|
174
|
+
if(~isstruct(item))
|
|
175
|
+
error('input is not a struct');
|
|
176
|
+
end
|
|
177
|
+
dim=size(item);
|
|
178
|
+
if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
|
|
179
|
+
item=reshape(item,dim(1),numel(item)/dim(1));
|
|
180
|
+
dim=size(item);
|
|
181
|
+
end
|
|
182
|
+
len=numel(item);
|
|
183
|
+
|
|
184
|
+
if(~isempty(name))
|
|
185
|
+
if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end
|
|
186
|
+
else
|
|
187
|
+
if(len>1) txt='['; end
|
|
188
|
+
end
|
|
189
|
+
for j=1:dim(2)
|
|
190
|
+
if(dim(1)>1) txt=[txt '[']; end
|
|
191
|
+
for i=1:dim(1)
|
|
192
|
+
names = fieldnames(item(i,j));
|
|
193
|
+
if(~isempty(name) && len==1)
|
|
194
|
+
txt=[txt S_(checkname(name,varargin{:})) '{'];
|
|
195
|
+
else
|
|
196
|
+
txt=[txt '{'];
|
|
197
|
+
end
|
|
198
|
+
if(~isempty(names))
|
|
199
|
+
for e=1:length(names)
|
|
200
|
+
txt=[txt obj2ubjson(names{e},getfield(item(i,j),...
|
|
201
|
+
names{e}),level+(dim(1)>1)+1+(len>1),varargin{:})];
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
txt=[txt '}'];
|
|
205
|
+
end
|
|
206
|
+
if(dim(1)>1) txt=[txt ']']; end
|
|
207
|
+
end
|
|
208
|
+
if(len>1) txt=[txt ']']; end
|
|
209
|
+
|
|
210
|
+
%%-------------------------------------------------------------------------
|
|
211
|
+
function txt=str2ubjson(name,item,level,varargin)
|
|
212
|
+
txt='';
|
|
213
|
+
if(~ischar(item))
|
|
214
|
+
error('input is not a string');
|
|
215
|
+
end
|
|
216
|
+
item=reshape(item, max(size(item),[1 0]));
|
|
217
|
+
len=size(item,1);
|
|
218
|
+
|
|
219
|
+
if(~isempty(name))
|
|
220
|
+
if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end
|
|
221
|
+
else
|
|
222
|
+
if(len>1) txt='['; end
|
|
223
|
+
end
|
|
224
|
+
isoct=jsonopt('IsOctave',0,varargin{:});
|
|
225
|
+
for e=1:len
|
|
226
|
+
val=item(e,:);
|
|
227
|
+
if(len==1)
|
|
228
|
+
obj=['' S_(checkname(name,varargin{:})) '' '',S_(val),''];
|
|
229
|
+
if(isempty(name)) obj=['',S_(val),'']; end
|
|
230
|
+
txt=[txt,'',obj];
|
|
231
|
+
else
|
|
232
|
+
txt=[txt,'',['',S_(val),'']];
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
if(len>1) txt=[txt ']']; end
|
|
236
|
+
|
|
237
|
+
%%-------------------------------------------------------------------------
|
|
238
|
+
function txt=mat2ubjson(name,item,level,varargin)
|
|
239
|
+
if(~isnumeric(item) && ~islogical(item))
|
|
240
|
+
error('input is not an array');
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
|
|
244
|
+
isempty(item) || jsonopt('ArrayToStruct',0,varargin{:}))
|
|
245
|
+
cid=I_(uint32(max(size(item))));
|
|
246
|
+
if(isempty(name))
|
|
247
|
+
txt=['{' S_('_ArrayType_'),S_(class(item)),S_('_ArraySize_'),I_a(size(item),cid(1)) ];
|
|
248
|
+
else
|
|
249
|
+
if(isempty(item))
|
|
250
|
+
txt=[S_(checkname(name,varargin{:})),'Z'];
|
|
251
|
+
return;
|
|
252
|
+
else
|
|
253
|
+
txt=[S_(checkname(name,varargin{:})),'{',S_('_ArrayType_'),S_(class(item)),S_('_ArraySize_'),I_a(size(item),cid(1))];
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
else
|
|
257
|
+
if(isempty(name))
|
|
258
|
+
txt=matdata2ubjson(item,level+1,varargin{:});
|
|
259
|
+
else
|
|
260
|
+
if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1)
|
|
261
|
+
numtxt=regexprep(regexprep(matdata2ubjson(item,level+1,varargin{:}),'^\[',''),']','');
|
|
262
|
+
txt=[S_(checkname(name,varargin{:})) numtxt];
|
|
263
|
+
else
|
|
264
|
+
txt=[S_(checkname(name,varargin{:})),matdata2ubjson(item,level+1,varargin{:})];
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
return;
|
|
268
|
+
end
|
|
269
|
+
if(issparse(item))
|
|
270
|
+
[ix,iy]=find(item);
|
|
271
|
+
data=full(item(find(item)));
|
|
272
|
+
if(~isreal(item))
|
|
273
|
+
data=[real(data(:)),imag(data(:))];
|
|
274
|
+
if(size(item,1)==1)
|
|
275
|
+
% Kludge to have data's 'transposedness' match item's.
|
|
276
|
+
% (Necessary for complex row vector handling below.)
|
|
277
|
+
data=data';
|
|
278
|
+
end
|
|
279
|
+
txt=[txt,S_('_ArrayIsComplex_'),'T'];
|
|
280
|
+
end
|
|
281
|
+
txt=[txt,S_('_ArrayIsSparse_'),'T'];
|
|
282
|
+
if(size(item,1)==1)
|
|
283
|
+
% Row vector, store only column indices.
|
|
284
|
+
txt=[txt,S_('_ArrayData_'),...
|
|
285
|
+
matdata2ubjson([iy(:),data'],level+2,varargin{:})];
|
|
286
|
+
elseif(size(item,2)==1)
|
|
287
|
+
% Column vector, store only row indices.
|
|
288
|
+
txt=[txt,S_('_ArrayData_'),...
|
|
289
|
+
matdata2ubjson([ix,data],level+2,varargin{:})];
|
|
290
|
+
else
|
|
291
|
+
% General case, store row and column indices.
|
|
292
|
+
txt=[txt,S_('_ArrayData_'),...
|
|
293
|
+
matdata2ubjson([ix,iy,data],level+2,varargin{:})];
|
|
294
|
+
end
|
|
295
|
+
else
|
|
296
|
+
if(isreal(item))
|
|
297
|
+
txt=[txt,S_('_ArrayData_'),...
|
|
298
|
+
matdata2ubjson(item(:)',level+2,varargin{:})];
|
|
299
|
+
else
|
|
300
|
+
txt=[txt,S_('_ArrayIsComplex_'),'T'];
|
|
301
|
+
txt=[txt,S_('_ArrayData_'),...
|
|
302
|
+
matdata2ubjson([real(item(:)) imag(item(:))],level+2,varargin{:})];
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
txt=[txt,'}'];
|
|
306
|
+
|
|
307
|
+
%%-------------------------------------------------------------------------
|
|
308
|
+
function txt=matdata2ubjson(mat,level,varargin)
|
|
309
|
+
if(isempty(mat))
|
|
310
|
+
txt='Z';
|
|
311
|
+
return;
|
|
312
|
+
end
|
|
313
|
+
if(size(mat,1)==1)
|
|
314
|
+
level=level-1;
|
|
315
|
+
end
|
|
316
|
+
type='';
|
|
317
|
+
hasnegtive=(mat<0);
|
|
318
|
+
if(isa(mat,'integer') || isinteger(mat) || (isfloat(mat) && all(mod(mat(:),1) == 0)))
|
|
319
|
+
if(isempty(hasnegtive))
|
|
320
|
+
if(max(mat(:))<=2^8)
|
|
321
|
+
type='U';
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
if(isempty(type))
|
|
325
|
+
% todo - need to consider negative ones separately
|
|
326
|
+
id= histc(abs(max(mat(:))),[0 2^7 2^15 2^31 2^63]);
|
|
327
|
+
if(isempty(find(id)))
|
|
328
|
+
error('high-precision data is not yet supported');
|
|
329
|
+
end
|
|
330
|
+
key='iIlL';
|
|
331
|
+
type=key(find(id));
|
|
332
|
+
end
|
|
333
|
+
txt=[I_a(mat(:),type,size(mat))];
|
|
334
|
+
elseif(islogical(mat))
|
|
335
|
+
logicalval='FT';
|
|
336
|
+
if(numel(mat)==1)
|
|
337
|
+
txt=logicalval(mat+1);
|
|
338
|
+
else
|
|
339
|
+
txt=['[$U#' I_a(size(mat),'l') typecast(swapbytes(uint8(mat(:)')),'uint8')];
|
|
340
|
+
end
|
|
341
|
+
else
|
|
342
|
+
if(numel(mat)==1)
|
|
343
|
+
txt=['[' D_(mat) ']'];
|
|
344
|
+
else
|
|
345
|
+
txt=D_a(mat(:),'D',size(mat));
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
%txt=regexprep(mat2str(mat),'\s+',',');
|
|
350
|
+
%txt=regexprep(txt,';',sprintf('],['));
|
|
351
|
+
% if(nargin>=2 && size(mat,1)>1)
|
|
352
|
+
% txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']);
|
|
353
|
+
% end
|
|
354
|
+
if(any(isinf(mat(:))))
|
|
355
|
+
txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:}));
|
|
356
|
+
end
|
|
357
|
+
if(any(isnan(mat(:))))
|
|
358
|
+
txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:}));
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
%%-------------------------------------------------------------------------
|
|
362
|
+
function newname=checkname(name,varargin)
|
|
363
|
+
isunpack=jsonopt('UnpackHex',1,varargin{:});
|
|
364
|
+
newname=name;
|
|
365
|
+
if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
|
|
366
|
+
return
|
|
367
|
+
end
|
|
368
|
+
if(isunpack)
|
|
369
|
+
isoct=jsonopt('IsOctave',0,varargin{:});
|
|
370
|
+
if(~isoct)
|
|
371
|
+
newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}');
|
|
372
|
+
else
|
|
373
|
+
pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start');
|
|
374
|
+
pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end');
|
|
375
|
+
if(isempty(pos)) return; end
|
|
376
|
+
str0=name;
|
|
377
|
+
pos0=[0 pend(:)' length(name)];
|
|
378
|
+
newname='';
|
|
379
|
+
for i=1:length(pos)
|
|
380
|
+
newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))];
|
|
381
|
+
end
|
|
382
|
+
if(pos(end)~=length(name))
|
|
383
|
+
newname=[newname str0(pos0(end-1)+1:pos0(end))];
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
%%-------------------------------------------------------------------------
|
|
388
|
+
function val=S_(str)
|
|
389
|
+
if(length(str)==1)
|
|
390
|
+
val=['C' str];
|
|
391
|
+
else
|
|
392
|
+
val=['S' I_(int32(length(str))) str];
|
|
393
|
+
end
|
|
394
|
+
%%-------------------------------------------------------------------------
|
|
395
|
+
function val=I_(num)
|
|
396
|
+
if(~isinteger(num))
|
|
397
|
+
error('input is not an integer');
|
|
398
|
+
end
|
|
399
|
+
if(num>=0 && num<255)
|
|
400
|
+
val=['U' data2byte(swapbytes(cast(num,'uint8')),'uint8')];
|
|
401
|
+
return;
|
|
402
|
+
end
|
|
403
|
+
key='iIlL';
|
|
404
|
+
cid={'int8','int16','int32','int64'};
|
|
405
|
+
for i=1:4
|
|
406
|
+
if((num>0 && num<2^(i*8-1)) || (num<0 && num>=-2^(i*8-1)))
|
|
407
|
+
val=[key(i) data2byte(swapbytes(cast(num,cid{i})),'uint8')];
|
|
408
|
+
return;
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
error('unsupported integer');
|
|
412
|
+
|
|
413
|
+
%%-------------------------------------------------------------------------
|
|
414
|
+
function val=D_(num)
|
|
415
|
+
if(~isfloat(num))
|
|
416
|
+
error('input is not a float');
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
if(isa(num,'single'))
|
|
420
|
+
val=['d' data2byte(num,'uint8')];
|
|
421
|
+
else
|
|
422
|
+
val=['D' data2byte(num,'uint8')];
|
|
423
|
+
end
|
|
424
|
+
%%-------------------------------------------------------------------------
|
|
425
|
+
function data=I_a(num,type,dim,format)
|
|
426
|
+
id=find(ismember('iUIlL',type));
|
|
427
|
+
|
|
428
|
+
if(id==0)
|
|
429
|
+
error('unsupported integer array');
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
% based on UBJSON specs, all integer types are stored in big endian format
|
|
433
|
+
|
|
434
|
+
if(id==1)
|
|
435
|
+
data=data2byte(swapbytes(int8(num)),'uint8');
|
|
436
|
+
blen=1;
|
|
437
|
+
elseif(id==2)
|
|
438
|
+
data=data2byte(swapbytes(uint8(num)),'uint8');
|
|
439
|
+
blen=1;
|
|
440
|
+
elseif(id==3)
|
|
441
|
+
data=data2byte(swapbytes(int16(num)),'uint8');
|
|
442
|
+
blen=2;
|
|
443
|
+
elseif(id==4)
|
|
444
|
+
data=data2byte(swapbytes(int32(num)),'uint8');
|
|
445
|
+
blen=4;
|
|
446
|
+
elseif(id==5)
|
|
447
|
+
data=data2byte(swapbytes(int64(num)),'uint8');
|
|
448
|
+
blen=8;
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2))
|
|
452
|
+
format='opt';
|
|
453
|
+
end
|
|
454
|
+
if((nargin<4 || strcmp(format,'opt')) && numel(num)>1)
|
|
455
|
+
if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2))))
|
|
456
|
+
cid=I_(uint32(max(dim)));
|
|
457
|
+
data=['$' type '#' I_a(dim,cid(1)) data(:)'];
|
|
458
|
+
else
|
|
459
|
+
data=['$' type '#' I_(int32(numel(data)/blen)) data(:)'];
|
|
460
|
+
end
|
|
461
|
+
data=['[' data(:)'];
|
|
462
|
+
else
|
|
463
|
+
data=reshape(data,blen,numel(data)/blen);
|
|
464
|
+
data(2:blen+1,:)=data;
|
|
465
|
+
data(1,:)=type;
|
|
466
|
+
data=data(:)';
|
|
467
|
+
data=['[' data(:)' ']'];
|
|
468
|
+
end
|
|
469
|
+
%%-------------------------------------------------------------------------
|
|
470
|
+
function data=D_a(num,type,dim,format)
|
|
471
|
+
id=find(ismember('dD',type));
|
|
472
|
+
|
|
473
|
+
if(id==0)
|
|
474
|
+
error('unsupported float array');
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
if(id==1)
|
|
478
|
+
data=data2byte(single(num),'uint8');
|
|
479
|
+
elseif(id==2)
|
|
480
|
+
data=data2byte(double(num),'uint8');
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2))
|
|
484
|
+
format='opt';
|
|
485
|
+
end
|
|
486
|
+
if((nargin<4 || strcmp(format,'opt')) && numel(num)>1)
|
|
487
|
+
if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2))))
|
|
488
|
+
cid=I_(uint32(max(dim)));
|
|
489
|
+
data=['$' type '#' I_a(dim,cid(1)) data(:)'];
|
|
490
|
+
else
|
|
491
|
+
data=['$' type '#' I_(int32(numel(data)/(id*4))) data(:)'];
|
|
492
|
+
end
|
|
493
|
+
data=['[' data];
|
|
494
|
+
else
|
|
495
|
+
data=reshape(data,(id*4),length(data)/(id*4));
|
|
496
|
+
data(2:(id*4+1),:)=data;
|
|
497
|
+
data(1,:)=type;
|
|
498
|
+
data=data(:)';
|
|
499
|
+
data=['[' data(:)' ']'];
|
|
500
|
+
end
|
|
501
|
+
%%-------------------------------------------------------------------------
|
|
502
|
+
function bytes=data2byte(varargin)
|
|
503
|
+
bytes=typecast(varargin{:});
|
|
504
|
+
bytes=bytes(:)';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function opt=varargin2struct(varargin)
|
|
2
|
+
%
|
|
3
|
+
% opt=varargin2struct('param1',value1,'param2',value2,...)
|
|
4
|
+
% or
|
|
5
|
+
% opt=varargin2struct(...,optstruct,...)
|
|
6
|
+
%
|
|
7
|
+
% convert a series of input parameters into a structure
|
|
8
|
+
%
|
|
9
|
+
% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
|
|
10
|
+
% date: 2012/12/22
|
|
11
|
+
%
|
|
12
|
+
% input:
|
|
13
|
+
% 'param', value: the input parameters should be pairs of a string and a value
|
|
14
|
+
% optstruct: if a parameter is a struct, the fields will be merged to the output struct
|
|
15
|
+
%
|
|
16
|
+
% output:
|
|
17
|
+
% opt: a struct where opt.param1=value1, opt.param2=value2 ...
|
|
18
|
+
%
|
|
19
|
+
% license:
|
|
20
|
+
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
|
|
21
|
+
%
|
|
22
|
+
% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
|
|
23
|
+
%
|
|
24
|
+
|
|
25
|
+
len=length(varargin);
|
|
26
|
+
opt=struct;
|
|
27
|
+
if(len==0) return; end
|
|
28
|
+
i=1;
|
|
29
|
+
while(i<=len)
|
|
30
|
+
if(isstruct(varargin{i}))
|
|
31
|
+
opt=mergestruct(opt,varargin{i});
|
|
32
|
+
elseif(ischar(varargin{i}) && i<len)
|
|
33
|
+
opt=setfield(opt,varargin{i},varargin{i+1});
|
|
34
|
+
i=i+1;
|
|
35
|
+
else
|
|
36
|
+
error('input must be in the form of ...,''name'',value,... pairs or structs');
|
|
37
|
+
end
|
|
38
|
+
i=i+1;
|
|
39
|
+
end
|
|
40
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function data_prob = sample_prob_final(ppg_prob, imu_label, fs)
|
|
2
|
+
% K.I. Veldkamp, PhD student AI4P, 29-02-24
|
|
3
|
+
|
|
4
|
+
%%--Assign probability to every individual data point!--%%
|
|
5
|
+
% Inputs:
|
|
6
|
+
% - ppg_prob
|
|
7
|
+
% - imu label
|
|
8
|
+
% Output:
|
|
9
|
+
% - data_prob: containing of an array with for every sample a probability.
|
|
10
|
+
% This can be mapped to the samples of the synced PPG-IMU
|
|
11
|
+
|
|
12
|
+
if ~exist('imu_label', 'var')
|
|
13
|
+
imu_label = ones(length(ppg_prob)); % Function also works without having imu_label --> then based on ppg_prob alone!
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
epoch_length = 6; % in seconds
|
|
17
|
+
overlap = 5; % in seconds
|
|
18
|
+
|
|
19
|
+
% Number of samples in epoch
|
|
20
|
+
samples_per_epoch = epoch_length * fs;
|
|
21
|
+
|
|
22
|
+
% Calculate number of samples to shift for each epoch
|
|
23
|
+
samples_shift = (epoch_length - overlap) * fs;
|
|
24
|
+
n_samples = (length(ppg_prob) + overlap) * fs;
|
|
25
|
+
data_prob = zeros(n_samples,1);
|
|
26
|
+
|
|
27
|
+
prob_array = ppg_prob;
|
|
28
|
+
imu_array = imu_label;
|
|
29
|
+
|
|
30
|
+
for i = 1:n_samples
|
|
31
|
+
start_idx = ceil((i-(samples_per_epoch-samples_shift))/fs); %start_idx for the non starting and ending epochs is equal to ceil((data idx - n_overlap)/fs)
|
|
32
|
+
end_idx = ceil(i/fs);
|
|
33
|
+
|
|
34
|
+
%%-----Correct for first and last 6s epochs (those have less than 6 epochs to calculate labels and prob)-----%%
|
|
35
|
+
if start_idx < 1
|
|
36
|
+
start_idx = 1; % The first 5 epochs indices start at 1
|
|
37
|
+
elseif end_idx>length(prob_array)
|
|
38
|
+
end_idx = length(prob_array); % The last 5 epochs indices end at the last label
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
prob = prob_array(start_idx:end_idx);
|
|
42
|
+
label_imu = imu_array(start_idx:end_idx);
|
|
43
|
+
data_prob(i) = mean(prob);
|
|
44
|
+
data_label_imu(i) = int8(mean(label_imu) >= 0.5); % Perform majority voting
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
data_prob(data_label_imu==0) = 0; % Set prob to zero if majority voting of IMU is 0
|
|
48
|
+
|
|
49
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
function [segment_ppg_total, segment_imu_total] = synchronization(ppg_meta, imu_meta)
|
|
2
|
+
% K.I. Veldkamp, PhD student AI4P, 29-02-24
|
|
3
|
+
% This function checks data availability between PPG and IMU and returns
|
|
4
|
+
% the synchronized indices
|
|
5
|
+
|
|
6
|
+
% Convert start and end times to datetime objects
|
|
7
|
+
ppg_start_time = datetime({ppg_meta.start_iso8601}', 'InputFormat', 'dd-MMM-yyyy HH:mm:ss Z', 'Format', 'yyyy-MM-dd''T''HH:mm:ss', 'TimeZone', 'UTC');
|
|
8
|
+
imu_start_time = datetime({imu_meta.start_iso8601}', 'InputFormat', 'dd-MMM-yyyy HH:mm:ss Z', 'Format', 'yyyy-MM-dd''T''HH:mm:ss', 'TimeZone', 'UTC');
|
|
9
|
+
ppg_end_time = datetime({ppg_meta.end_iso8601}', 'InputFormat', 'dd-MMM-yyyy HH:mm:ss Z', 'Format', 'yyyy-MM-dd''T''HH:mm:ss', 'TimeZone', 'UTC');
|
|
10
|
+
imu_end_time = datetime({imu_meta.end_iso8601}', 'InputFormat', 'dd-MMM-yyyy HH:mm:ss Z', 'Format', 'yyyy-MM-dd''T''HH:mm:ss', 'TimeZone', 'UTC');
|
|
11
|
+
|
|
12
|
+
% Create a time vector covering the entire range
|
|
13
|
+
time_vector_total = datetime(min([imu_start_time; ppg_start_time]), 'Format', 'yyyy-MM-dd HH:mm:ss'):seconds(1):datetime(max([imu_end_time; ppg_end_time]), 'Format', 'yyyy-MM-dd HH:mm:ss');
|
|
14
|
+
|
|
15
|
+
% Initialize variables
|
|
16
|
+
data_presence_ppg = zeros(size(time_vector_total));
|
|
17
|
+
data_presence_ppg_idx = zeros(size(time_vector_total));
|
|
18
|
+
data_presence_imu = zeros(size(time_vector_total));
|
|
19
|
+
data_presence_imu_idx = zeros(size(time_vector_total));
|
|
20
|
+
|
|
21
|
+
% Mark the segments of PPG data with 1
|
|
22
|
+
for i = 1:length(ppg_start_time)
|
|
23
|
+
indices = time_vector_total >= ppg_start_time(i) & time_vector_total < ppg_end_time(i);
|
|
24
|
+
data_presence_ppg(indices) = 1;
|
|
25
|
+
data_presence_ppg_idx(indices) = i;
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
% Mark the segments of IMU data with 1
|
|
29
|
+
for i = 1:length(imu_start_time)
|
|
30
|
+
indices = time_vector_total >= imu_start_time(i) & time_vector_total < imu_end_time(i);
|
|
31
|
+
data_presence_imu(indices) = 1;
|
|
32
|
+
data_presence_imu_idx(indices) = i;
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
% Find the indices where both PPG and IMU data are present
|
|
36
|
+
corr_indices = find(data_presence_ppg == 1 & data_presence_imu == 1);
|
|
37
|
+
|
|
38
|
+
% Find the start and end indices of each segment
|
|
39
|
+
corr_start_end = [];
|
|
40
|
+
start_idx = corr_indices(1);
|
|
41
|
+
for i = 2:length(corr_indices)
|
|
42
|
+
if corr_indices(i) - corr_indices(i-1) > 1
|
|
43
|
+
end_idx = corr_indices(i-1);
|
|
44
|
+
corr_start_end = [corr_start_end; start_idx, end_idx];
|
|
45
|
+
start_idx = corr_indices(i);
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
% Add the last segment
|
|
50
|
+
if ~isempty(corr_indices)
|
|
51
|
+
corr_start_end = [corr_start_end; start_idx, corr_indices(end)];
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
% Extract the synchronized indices for each segment
|
|
55
|
+
segment_ppg_total = [];
|
|
56
|
+
segment_imu_total = [];
|
|
57
|
+
for i = 1:size(corr_start_end,1)
|
|
58
|
+
start_idx = corr_start_end(i,1);
|
|
59
|
+
end_idx = corr_start_end(i,2);
|
|
60
|
+
segment_ppg = unique(data_presence_ppg_idx(start_idx:end_idx))';
|
|
61
|
+
segment_imu = unique(data_presence_imu_idx(start_idx:end_idx))';
|
|
62
|
+
if length(segment_ppg) > 1 & length(segment_imu) == 1
|
|
63
|
+
segment_ppg_total = [segment_ppg_total; segment_ppg];
|
|
64
|
+
segment_imu_total = [segment_imu_total; segment_imu*ones(length(segment_ppg),1)];
|
|
65
|
+
elseif length(segment_ppg) == 1 & length(segment_imu) > 1
|
|
66
|
+
segment_ppg_total = [segment_ppg_total; segment_ppg*ones(length(segment_imu),1)];
|
|
67
|
+
segment_imu_total = [segment_imu_total; segment_imu];
|
|
68
|
+
elseif length(segment_ppg) == length(segment_imu)
|
|
69
|
+
segment_ppg_total = [segment_ppg_total; segment_ppg];
|
|
70
|
+
segment_imu_total = [segment_imu_total; segment_imu];
|
|
71
|
+
else
|
|
72
|
+
continue
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function tsdf = tsdf_scan_meta(tsdf_data_full_path)
|
|
2
|
+
% K.I. Veldkamp, PhD student AI4P, 29-02-24
|
|
3
|
+
% For each given TSDB directory, transcribe TSDF metadata contents to SQL
|
|
4
|
+
% table --> function specific for toolbox data structure
|
|
5
|
+
tsdf = [];
|
|
6
|
+
irow = 1;
|
|
7
|
+
|
|
8
|
+
meta_list = dir(fullfile(tsdf_data_full_path, '*_meta.json'));
|
|
9
|
+
meta_filenames = {meta_list.name};
|
|
10
|
+
|
|
11
|
+
jsonobj = {};
|
|
12
|
+
for n = 1:length(meta_filenames)
|
|
13
|
+
tsdb_meta_fullpath = fullfile(tsdf_data_full_path, meta_filenames{n});
|
|
14
|
+
jsonstr = fileread(tsdb_meta_fullpath);
|
|
15
|
+
jsonobj{n} = loadjson(jsonstr);
|
|
16
|
+
tsdf(irow).tsdf_meta_fullpath = tsdb_meta_fullpath;
|
|
17
|
+
tsdf(irow).subject_id = jsonobj{n}.subject_id;
|
|
18
|
+
tsdf(irow).start_iso8601 = jsonobj{n}.start_iso8601;
|
|
19
|
+
tsdf(irow).end_iso8601 = jsonobj{n}.end_iso8601;
|
|
20
|
+
irow = irow + 1;
|
|
21
|
+
end
|
|
22
|
+
|