Skip to content

Commit 90316ff

Browse files
committed
Merge remote-tracking branch 'cpp-lln-lab/master'
2 parents 661c536 + 9dc88a2 commit 90316ff

File tree

3 files changed

+165
-120
lines changed

3 files changed

+165
-120
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ If no key is pressed on the correct keyboard after the timeOut time this exits w
237237
A wrapper function to close all windows, ports, show mouse cursor, close keyboard queues
238238
and give access back to the keyboards.
239239

240+
### getExperimentStart
241+
242+
Wrapper function that will show a fixation cross and collect a start timestamp in `cfg.experimentStart`
243+
244+
### getExperimentEnd
245+
246+
Wrapper function that will show a fixation cross and display in the console the whole experiment's duration in minutes and seconds
247+
240248
### getResponse
241249

242250
It is wrapper function to use `KbQueue` which is definitely what you should use to collect responses.
@@ -263,8 +271,6 @@ In brief, there are several actions you can execute with this function.
263271
- stop: Stops buffering key presses. You can still restart by calling "start" again.
264272
- release: Closes the buffer for good.
265273

266-
267-
268274
### deg2Pix
269275

270276
For a given field value in degrees of visual angle in the input `structure`,
@@ -283,6 +289,9 @@ This will handle the Eye Tracker (EyeLink set up) and can be called to initializ
283289

284290
Use that to stop your script and only restart when the space bar is pressed.
285291

292+
### standByScreen
293+
294+
It shows a basic one-page instruction stored in `cfg.task.instruction` and wait for `space` stroke.
286295

287296
### waitForTrigger
288297

eyeTracker.m

100755100644
Lines changed: 153 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
% Eyelink already initialized!
2+
% Running experiment on a 'EYELINK CL 4.56 ' tracker.
3+
% Error in function Open: Usage error
4+
% Could not find *any* audio hardware on your system - or at least not with the provided deviceid, if any!
5+
% Error in function FillRect: Invalid Window (or Texture) Index provided: It doesn't correspond to an open window or texture.
6+
% Did you close it accidentally via Screen('Close') or Screen('CloseAll') ?
7+
% EYELINK: WARNING! PsychEyelinkCallRuntime() Failed to call eyelink runtime callback function PsychEyelinkDispatchCallback [rc = 1]!
8+
% EYELINK: WARNING! Make sure that function is on your Matlab/Octave path and properly initialized.
9+
% EYELINK: WARNING! May also be an error during execution of that function. Type ple at command prompt for error messages.
10+
% EYELINK: WARNING! Auto-Disabling all callbacks to the runtime environment for safety reasons.
11+
% Eyelink: In PsychEyelink_get_input_key(): Error condition detected: Trying to send TERMINATE_KEY abort keycode!
12+
13+
% Eyelink: In PsychEyelink_get_input_key(): Error condition detected: Trying to send TERMINATE_KEY abort keycode!
14+
% Error in function FillRect: Invalid Window (or Texture) Index provided: It doesn't correspond to an open window or texture.
15+
% Did you close it accidentally via Screen('Close') or Screen('CloseAll') ?
16+
% Error using Screen
17+
% Usage:
18+
%
19+
% Screen('FillRect', windowPtr [,color] [,rect] )
20+
%
21+
% Error in eyeTracker (line 150)
22+
% Screen('FillRect', cfg.screen.win, [0 0 0]);
23+
%
24+
% Error in visualLocTanslational (line 52)
25+
% [el] = eyeTracker('Calibration', cfg);
26+
127
function [el, edfFile] = eyeTracker(input, cfg, varargin)
228
% [el, edfFile] = eyeTracker(input, cfg, varargin)
329
%
@@ -18,13 +44,13 @@
1844
% and perform some initializations. The information is returned
1945
% in a structure that also contains useful defaults
2046
% and control codes (e.g. tracker state bit and Eyelink key values).
21-
el = EyelinkInitDefaults(cfg.win);
47+
el = EyelinkInitDefaults(cfg.screen.win);
2248

