-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalyze.m
78 lines (66 loc) · 1.99 KB
/
analyze.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
75
76
77
78
% analyze runs an analysis on the data
function [values, participants, measures] = analyze(dataType, nanMethod, plotType, alg)
if nargin < 1
dataType = 'all';
end
if nargin < 2
nanMethod = 'delete';
end
shouldDeleteNaN = strcmp(nanMethod, 'delete');
addpath import;
if strcmp(dataType, 'all')
[cData, mData, participants, measures] = importTwo(pathFor('leg'), pathFor('arm'), shouldDeleteNaN);
if shouldDeleteNaN
[participants, cData, mData] = deleteNaN(participants, cData, mData);
end
[values, measures] = combineTwo(cData, mData, measures);
clear cData, mData;
else
[values, participants, measures] = mefimport(pathFor(dataType), shouldDeleteNaN);
end
values = fillWithMethod(values, nanMethod);
if nargin < 4
alg = 'svd';
end
% Only plot if a type was provided
if nargin >= 3
figure;
[coeff, score] = pca(values, 'VariableWeights', 'variance', 'algorithm', alg);
addpath analyze;
switch plotType
case 'dist'
% Print number of STD from mean
stdDist(length(measures), score, participants, true);
case 'biplot'
bp(coeff, score, measures);
case 'cross'
dataProj = '';
switch dataType
case 'leg'
dataProj = 'arm';
case 'arm'
dataProj = 'leg';
otherwise
disp('ERROR: data type must be ''leg'' or ''arm''.');
end
[valuesProj, participantsProj] = mefimport(pathFor(dataProj), shouldDeleteNaN);
values = fillWithMethod(valuesProj, nanMethod);
crosswiseBP(values, valuesProj, measures, participants, participantsProj, alg);
case 'line'
dataProj = '';
switch dataType
case 'leg'
dataProj = 'arm';
case 'arm'
dataProj = 'leg';
otherwise
disp('ERROR: data type must be ''leg'' or ''arm''.');
end
[valuesProj, participantsProj] = mefimport(pathFor(dataProj), shouldDeleteNaN);
values = fillWithMethod(valuesProj, nanMethod);
lineCross(values, valuesProj, participants, participantsProj, 1, alg);
end
rmpath analyze;
end
rmpath import;
end