0001 function time = vb_index_to_time(index,meg_info)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
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
0021 sampling_length = 1000/sample_freq;
0022
0023
0024 sampling_point = -(sampling_length * pretrigger) : sampling_length : ...
0025 (sampling_length * (Nsample-pretrigger-1));
0026
0027 for k=1:length(index)
0028
0029 if index(k) > length(sampling_point)
0030 index(k) = length(sampling_point);
0031 end
0032
0033 time(k) = sampling_point(index(k));
0034 end