Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging of remote Eyelink edf filename #193

Merged
merged 1 commit into from
May 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions +neurostim/+plugins/eyelink.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
properties
el; %@struct; % Information structure to communicate with Eyelink host
commands = {'link_sample_data = GAZE'};
edfFile = 'test.edf';
edfFile = '';
edfFileRemote = '';
getSamples =true;
getEvents =false;
nTransferAttempts = 5;
Expand Down Expand Up @@ -180,10 +181,14 @@ function beforeExperiment(o)
Eyelink('command', 'sample_rate = %d',o.sampleRate);


% open file to record data to (will be renamed on copy)
% Create a temporary file anme to use on Eyelink remote PC
% side. Will be renamed to default ns format on transfer
% afterExperiment
[~,tmpFile] = fileparts(tempname);
o.edfFile= [tmpFile(end-7:end) '.edf']; %8 character limit
Eyelink('Openfile', o.edfFile);
o.edfFileRemote = [tmpFile(end-7:end) '.edf']; %8 character limit in Eyelink software

% open file to record data to (will be renamed on copy)
Eyelink('Openfile', o.edfFileRemote);

switch upper(o.eye)
case 'LEFT'
Expand Down Expand Up @@ -294,19 +299,19 @@ function afterExperiment(o)
try
newFileName = [o.cic.fullFile '.edf'];
for i=1:o.nTransferAttempts
status=Eyelink('ReceiveFile',o.edfFile,newFileName); %change to OUTPUT dir
status=Eyelink('ReceiveFile',o.edfFileRemote,newFileName); %change to OUTPUT dir
if status>0
o.edfFile = newFileName;
writeToFeed(o,['Success: transferred ' num2str(status) ' bytes']);
break
else
o.nTransferAttempts = o.nTransferAttempts - 1;
writeToFeed(o,['Fail: EDF file (' o.edfFile ') did not transfer ' num2str(status)]);
writeToFeed(o,['Fail: EDF file (' o.edfFileRemote ') did not transfer ' num2str(status)]);
writeToFeed(o,['Retrying. ' num2str(o.nTransferAttempts) ' attempts remaining.']);
end
end
catch
error(horzcat('Eyelink file transfer failed. Saved on Eyelink PC as ',o.edfFile));
error(horzcat('Eyelink file transfer failed. Saved on Eyelink PC as ',o.edfFileRemote));
end
end
Eyelink('Shutdown');
Expand Down