2349
% calibration has silver background with black targets, sound and smaller
2450
% targets
25-
el.backgroundcolour = [192 192 192, (cfg.win)];
26-
el.msgfontcolour = BlackIndex(cfg.win);
27-
el.calibrationtargetcolour = BlackIndex(cfg.win);
51+
el.backgroundcolour = [192 192 192, (cfg.screen.win)];
52+
el.msgfontcolour = BlackIndex(cfg.screen.win);
53+
el.calibrationtargetcolour = BlackIndex(cfg.screen.win);
2854
el.calibrationtargetsize = 1;
2955
el.calibrationtargetwidth = 0.5;
3056
el.displayCalResults = 1;
@@ -91,38 +117,37 @@
91117
% you must send this command with value NO for custom calibration
92118
% you must also reset it to YES for subsequent experiments
93119
Eyelink('command', 'generate_default_targets = YES');
94-
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
95120

96-
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
97-
% % CUSTOM CALIBRATION
98-
% % (SET MANUALLY THE DOTS COORDINATES, HERE FOR 6 DOTS)
99-
% Eyelink('command', 'calibration_type = HV5');
100-
% % you must send this command with value NO for custom calibration
101-
% % you must also reset it to YES for subsequent experiments
102-
% Eyelink('command', 'generate_default_targets = NO');
103-
%
104-
% % calibration and validation target locations
105-
% [width, height]=Screen('WindowSize', screenNumber);
106-
% Eyelink('command','calibration_samples = 6');
107-
% Eyelink('command','calibration_sequence = 0,1,2,3,4,5');
108-
% Eyelink('command','calibration_targets = ...
109-
% %d,%d %d,%d %d,%d %d,%d %d,%d',...
110-
% 640,512, ... %width/2,height/2
111-
% 640,102, ... %width/2,height*0.1
112-
% 640,614, ... %width/2,height*0.6
113-
% 128,341, ... %width*0.1,height*1/3
114-
% 1152,341 ); %width-width*0.1,height*1/3
115-
%
116-
% Eyelink('command','validation_samples = 5');
117-
% Eyelink('command','validation_sequence = 0,1,2,3,4,5');
118-
% Eyelink('command','validation_targets = ...
119-
% %d,%d %d,%d %d,%d %d,%d %d,%d',...
120-
% 640,512, ... %width/2,height/2
121-
% 640,102, ... %width/2,height*0.1
122-
% 640,614, ... %width/2,height*0.6
123-
% 128,341, ... %width*0.1,height*1/3
124-
% 1152,341 ); %width-width*0.1,height*1/3
125-
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
121+
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
122+
%
123+
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
124+
% % CUSTOM CALIBRATION
125+
% % (SET MANUALLY THE DOTS COORDINATES, HERE FOR 6 DOTS)
126+
% Eyelink('command', 'calibration_type = HV5');
127+
% % you must send this command with value NO for custom calibration
128+
% % you must also reset it to YES for subsequent experiments
129+
% Eyelink('command', 'generate_default_targets = NO');
130+
%
131+
% % calibration and validation target locations
132+
% [width, height]=Screen('WindowSize', screenNumber);
133+
% Eyelink('command','calibration_samples = 6');
134+
% Eyelink('command','calibration_sequence = 0,1,2,3,4,5');
135+
% Eyelink('command','calibration_targets = %d,%d %d,%d %d,%d %d,%d %d,%d',...
136+
% 640,512, ... %width/2,height/2
137+
% 640,102, ... %width/2,height*0.1
138+
% 640,614, ... %width/2,height*0.6
139+
% 128,341, ... %width*0.1,height*1/3
140+
% 1152,341 ); %width-width*0.1,height*1/3
141+
%
142+
% Eyelink('command','validation_samples = 5');
143+
% Eyelink('command','validation_sequence = 0,1,2,3,4,5');
144+
% Eyelink('command','validation_targets = %d,%d %d,%d %d,%d %d,%d %d,%d',...
145+
% 640,512, ... %width/2,height/2
146+
% 640,102, ... %width/2,height*0.1
147+
% 640,614, ... %width/2,height*0.6
148+
% 128,341, ... %width*0.1,height*1/3
149+
% 1152,341 ); %width-width*0.1,height*1/3
150+
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
126151

