Home > 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 
0017 % sampling length(msec).
0018 sampling_length = 1000/sample_freq;
0019 
0020 % time list of sample points(msec)
0021 sampling_point = -(sampling_length * pretrigger) : sampling_length : ...
0022     (sampling_length * (Nsample-pretrigger-1));
0023 
0024 for k=1:length(index)
0025   % array over flow check
0026   if index(k) > length(sampling_point)
0027     index(k) = length(sampling_point);
0028   end
0029   % return time
0030   time(k) = sampling_point(index(k));
0031 end

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005