-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlotTrackError.m
83 lines (68 loc) · 3.5 KB
/
PlotTrackError.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
function TrackError = PlotTrackError(mOrder, Calib, testData)
%PLOTCALIBRATIONPOINTS plots the calibration data for a calibration session
% Input:
% calibPlot: The calibration plot data, specifying the input and output calibration data
% Calib: The calib config structure (see SetCalibParams)
% mOrder: Vector containing indices indicating the order in which to show
%the calibration points, [1 2 3 4 5] to show five calibration points in order or [1 3 5 2 4] to show them in different order.
%
% Output:
% pts: The list of points used for calibration. These could be
% further used for the analysis such as the variance, mean etc.
global EXPWIN
BLACK=[0 0 0];
Lx_delta=[]; Ly_delta=[]; Rx_delta=[]; Ry_delta=[];
%degree symbol
s = sprintf('%c', char(176));
Screen('FillRect',EXPWIN,Calib.bkcolor*255);
Screen('TextSize', EXPWIN , 12);
% figure(1); clf; hold on;
% for j =1:Calib.points.n
% plot(testData.left(j).xy(:,1), testData.left(j).xy(:,2),'*')
% plot(testData.right(j).xy(:,1), testData.right(j).xy(:,2),'r*')
% end
for i = 1:length(Calib.points.x)
%alter the data streams dependent on whether it was from the calibration
%or from a retest
ldat=testData.left(i).xy; rdat=testData.right(i).xy;
calib_pt_x=Calib.screen.width*Calib.points.x(mOrder(i));
calib_pt_y=Calib.screen.height*Calib.points.y(mOrder(i));
reye=[Calib.screen.width*rdat(:,1) Calib.screen.height*rdat(:,2)];
leye=[Calib.screen.width*ldat(:,1) Calib.screen.height*ldat(:,2)];
dotLoc(1) = calib_pt_x - Calib.SmallMark;
dotLoc(2) = calib_pt_y - Calib.SmallMark;
dotLoc(3) = calib_pt_x + Calib.SmallMark;
dotLoc(4) = calib_pt_y + Calib.SmallMark;
for j=1:length(reye)
Screen('DrawText', EXPWIN, 'o',reye(j,1), reye(j,2), [255 0 0]);
end
Rx_delta=reye(:,1)-calib_pt_x;
Ry_delta=reye(:,2)-calib_pt_y;
for j=1:length(leye)
Screen('DrawText', EXPWIN, 'o',leye(j,1), leye(j,2), [0 255 0]);
end
Lx_delta=leye(:,1)-calib_pt_x;
Ly_delta=leye(:,2)-calib_pt_y;
Leye_TrackLoss=sum(ldat(:,1)==-1)/length(ldat);
Reye_TrackLoss=sum(rdat(:,1)==-1)/length(rdat);
%Calculate mean & standard dev. of visual angle error in track signal
Rxy_dist=sqrt(Rx_delta.^2+Ry_delta.^2)*Calib.screen.degperpix;
Lxy_dist=sqrt(Lx_delta.^2+Ly_delta.^2)*Calib.screen.degperpix;
err_stat= sprintf('%0.2f%s +/-%0.2f%s', median( (Rxy_dist+Lxy_dist)/2), s, std( (Rxy_dist+Lxy_dist)/2),s );
Screen('DrawText', EXPWIN, err_stat, calib_pt_x-85, calib_pt_y-70, BLACK );
err_stat= sprintf('L-Loss %0.2f, R-Loss %0.2f', Leye_TrackLoss,Reye_TrackLoss);
Screen('DrawText', EXPWIN, err_stat, calib_pt_x-185, calib_pt_y-40, BLACK );
TrackError(i).Left=Lxy_dist; TrackError(i).Right=Rxy_dist;
TrackError(i).Left_TrackLoss=Leye_TrackLoss;
TrackError(i).Right_TrackLoss=Reye_TrackLoss;
TrackError(i).Left_Validity=testData.left(i).validity;
TrackError(i).Right_Validity=testData.right(i).validity;
TrackError(i).Left_pupil=testData.left(i).pupil;
TrackError(i).Right_pupil=testData.right(i).pupil;
Screen('FillOval',EXPWIN,Calib.fgcolor*255, dotLoc);
end
DrawFormattedText(EXPWIN,'Press space to continue...','Center',...
Calib.screen.height/4, [255 255 255]);
DrawFormattedText(EXPWIN,'Median binocular accuracy (L+R)/2 is shown with +/- std. dev.','Center',Calib.screen.height/3, BLACK);
Screen('Flip', EXPWIN,[]);
end