-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDAOneSubjectStroke.m
64 lines (52 loc) · 2.32 KB
/
DAOneSubjectStroke.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
function [ stats ] = DAOneSubjectStroke( subject , averagesfolder, lap )
% This calcualtes the deviation area between the average ankle trajectory
% of Active mode with the target of treadmill and Overground each.
parentfolder = SelectFolder(averagesfolder, subject);
%% Gait Templates
TFile = rdir( [parentfolder, strcat( '\*GaitTemplate*.txt' ) ] );
% Importing gait templates:
Temp = importdata(TFile.name, '\t', 3);
P.TargetX = Temp.data(:,8);
P.TargetY = Temp.data(:,9); % get targe x and y gait positions from column 8 and 9 in template data
%% Anklepositions
% Active mode
if nargin <3
Assistive_FileList = rdir( [ parentfolder, '\*_training*.txt' ] );
for i = 1:length(Assistive_FileList)
Ai(i) = readAvgAnklepos( Assistive_FileList(i).name, '', 2 ); %Each Cycle
A.x = mean( [ Ai(i).x ] , 2 );
A.y = mean( [ Ai(i).y ] , 2 );
end
else
A = readAvgAnklepos( parentfolder, ['\*_training', lap, ...
'.txt'], 2);
end
% Post training A
[ Posta ] = readAvgAnklepos( parentfolder, '\*posta*.txt', 2 );
% Post training B
[ Postb ] = readAvgAnklepos( parentfolder, '\*postb*.txt', 2 );
% Post training C
[ Postc ] = readAvgAnklepos( parentfolder, '\*postc*.txt', 2 );
%% Plots and Deviation Areas
% Add figure handle to inputs to function for plots.
[ da_A, ~ , ref ] = calculateDAparams( A.x, A.y, P.TargetX, P.TargetY ); %
[ da_posta, ~, ~ ] = calculateDAparams( Posta.x, Posta.y, ...
P.TargetX, P.TargetY );
[ da_postb, ~, ~ ] = calculateDAparams( Postb.x, Postb.y, ...
P.TargetX, P.TargetY );
[ da_postc, ~, ~ ] = calculateDAparams( Postc.x, Postc.y, ...
P.TargetX, P.TargetY );
%% Calculating Means and Standard Deviations for Deviation Areas
%Deviation Areas
if nargin < 3
stats.A = mean( da_A./ref );
stats.Posta = mean( da_posta./ref );
stats.Postb = mean( da_postb./ref );
stats.Postc = mean( da_postc./ref );
else
stats.A = [ mean( da_A./ref ), std( da_A./ref ) ];
stats.Posta = [ mean( da_posta./ref ), std( da_posta./ref ) ];
stats.Postb = [ mean( da_postb./ref ), std( da_postb./ref ) ];
stats.Postc = [ mean( da_postc./ref ), std( da_postc./ref ) ];
end
end