Home > vbmeg > functions > common > utility > vb_index_to_time.m

vb_index_to_time

PURPOSE ^

Return actual time (ms) for given sample indices

SYNOPSIS ^

function time = vb_index_to_time(index,meg_info)

DESCRIPTION ^

 Return actual time (ms) for given sample indices

 --- Syntax
 time = vb_index_to_time(index,MEGinfo)

 --- History
 2008-10-30 Taku Yoshioka

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function time = vb_index_to_time(index,meg_info)
0002 % Return actual time (ms) for given sample indices
0003 %
0004 % --- Syntax
0005 % time = vb_index_to_time(index,MEGinfo)
0006 %
0007 % --- History
0008 % 2008-10-30 Taku Yoshioka
0009 %
0010 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 sample_freq     = vb_meginfo_get_sampling_frequency(meg_info);
0014 Nsample         = vb_meginfo_get_sample_number(meg_info);
0015 pretrigger      = vb_meginfo_get_pre_trigger(meg_info);
0016 if isempty(pretrigger)
0017     pretrigger = 0;
0018 end
0019 
0020 % sampling length(msec).
0021 sampling_length = 1000/sample_freq;
0022 
0023 % time list of sample points(msec)
0024 sampling_point = -(sampling_length * pretrigger) : sampling_length : ...
0025     (sampling_length * (Nsample-pretrigger-1));
0026 
0027 for k=1:length(index)
0028   % array over flow check
0029   if index(k) > length(sampling_point)
0030     index(k) = length(sampling_point);
0031   end
0032   % return time
0033   time(k) = sampling_point(index(k));
0034 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005