-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmake_events.m
More file actions
executable file
·42 lines (31 loc) · 1012 Bytes
/
make_events.m
File metadata and controls
executable file
·42 lines (31 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function [t,table_header]=make_events(sub_id, task_id, run_id, onset, duration, trial_type, varargin)
%% Nancy projects
% It creates a BIDS compatible sub-01_ses-01_task-FullExample-01_events.tsv file
% This example lists all required and optional fields.
% When adding additional metadata please use CamelCase
%
% anushkab, 2018
% modified RG 201809
% modified marcobarilari 201912
%
% it requires:
%
%% make the file name
task_dir = pwd;
if ~exist(fullfile(pwd,'output'), 'dir')
mkdir(fullfile(pwd,'output'));
end
events_tsv_name = fullfile(task_dir, 'output', ...
['sub-' sub_id ...
'_task-' task_id ...
'_run-' run_id '_events.tsv']);
%% make an event table and save
t = table(onset,duration,trial_type,varargin{:});
table_header = {};
for K = 4 : nargin
fprintf('input #%d came from variable "%s"\n', K, inputname(K) );
table_header{end+1} = inputname(K);
end
t.Properties.VariableNames = table_header;
writetable(t,events_tsv_name,'FileType','text','Delimiter','\t');
end