Home > fmri > utils > rd_psyscope_data.m

rd_psyscope_data

PURPOSE ^

data = rd_psyscope_data(fname);

SYNOPSIS ^

function data = rd_psyscope_data(fname)

DESCRIPTION ^

 data = rd_psyscope_data(fname);

 Reads event timing information from psyscope data file

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data = rd_psyscope_data(fname)
0002 % data = rd_psyscope_data(fname);
0003 %
0004 % Reads event timing information from psyscope data file
0005 %
0006 
0007 % 03/24/00 PJ
0008 
0009 fid = fopen(fname,'rt');
0010 
0011 if fid == -1
0012   error(sprintf('Could not open: <%s>'))
0013 end
0014 
0015 data = struct('trial',[],'condition',[],'time',[],'state',[]);
0016 
0017 %
0018 % Look for start of data
0019 %
0020 
0021 found_start = 0;
0022 
0023 while ~found_start
0024   line = fgetl(fid);
0025   if findstr(line,'Trial') & findstr(line,'Condition')
0026     disp('Found start of data ...')
0027     found_start = 1;
0028   end
0029 end
0030 
0031 done = 0;
0032 nevents = 0;
0033 
0034 disp('Scanning for events ...')
0035 
0036 while ~done
0037   line = fgets(fid);
0038   if line == -1
0039     done = 1;
0040   else
0041     vals = sscanf(line,'%d',3);
0042 
0043     if vals
0044       nevents = nevents + 1;
0045       data.trial(nevents) = vals(1);
0046       data.time(nevents) = vals(2);
0047       data.state(nevents) = vals(3);
0048     end
0049   end
0050 end
0051 
0052 disp(sprintf('Found %d events',nevents))
0053 
0054 fclose(fid);

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003