127152
% % set parser (conservative saccade thresholds)
128153
% Eyelink('command', 'saccade_velocity_threshold = 35');
@@ -134,21 +159,21 @@
134159
% enter Eyetracker camera setup mode, calibration and validation
135160
EyelinkDoTrackerSetup(el);
136161

137-
% % % do a final check of calibration using driftcorrection
138-
% % % You have to hit esc before return.
139-
% % EyelinkDoDriftCorrection(el);
140-
%
141-
% % % do a final check of calibration using driftcorrection
142-
% % success=EyelinkDoDriftCorrection(el);
143-
% % if success~=1
144-
% % Eyelink('shutdown');
145-
% % Screen('CloseAll');
146-
% % return;
147-
% % end
162+
% % do a final check of calibration using driftcorrection
163+
% % You have to hit esc before return.
164+
% EyelinkDoDriftCorrection(el);
165+
166+
% % do a final check of calibration using driftcorrection
167+
% success=EyelinkDoDriftCorrection(el);
168+
% if success~=1
169+
% Eyelink('shutdown');
170+
% cleanUp()
171+
% return;
172+
% end
148173

149174
% Go back to black screen
150-
Screen('FillRect', cfg.win, [0 0 0]);
151-
Screen('Flip', cfg.win);
175+
Screen('FillRect', cfg.screen.win, [0 0 0]);
176+
Screen('Flip', cfg.screen.win);
152177

153178
case 'StartRecording'
154179

@@ -191,7 +216,11 @@
191216

192217
case 'Shutdown'
193218

194-
edfFileName = cfg.fileName.eyetracker;
219+
edfFileName = fullfile( ...
220+
cfg.dir.outputSubject, ...
221+
'eyetracker', ...
222+
cfg.fileName.eyetracker);
223+
195224
edfFile = 'demo.edf';
196225

197226
% STEP 6
@@ -205,18 +234,25 @@
205234
% download data file
206235
try
207236
fprintf('Receiving data file ''%s''\n', edfFileName);
208-
status = Eyelink('ReceiveFile', '', ...
209-
[cfg.outputDir, filesep, 'eyetracker', filesep, edfFileName]);
237+
238+
status = Eyelink('ReceiveFile', '', edfFileName);
239+
210240
if status > 0
211241
fprintf('ReceiveFile status %d\n', status);
212242
end
213-
if 2 == exist([cfg.outputDir, filesep, 'eyetracker', ...
214-
filesep, edfFileName], 'file')
215-
fprintf('Data file ''%s'' can be found in ''%s''\n', edfFileName, ...
216-
[cfg.outputDir, filesep, 'eyetracker', filesep]);
243+
244+
if 2 == exist(edfFileName, 'file')
245+
246+
fprintf('Data file ''%s'' can be found in ''%s''\n', ...
247+
cfg.fileName.eyetracker, ...
248+
fullfile(cfg.dir.outputSubject, 'eyetracker'));
249+
217250
end
251+
218252
catch
253+
219254
fprintf('Problem receiving data file ''%s''\n', edfFileName);
255+
220256
end
221257

222258
Eyelink('shutdown');
@@ -229,65 +265,65 @@
229265

230266
%% subfunctions for iView
231267

