-
Notifications
You must be signed in to change notification settings - Fork 0
/
CalibratePupil.m
87 lines (71 loc) · 3.22 KB
/
CalibratePupil.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
function [ HW ] = CalibratePupil( HW, plexonServer )
%CALIBRATEPUPIL Summary of this function goes here
% Detailed explanation goes here
LPT_Stimulus_Trigger = 4;
LPT_Stimulus_End = 1;
% Generic parameter structure that is used as a starting point for others
Pempty = struct();
Pempty.eyesToDraw = [0 1];
Pempty.outerRadiusDeg = 0;
Pempty.innerRadiusDeg = 0;
Pempty.bgLuminance = 0.1;
Pempty.stimLuminance = Pempty.bgLuminance; % just to be sure
Pempty.fixWidthDeg = 0.5;
Pempty.fixLineWidthPx = 3;
% Nothing-but-fixation screen parameters
Pfix = Pempty;
Pfix.fixColor = HW.white * 0.5;
% Bright screen for pupil calibration
PbrightCalib = Pempty;
PbrightCalib.bgLuminance = 227.6/227.6;
PbrightCalib.fixColor = HW.white * 0.5;
% Dark screen for pupil calibration
PdarkCalib = Pempty;
PdarkCalib.bgLuminance = 0;
PdarkCalib.fixColor = HW.white * 0.03;
% Data file:
% Object measured (see below)
% Brightness of display (-1 if not applicable)
% Size measured
% Plexon trigger time for synchro (-1 if not applicable)
% Objects to measure:
% 1: Limbus-to-limbus distance, i.e. corneal diameter (actual)
% 2: Bright stimulus, limbus on Eyelink screen
% 3: Bright stimulus, pupil on Eyelink screen
% 4: Dark stimulus, limbus on Eyelink screen
% 5: Dark stimulus, pupil on Eyelink screen
dataColumns = {'ObjectMeasured', 'Brightness', 'sizeMeasured', 'PlexonTimestamp'};
sessionName = input('Session name - pupil calibration (Subjectcode+experimentInitial):', 's');
datafile = DataFile(DataFile.defaultPath(sessionName), dataColumns);
realLimbDiam = input('1) Enter subject''s actual limbus diameter (mm)...');
datafile.append([1, -1, realLimbDiam, -1]);
% Draw fixation screen and Wait for subject to be ready
HW = DrawAnnulus(HW, Pfix);
fprintf('Ensure subject is viewing screen properly,\n');
[~] = input('then start Plexon data collection and press Enter...','s');
PL_GetTS(plexonServer); % Erase previous timestamps
% Display bright stimulus
HW = DrawAnnulus(HW, PbrightCalib);
[~] = input('Displaying bright stimulus; press Enter when steady measurements have been taken...', 's');
LPTTrigger(LPT_Stimulus_Trigger);
pause(0.1);
[~,triggerTS,~,~] = GetEventsPlexon(plexonServer); % read plexon's timestamp value
limDiamBright = input('2) Enter subject''s on-screen limbus diameter (mm)...');
datafile.append([2, PbrightCalib.bgLuminance, limDiamBright, triggerTS]);
pupDiamBright = input('3) Enter subject''s on-screen pupil diameter (mm)...');
datafile.append([3, PbrightCalib.bgLuminance, pupDiamBright, triggerTS]);
% Display dark stimulus
HW = DrawAnnulus(HW, PdarkCalib);
[~] = input('Displaying dark stimulus; press Enter when steady measurements have been taken...', 's');
LPTTrigger(LPT_Stimulus_Trigger);
pause(0.1);
[~,triggerTS,~,~] = GetEventsPlexon(plexonServer);
limDiamDark = input('4) Enter subject''s on-screen limbus diameter (mm)...');
datafile.append([4, PdarkCalib.bgLuminance, limDiamDark, triggerTS]);
pupDiamDark = input('5) Enter subject''s on-screen pupil diameter (mm)...');
datafile.append([5, PdarkCalib.bgLuminance, pupDiamDark, triggerTS]);
% Reset plexon state
LPTTrigger(LPT_Stimulus_End);
PL_GetTS(plexonServer); % erase existing timestamps
[~] = input('Done with calibration! Stop Plexon data collection and press Enter...','s');
end