-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalize.m
215 lines (197 loc) · 6.24 KB
/
analize.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
% Jorge Rey Martinez & María Moserrat Soriano 2021 version 2.0
% VVOR AND VORS ANALYSIS
% Inputs
% t = time array
% e = eye velocity array
% h = head velocity array
% s = Boolean, true if register is supresed VVOR false if VVOR
function analize(t,e,h,s)
%Draw figure considering screen size
scrsz = get(groot,'ScreenSize');
if s == 1
figure1 = figure('Name','VORS ANALYSIS','NumberTitle','off','Position',[5 50 scrsz(3)/1.01 scrsz(4)/1.2]);
else
figure1 = figure('Name','VVOR ANALYSIS','NumberTitle','off','Position',[5 50 scrsz(3)/1.01 scrsz(4)/1.2]);
end
figure(figure1);
%%%%%% Numerical data CALCULATIONS section %%%%%%%%%%%%
% Get Desacade eye data
if s == 1
desacE = medfilt1(e,35);
else
desacE = medfilt1(e,30);
end
%get positive/neagtive data
limit = size(t);
posH = [];
posE = [];
negH = [];
negE = [];
for n = 1:limit
if h(n) > 0
posH = vertcat(posH,h(n));
if desacE(n) > 0
posE = vertcat(posE,desacE(n));
else
posE = vertcat(posE,0);
end
end
if h(n) < 0
negH = vertcat(negH,h(n));
if desacE(n) < 0
negE = vertcat(negE,desacE(n));
else
negE = vertcat(negE,0);
end
end
end
prePosPeakE = mean(findpeaks(posE));
preNegPeakE = mean(findpeaks(abs(negE)));
if prePosPeakE > preNegPeakE
peakE = prePosPeakE;
peakH = mean(findpeaks(posH));
else
peakE = -preNegPeakE;
peakH = -mean(findpeaks(abs(negH)));
end
%AUC Gain
aucPosEye = trapz(posE);
aucPosHead = trapz(posH);
aucNegEye = trapz(negE);
aucNegHead = trapz(negH);
gainPos = (aucPosEye/aucPosHead);
gainNeg = (aucNegEye/aucNegHead);
%velGainPos = mean(findpeaks(posE))/mean(findpeaks(posH));
%velGainNeg = mean(findpeaks(abs(negE)))/mean(findpeaks(abs(negH)));
%Eye Head Regression Gain
negB = negH\negE;
posB = posH\posE;
calcNegE = negB*negH;
calcPosE = posB*posH;
%%%%% PLOTS SECTION %%%%%
%RAW plot
subplot(3,2,1)
plot(t,h,'b',t,e,'r','LineWidth',1.25)
title('Test Output - RAW data')
xlabel('Time in secs')
ylabel('Velocity in deg/sec')
ylim([-400 +400])
legend ('Head velocity','Eye velocity')
%Desaccaded plot
subplot(3,2,2)
plot(t,h,'b',t,desacE,'r','LineWidth',1.25)
AUCTitle = strcat('Test Output - Desaccaded data - ',' LEFT GAIN: ',num2str(gainPos),' -RIGHT GAIN: ',num2str(gainNeg));
title(AUCTitle)
xlabel('Time in secs')
ylabel('Velocity in deg/sec')
ylim([-400 +400])
legend ('Head velocity','Eye velocity')
% %Positive-Negative plots
% subplot(3,2,5)
% plot([posH,posE],'LineWidth',1.25)
% title('Positive vs Negative data - Desaccaded data')
% xlabel('Time in samples')
% ylabel('Velocity in deg/sec')
% hold on
% plot([negH,negE],'LineWidth',1.25)
% hold off
% legend ('Head velocity','Eye velocity','Head velocity','Eye velocity')
%XY ploy & regresion line
subplot(3,2,6)
hold on
if isOctave
scatter(negH,negE,'c','.');
scatter(posH,posE,'b','.');
else
scatter(negH,negE,'.b');
scatter(posH,posE,'.','MarkerEdgeColor',[0 .7 .7]);
end
XYTitle = strcat('Head vs Eye plot - Desaccaded data',' LEFT GAIN: ',num2str(posB),' -RIGHT GAIN: ',num2str(negB));
title(XYTitle)
xlabel('Head Velocity in deg/sec')
ylabel('Eye Velocity in deg/sec')
plot(negH,calcNegE,posH,calcPosE,'LineWidth',5)
if s == 1
plot(negH,negH,'r',posH,posH,'r','LineWidth',1.5)
legend ('Negative data','Positive data','Negative regresion','Positive regresion','No Suppression line','Location','northwest')
else
plot(negH,negH,'g',posH,posH,'g','LineWidth',1.5)
legend ('Negative data','Positive data','Negative regresion','Positive regresion','Normality line','Location','northwest')
end
hold off
%axis square
%Fourier plots
subplot(3,2,3)
[fHead,P1Head] = fourier(h);
[fEye,P1Eye] = fourier(e);
hold on
stem(fHead,P1Head,'b');
title('Single-Side Amplitude Spectrum of Head and Eye - RAW data')
xlabel('f (Hz)')
ylabel('|P1(f)|')
xlim([0 5])
stem(fEye,P1Eye,'r');
legend('Head','Eye')
hold off
%Desacade Fourier
subplot(3,2,4)
[fHead,P1Head] = fourier(h);
[fEye,P1Eye] = fourier(desacE);
hold on
stem(fHead,P1Head,'b');
title('Single-Side Amplitude Spectrum of Head and Eye - Desaccaded data')
xlabel('f (Hz)')
ylabel('|P1(f)|')
xlim([0 5])
stem(fEye,P1Eye,'r');
legend('Head','Eye')
hold off
%Analysis of head oscillations variability:
distanciaPicos = 60;
lHeadPeaks = findpeaks(posH,'MinPeakDistance',distanciaPicos);
rHeadPeaks = findpeaks(abs(negH),'MinPeakDistance',distanciaPicos);
velocityTreshold = 25;
lHeadInvalids = lHeadPeaks<velocityTreshold;
rHeadInvalids = rHeadPeaks<velocityTreshold;
lHeadPeaks(lHeadInvalids) = [];
rHeadPeaks(rHeadInvalids) = [];
[lPeakN, ~] = size(lHeadPeaks);
[rPeakN, ~] = size(rHeadPeaks);
[lPR,rPR,saccadePositions] = prScore(t,e,h,s);
%PR PLOT only available in VVOR tests
if s ~= 1
subplot(3,2,5)
plot(t,h,'b',t,e,'r','LineWidth',1.5)
prTitle = strcat('Saccade Recognition & PR Plot: ', ' Left PR:',num2str(lPR),', Right PR: ',num2str(rPR));
title(prTitle)
xlabel('Time in samples')
ylabel('Velocity in deg/sec')
ylim([-400 +400])
%add saccade detection to plot
[sP,~,~] = find(t==saccadePositions);
hold on
plot(t(sP),e(sP),'ko')
hold off
legend ('Head velocity','Eye velocity','Detected Saccade')
end
%%%%%%%%%Output analysis results to text%%%%%%%%%%%%
resultG = strcat('GAIN RESULTS: ',' Left(area): ',num2str(gainPos),' Right(area): ',num2str(gainNeg),' || Left(slope): ',num2str(posB),' Right(slope): ',num2str(negB),' || Head Max(º/s): ', num2str(peakH),' Eye Max: ',num2str(peakE));
if s~= 1
resultPR = strcat('PR RESULTS: ',' Left PR Score: ',num2str(lPR),' Right PR score: ',num2str(rPR),' || Left/Right peaks > 25º/s: ',num2str(lPeakN),'/',num2str(rPeakN),' || Left/Right velocity SD of peaks: ',num2str(std(lHeadPeaks)),'/',num2str(std(rHeadPeaks)));
else
resultPR = 'PR score is not available for VORS - supression - testing';
end
mTextBoxGain = uicontrol(figure1,'style','text');
mTextBoxPR = uicontrol(figure1,'style','text');
set(mTextBoxGain,'String',resultG);
set(mTextBoxGain,'FontSize',10);
set(mTextBoxGain,'HorizontalAlignment','left');
set(mTextBoxGain,'Position',[20 20 1300 25]);
set(mTextBoxPR,'String',resultPR);
set(mTextBoxPR,'FontSize',10);
set(mTextBoxPR,'HorizontalAlignment','left');
set(mTextBoxPR,'Position',[20 1 1600 25]);
set(figure1,'MenuBar','figure');
disp(resultG);
disp(resultPR);
end