create_events_tsv.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. % Adds a single events.tsv to the dataset
  2. %
  3. % requires bids-matlab: https://github.com/bids-standard/bids-matlab
  4. %
  5. %
  6. % timings in of the individual movie clips within the 15 min
  7. %
  8. % rest1 0:4
  9. % clip1 4:50
  10. % rest2 50:55
  11. % clip2 55:96
  12. % rest3 96:101
  13. % clip3 101:137
  14. % rest4 137:142
  15. % clip4 142:153
  16. % rest5 153:158
  17. % clip5 158:173
  18. % rest6 173:180
  19. % This is given in units of TRs.
  20. % These numbers refer to periods.
  21. % I.e. 0:4 = [0, 1, 2, 3]
  22. clear;
  23. timings = {'clip1', 4,50;
  24. 'clip2', 55,96;
  25. 'clip3', 101,137;
  26. 'clip4', 142,153;
  27. 'clip5', 158,173};
  28. % this is hard coded here
  29. % but obviously would have to be adapted dynamically to each file
  30. TRs = [5.1002; 5.1999];
  31. nb_volumes = 200;
  32. VolumeTiming = cumsum([0; repmat(TRs, nb_volumes / numel(TRs), 1)]);
  33. %%
  34. root_dir = fullfile(fileparts(mfilename('fullpath')), '..');
  35. filename = fullfile(root_dir, 'task-movie_events.tsv');
  36. % approximate duration by taking means of TR X number of TR for that clip
  37. tsv_content.onset = VolumeTiming([timings{:,2}] + 1);
  38. tsv_content.duration = [timings{:,3}] - [timings{:,2}] * mean(TRs);
  39. tsv_content.trial_type = repmat({'clip'}, size(timings, 1), 1);
  40. tsv_content.clip_number = 1:size(timings, 1);
  41. bids.util.tsvwrite(filename, tsv_content);