232-
function ivx = eyeTrackInit(cfg)
233-
% initialize iView eye tracker
234-
235-
ivx = [];
236-
237-
if cfg.eyeTracker
238-
239-
host = cfg.eyetracker.Host;
240-
port = cfg.eyetracker.Port;
241-
window = cfg.eyetracker.Window;
242-
243-
% original: ivx=iviewxinitdefaults(window, 9 , host, port);
244-
ivx = iviewxinitdefaults2(window, 9, [], host, port);
245-
ivx.backgroundColour = 0;
246-
[~, ivx] = iViewX('openconnection', ivx);
247-
[success, ivx] = iViewX('checkconnection', ivx);
248-
if success ~= 1
249-
error('connection to eye tracker failed');
250-
end
251-
end
252-
end
253-
254-
function eyeTrackStart(ivx, cfg)
255-
% start iView eye tracker
256-
if cfg.eyeTracker
257-
% to clear data buffer
258-
iViewX('clearbuffer', ivx);
259-
% start recording
260-
iViewX('startrecording', ivx);
261-
iViewX('message', ivx, ...
262-
[ ...
263-
'Start_Ret_', ...
264-
'Subj_', cfg.Subj, '_', ...
265-
'Run', num2str(cfg.Session(end)), '_', ...
266-
cfg.Apperture, '_', ...
267-
cfg.Direction]);
268-
iViewX('incrementsetnumber', ivx, 0);
269-
end
270-
end
271-
272-
function eyeTrackStop(ivx, cfg)
273-
% stop iView eye tracker
274-
275-
if cfg.eyeTracker
276-
277-
% stop tracker
278-
iViewX('stoprecording', ivx);
279-
280-
% save data file
281-
thedatestr = datestr(now, 'yyyy-mm-dd_HH.MM');
282-
strFile = fullfile(OutputDir, ...
283-
[cfg.Subj, ...
284-
'_run', num2str(cfg.Session(end)), '_', ...
285-
cfg.Apperture, '_', ...
286-
cfg.Direction, '_', ...
287-
thedatestr, '.idf"']);
288-
iViewX('datafile', ivx, strFile);
289-
290-
% close iView connection
291-
iViewX('closeconnection', ivx);
292-
end
293-
end
268+
% function ivx = eyeTrackInit(cfg)
269+
% % initialize iView eye tracker
270+
%
271+
% ivx = [];
272+
%
273+
% if cfg.eyeTracker
274+
%
275+
% host = cfg.eyetracker.Host;
276+
% port = cfg.eyetracker.Port;
277+
% window = cfg.eyetracker.Window;
278+
%
279+
% % original: ivx=iviewxinitdefaults(window, 9 , host, port);
280+
% ivx = iviewxinitdefaults2(window, 9, [], host, port);
281+
% ivx.backgroundColour = 0;
282+
% [~, ivx] = iViewX('openconnection', ivx);
283+
% [success, ivx] = iViewX('checkconnection', ivx);
284+
% if success ~= 1
285+
% error('connection to eye tracker failed');
286+
% end
287+
% end
288+
% end
289+
%
290+
% function eyeTrackStart(ivx, cfg)
291+
% % start iView eye tracker
292+
% if cfg.eyeTracker
293+
% % to clear data buffer
294+
% iViewX('clearbuffer', ivx);
295+
% % start recording
296+
% iViewX('startrecording', ivx);
297+
% iViewX('message', ivx, ...
298+
% [ ...
299+
% 'Start_Ret_', ...
300+
% 'Subj_', cfg.Subj, '_', ...
301+
% 'Run', num2str(cfg.Session(end)), '_', ...
302+
% cfg.Apperture, '_', ...
303+
% cfg.Direction]);
304+
% iViewX('incrementsetnumber', ivx, 0);
305+
% end
306+
% end
307+
%
308+
% function eyeTrackStop(ivx, cfg)
309+
% % stop iView eye tracker
310+
%
311+
% if cfg.eyeTracker
312+
%
313+
% % stop tracker
314+
% iViewX('stoprecording', ivx);
315+
%
316+
% % save data file
317+
% thedatestr = datestr(now, 'yyyy-mm-dd_HH.MM');
318+
% strFile = fullfile(OutputDir, ...
319+
% [cfg.Subj, ...
320+
% '_run', num2str(cfg.Session(end)), '_', ...
321+
% cfg.Apperture, '_', ...
322+
% cfg.Direction, '_', ...
323+
% thedatestr, '.idf"']);
324+
% iViewX('datafile', ivx, strFile);
325+
%
326+
% % close iView connection
327+
% iViewX('closeconnection', ivx);
328+
% end
329+
% end

initPTB.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
checkPtbVersion();
2424

2525
pth = fileparts(mfilename('fullpath'));
26-
addpath(fullfile(pth, 'subfun'));
26+
addpath(genpath(fullfile(pth, 'src')));
2727

2828
% For octave: to avoid displaying messenging one screen at a time
2929
more off;

0 commit comments

Comments
 (0)