JA_TMS_random_delays.m 557 B

12345678910111213141516
  1. function [final_design] = JA_TMS_random_delays(final_design, TMS_delay, ifi)
  2. % based on the TMS delay it sets the TMS timings according to the '0.0' or
  3. % '-0.05' categories
  4. TMS_delay = str2double(TMS_delay{1});
  5. jitter = 0.05;
  6. TMS_tmp = [TMS_delay-jitter:ifi:TMS_delay:ifi:TMS_delay+jitter+ifi];
  7. TMS_delay_array = repmat(TMS_tmp, [1, ceil(size(final_design,1)/length(TMS_tmp))]);
  8. idx_TMS_full = randperm(length(TMS_delay_array));
  9. idx_TMS_def = idx_TMS_full(1:size(final_design,1));
  10. final_design.TMS = TMS_delay_array(idx_TMS_def)';
  11. end