Skip to content

Commit

Permalink
fix bug in saving eyetracking files
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Gwilliams committed Jan 23, 2017
1 parent 619531f commit 462af62
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 42 deletions.
2 changes: 1 addition & 1 deletion external/PTBWrapper/PTBStopEyeTrackerRecording.m
Expand Up @@ -47,7 +47,7 @@

PTBEyeTrackerFileName = 'test';

status = Eyelink('ReceiveFile',PTBEyeTrackerFileName, PTBEyeTrackerFileName);
status = Eyelink('ReceiveFile')%,PTBEyeTrackerFileName, PTBEyeTrackerFileName);
disp(['Got status ' num2str(status) ' for command for receive file.']);
if status < 0
error('Eyetracker file not received.');
Expand Down
22 changes: 13 additions & 9 deletions runme/runme_MEGGamma.m
Expand Up @@ -19,7 +19,7 @@
tr = 1/hz*60;

% Run number?
runnr = 12;
runnr = 1;

%% Use Eyetracker?
if runnr == 1
Expand All @@ -34,19 +34,23 @@
end

if use_eyetracker

d = openScreen(d);
global PTBTheWindowPtr
PTBTheWindowPtr = d.windowPtr;



%Open the screen
PTBInitEyeTracker;
% paragraph = {'Eyetracker initialized.','Get ready to calibrate.'};
% PTBDisplayParagraph(paragraph, {'center',30}, {'a'});
PTBCalibrateEyeTracker;

% actually starts the recording
% name correponding to MEG file (can only be 8 characters!!, no extension)
PTBStartEyeTrackerRecording('eyelink');

Screen('CloseAll');

end

Screen('CloseAll');
%% MEG Parameters


Expand Down Expand Up @@ -85,12 +89,12 @@
PTBStopEyeTrackerRecording; % <----------- (can take a while)

% move the file to the logs directory
destination = '~/Desktop/Experiments/Winawer/';
destination = 'eyelink';
i = 0;
while exist([destination 'eyelink' num2str(i) '.edf'], 'file')
while exist([destination num2str(i) '.edf'], 'file')
i = i + 1;
end
movefile('eyelink.edf', [destination 'eyelink' num2str(i) '.edf'])
movefile('eyelink.edf', [destination num2str(i) '.edf'])

end

Expand Down
63 changes: 31 additions & 32 deletions runme/runme_MEG_OnOffLeftRight_ET_M2008.m
Expand Up @@ -12,7 +12,7 @@ function runme_MEG_OnOffLeftRight_ET_M2008(n, stimfile)
% n is the runnumber [1 15]
% stimfile is the prefix for the stimulus fils containing images, and can
% be either
% - attention_onOffLeftRight_params
% - attention_onOffLeftRight_params
% - onOffLeftRight_params
% The actual stim files have names like
% attention_onOffLeftRight_params1.mat
Expand All @@ -24,10 +24,10 @@ function runme_MEG_OnOffLeftRight_ET_M2008(n, stimfile)
% runme_MEG_OnOffLeftRight_ET_M2008(1, 'attention_onOffLeftRight_params');
% runme_MEG_OnOffLeftRight_ET_M2008(1, 'onOffLeftRight_params');

%%
%%
% initialize stim tracker for MEG
PTBInitStimTracker;
global PTBTriggerLength
global PTBTriggerLength
PTBTriggerLength = 0.001;

% debug mode?
Expand All @@ -38,42 +38,41 @@ function runme_MEG_OnOffLeftRight_ET_M2008(n, stimfile)
cal = 'meg_lcd';
d = loadDisplayParams(cal);
hz = FrameRate(d.screenNumber);
hz = 60;
%hz = %60;
tr = 1/hz*60;
use_eyetracker = false;
use_eyetracker = true;

% Do we want to use the eyetracker?
if n == 1; % Only for the first run

% use_eyetracker = true;

% d = openScreen(d);
% global PTBTheWindowPtr
% PTBTheWindowPtr = d.windowPtr;


if use_eyetracker

%Open the screen
PTBInitEyeTracker;
% paragraph = {'Eyetracker initialized.','Get ready to calibrate.'};
% PTBDisplayParagraph(paragraph, {'center',30}, {'a'});
PTBCalibrateEyeTracker;

% actually starts the recording
% name correponding to MEG file (can only be 8 characters!!, no extension)
PTBStartEyeTrackerRecording('eyelink');
if use_eyetracker == true;
d = openScreen(d);
global PTBTheWindowPtr
PTBTheWindowPtr = d.windowPtr;
if use_eyetracker
%Open the screen
PTBInitEyeTracker;
% paragraph = {'Eyetracker initialized.','Get ready to calibrate.'};
% PTBDisplayParagraph(paragraph, {'center',30}, {'a'});
PTBCalibrateEyeTracker;
% actually starts the recording
% name correponding to MEG file (can only be 8 characters!!, no extension)
PTBStartEyeTrackerRecording('eyelink');
end
end
end

Screen('CloseAll');

%% Default parameters
params = retCreateDefaultGUIParams;


%% Hemifield and ONOFF mixture
params.modality = 'MEG';
params.modality = 'MEG';
params.prescanDuration = 0;
params.interleaves = NaN;
params.tr = 1/hz*60;
Expand All @@ -99,19 +98,19 @@ function runme_MEG_OnOffLeftRight_ET_M2008(n, stimfile)


%% Check timing results
f = dir('~/Desktop/2014*.mat');
f = dir('~/Desktop/2017*.mat');
load(fullfile('~', 'Desktop', f(end).name));
figure(101); clf

% desired inter-stimulus duration
plot(diff(stimulus.seqtiming));

% measured inter-stimulus duration
hold on; plot(diff(response.flip), 'r-');
hold on; plot(diff(response.flip), 'r-');

ylim(median(diff(response.flip)) + [-.001 .001])
% frames between stimuli
frames = round(diff(response.flip) / (1/60));
frames = round(diff(response.flip) / (1/60));

% how many interstimulus frames differed from the median?
disp(sum(frames ~= median(frames)))
Expand All @@ -121,16 +120,16 @@ function runme_MEG_OnOffLeftRight_ET_M2008(n, stimfile)

if n == 15;
if use_eyetracker

PTBStopEyeTrackerRecording; % <----------- (can take a while)

% move the file to the logs directory
destination = '~/Desktop/MEG_eyelink_';
destination = 'eyelink';
i = 0;
while exist([destination num2str(i) '.edf'], 'file')
i = i + 1;
end
movefile('eyelink.edf', [destination num2str(i) '.edf'])

end
end

0 comments on commit 462af62

Please sign in to comment.