Skip to content

Commit

Permalink
Merge pull request #193 from klabhub/eyelinkRemoteFile
Browse files Browse the repository at this point in the history
Add logging of remote Eyelink edf filename
  • Loading branch information
bartkrekelberg committed May 27, 2022
2 parents 0c3fc0e + a4b04e4 commit 6c7aa72
Showing 1 changed file with 12 additions and 7 deletions.
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

0 comments on commit 6c7aa72

Please sign in to comment.