Home > eeg > egis > egis_file_utils > rd_onetr_allch.m

rd_onetr_allch

PURPOSE ^

trialdata = rd_onetr_allch(fileid, cell_data_offset, trial_num, nchan, npoints, seek_start, start_samp, stop_samp)

SYNOPSIS ^

function trialdata = rd_onetr_allch(fid, cell_data_offset, trial_num, nchan, npoints, seek_start, start_samp, stop_samp)

DESCRIPTION ^

 trialdata = rd_onetr_allch(fileid, cell_data_offset, trial_num, nchan, npoints, seek_start, start_samp, stop_samp)

   Reads the raw (untransformed) data from all channels for a single trial 
   from a single cell in the EGIS session file referred to by the file_id.

   Returns channels in columns

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function trialdata = rd_onetr_allch(fid, cell_data_offset, trial_num, nchan, npoints, seek_start, start_samp, stop_samp)
0002 % trialdata = rd_onetr_allch(fileid, cell_data_offset, trial_num, nchan, npoints, seek_start, start_samp, stop_samp)
0003 %
0004 %   Reads the raw (untransformed) data from all channels for a single trial
0005 %   from a single cell in the EGIS session file referred to by the file_id.
0006 %
0007 %   Returns channels in columns
0008 
0009 % Modification history:
0010 %
0011 %  7/20/95 PJ -- version 1.1  added command line parameter 'seek_start' which enables one
0012 %                 to read directly from the last location accessed in the file
0013 %                instead of seeking from the beginning of the file.
0014 %                seek_start = 'cof' for reading from current position and seek_start = 'bof'
0015 %                for searching from beginning and then reading
0016 %
0017 %                Also added the optional parameters 'start_samp' and 'stop_samp'
0018 %                which allow one to extract a subset of samples from the trial
0019 %
0020 %  2/15/95 PJ -- started work on module
0021 %
0022 bytes_to_end_of_trial = 0;
0023 
0024 if nargin <= 5
0025   trial_offset = cell_data_offset + (trial_num-1)*nchan*npoints*2;
0026   seek_start = 'bof';
0027   start_samp = 1; stop_samp = npoints;
0028   samp_offset = 0;
0029 elseif nargin == 6
0030   if seek_start == 'bof'
0031     trial_offset = cell_data_offset + (trial_num-1)*nchan*npoints*2;
0032   else
0033     trial_offset = 0;
0034   end
0035   start_samp = 1; stop_samp = npoints;
0036   samp_offset = 0;
0037 elseif nargin == 8
0038   if seek_start == 'bof'
0039     trial_offset = cell_data_offset + (trial_num-1)*nchan*npoints*2;
0040   else
0041     trial_offset = 0;
0042   end
0043   samp_offset = (start_samp - 1)*nchan*2;
0044   bytes_to_end_of_trial = (npoints - stop_samp)*nchan*2;
0045 end
0046 
0047 nsamps = stop_samp - start_samp + 1;
0048 %trial_offset, samp_offset, nsamps
0049 fseek(fid, trial_offset + samp_offset, seek_start);
0050 
0051 trialdata = fread(fid, [nchan, nsamps],'int16');
0052 
0053 %seek to the end of trial in case only a subset of samples was read.
0054 %This aligns the file pointer at the proper position for a subsequent
0055 %read in which the 'seek_start' parameter is 'cof'.  Otherwise the
0056 %subsequent read would read in the wrong chunk of data.
0057 
0058 fseek(fid, bytes_to_end_of_trial, 'cof');
0059 
0060 trialdata = trialdata';

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003