-
Notifications
You must be signed in to change notification settings - Fork 1
/
runRMS_acc.m
74 lines (55 loc) · 2.28 KB
/
runRMS_acc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
p = mfilename('fullpath');
addpath(genpath(fileparts(p)))
[fname path_name] = uigetfile( {'*.txt';'*.dat';'*.*'}, ...
'Choose file with acceleration sensor aquisition',...
'MultiSelect', 'on');
if iscell(fname) && length( fname ) > 1
fname = sort( fname );
else
dummy = fname;
clear fname;
fname{1} = dummy;
end
for k = 1:length( fname )
accfiles(k).name = fname{k};
end
rootdir = path_name;
% pegar par�metros
prompt = {'Tempo de bloco de repouso:','Tempo de bloco ativa��o:','N�mero de repeti��o dos blocos:', 'Diret�rio de output:','Plotar gr�ficos(s/n):'};
dlg_title = 'Input';
num_lines = 1;
def = {'20','20', '12', '', 's'};
N = 80;
answer = inputdlg(prompt,dlg_title,[num_lines, length(dlg_title)+N],def, 'on');
dur_rest_seg = str2num( answer{1} );
dur_activation_seg = str2num( answer{2} );
repetitions = str2num( answer{3} );
outdir = answer{4};
if strcmp( answer{5}, 'n' )
plotar_graficos = false ;
else
plotar_graficos = true ;
end
% preprocessamento no analyzer tem que estar com esse sampling rate
fs_acc = 100; % taxa de amostragem
[signal R R_bloco] = RMS_accelerometro( accfiles, rootdir, fs_acc, dur_rest_seg, dur_activation_seg, repetitions, plotar_graficos );
R_runs = summarize_run( R_bloco );
xlswrite( fullfile( outdir, ['Accelerometro-' datestr( now, 'yyyymmdd-HHMMSS' )] ), R );
if ~isempty( R_bloco )
xlswrite( fullfile( outdir, ['Accelerometro-blocos-' datestr( now, 'yyyymmdd-HHMMSS' )] ), R_bloco );
end
xlswrite( fullfile( outdir, ['Accelerometro-runs-' datestr( now, 'yyyymmdd-HHMMSS' )] ), R_runs );
calcularRegressor = 0;
if calcularRegressor
win_size = 1;
for k=1:length(accfiles)
signal_resampled{k} = moving_window_average( signal{k}', win_size, fs_acc);
signal_resampled{k} = signal_resampled{k}';
end
signal_convolved = RMS_accelerometro_convolve( accfiles, signal_resampled, 1/win_size );
fs_res = 1/win_size;
result_dir = outdir;
for k=1:length(accfiles)
dlmwrite( fullfile( result_dir, ['vol_' accfiles(k).name(1:end-4) '.txt']), signal_convolved{k}(fs_res : 2*fs_res : end), 'newline', 'PC' );
end
end