-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrainingSetBuilder_IvUvP.m
More file actions
65 lines (50 loc) · 2.04 KB
/
Copy pathtrainingSetBuilder_IvUvP.m
File metadata and controls
65 lines (50 loc) · 2.04 KB
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
source_folder = 'restructured_dataset';
subfolders = {'dati_buoni'; 'dati_cattivi'};
target_folder = 'features_dataset';
orientations = ['H', 'V'];
dynamicCases = ['I', 'U', 'P'];
plotGraphs = true;
root = pwd;
for subfolder_idx = 1 : size(subfolders, 1)
subfolder = subfolders(subfolder_idx);
curr_source_folder = fullfile(root, source_folder, subfolder);
cd(curr_source_folder{1});
load('data.mat')
for orientation = orientations
table = struct();
table.power_std = zeros(30,1);
table.power_mean = zeros(30,1);
table.power_median = zeros(30,1);
table.phase_std = zeros(30,1);
table.phase_mean = zeros(30,1);
table.phase_median = zeros(30,1);
table.out = zeros(30,3);
%Dynamic case
baseIdx = 1;
for dynamicCase = dynamicCases
powerFeatures = extractFeatures(data.dynamic.(orientation).(dynamicCase).power);
phaseFeatures = extractFeatures(data.dynamic.(orientation).(dynamicCase).phase);
idx = baseIdx : baseIdx + 9;
table.power_std(idx) = powerFeatures.std;
table.power_mean(idx) = powerFeatures.mean;
table.power_median(idx) = powerFeatures.median;
table.phase_std(idx) = phaseFeatures.std;
table.phase_mean(idx) = phaseFeatures.mean;
table.phase_median(idx) = phaseFeatures.median;
val = [-1,-1,-1];
if dynamicCase == 'I'
val = [1,0,0];
elseif dynamicCase == 'U'
val = [0,1,0];
elseif dynamicCase == 'P'
val = [0,0,1];
end
table.out(idx,:) = ones(10,3).* val;
baseIdx = baseIdx + 10;
end
end
dest_folder = fullfile(root, target_folder, subfolder);
mkdir(dest_folder{1});
save(fullfile(dest_folder{1}, ['trainingSet_IvUvP_', orientation, '.mat']), 'table');
end
cd(root);