eeg_lat2point() - convert latencies in time units relative to the time locking event of an eeglab() data epoch to latencies in data points (assuming concatenated epochs). Usage: >> [newlat] = eeg_lat2point( lat_array, epoch_array,... srate, timelimits, timeunit); Inputs: lat_array - latency array in 'timeunit' units (see below) epoch_array - epoch number for each latency srate - data sampling rate in Hz timelimits - [min max] epoch timelimits in 'timeunit' units (see below) timeunit - time unit relative to seconds. Default is 1 = seconds. Outputs: newlat - converted latency values in points assuming concatenated data epochs (see eeglab() event structure) Author: Arnaud Delorme, CNL / Salk Institute, 2 Mai 2002 See also: eeg_point2lat(), eeglab()
0001 % eeg_lat2point() - convert latencies in time units relative to the 0002 % time locking event of an eeglab() data epoch to 0003 % latencies in data points (assuming concatenated epochs). 0004 % Usage: 0005 % >> [newlat] = eeg_lat2point( lat_array, epoch_array,... 0006 % srate, timelimits, timeunit); 0007 % Inputs: 0008 % lat_array - latency array in 'timeunit' units (see below) 0009 % epoch_array - epoch number for each latency 0010 % srate - data sampling rate in Hz 0011 % timelimits - [min max] epoch timelimits in 'timeunit' units (see below) 0012 % timeunit - time unit relative to seconds. Default is 1 = seconds. 0013 % 0014 % Outputs: 0015 % newlat - converted latency values in points assuming concatenated 0016 % data epochs (see eeglab() event structure) 0017 % 0018 % Author: Arnaud Delorme, CNL / Salk Institute, 2 Mai 2002 0019 % 0020 % See also: eeg_point2lat(), eeglab() 0021 0022 % Copyright (C) 2 Mai 2002 Arnaud Delorme, Salk Institute, arno@salk.edu 0023 % 0024 % This program is free software; you can redistribute it and/or modify 0025 % it under the terms of the GNU General Public License as published by 0026 % the Free Software Foundation; either version 2 of the License, or 0027 % (at your option) any later version. 0028 % 0029 % This program is distributed in the hope that it will be useful, 0030 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0031 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0032 % GNU General Public License for more details. 0033 % 0034 % You should have received a copy of the GNU General Public License 0035 % along with this program; if not, write to the Free Software 0036 % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0037 0038 function newlat = eeg_lat2point( lat_array, epoch_array, srate, timewin, timeunit); 0039 0040 if nargin <4 0041 help eeg_lat2point; 0042 return; 0043 end; 0044 if nargin <5 0045 timeunit = 1; 0046 end; 0047 0048 if length(lat_array) ~= length(epoch_array) 0049 if length(epoch_array)~= 1 0050 disp('eeg_lat2point: latency and epochs must have the same length'); return; 0051 else 0052 epoch_array = ones(1,length(lat_array))*epoch_array; 0053 end; 0054 end; 0055 if length(timewin) ~= 2 0056 disp('eeg_lat2point: timelimits must have length 2'); return; 0057 end; 0058 if iscell(epoch_array) 0059 epoch_array = [ epoch_array{:} ]; 0060 end; 0061 if iscell(lat_array) 0062 lat_array = [ lat_array{:} ]; 0063 end 0064 0065 timewin = timewin*timeunit; 0066 pnts = (timewin(2)-timewin(1))*srate+1; 0067 newlat = (lat_array*timeunit-timewin(1))*srate+1 + (epoch_array-1)*pnts;