66
77- [ CPP_BIDS] ( #cpp_bids )
88 - [ Usage] ( #usage )
9+ - [ To save events.tsv file] ( #to-save-eventstsv-file )
910 - [ Functions descriptions] ( #functions-descriptions )
1011 - [ userInputs] ( #userinputs )
1112 - [ createFilename] ( #createfilename )
@@ -24,6 +25,8 @@ A set of function for matlab and octave to create [BIDS-compatible](https://bids
2425
2526## Usage
2627
28+ ### To save events.tsv file
29+
2730``` matlab
2831
2932% define the folder where the data will be saved
@@ -36,14 +39,12 @@ expParameters.task = 'testtask';
3639% expParameters = userInputs;
3740
3841% or declare it directly
39- expParameters.subjectGrp = '';
4042expParameters.subjectNb = 1;
41- expParameters.sessionNb = 1;
4243expParameters.runNb = 1;
4344
4445% by default we assume you are running things on a behavioral PC with no eyetracker
45- cfg.eyeTracker = false;
46- cfg.testingDevice = 'PC';
46+ % cfg.eyeTracker = false;
47+ % cfg.testingDevice = 'PC';
4748
4849% if the testing device is set to 'PC' then the data will be saved in the `beh` folder
4950% if set to 'mri' then the data will be saved in the `func` folder
@@ -54,34 +55,88 @@ cfg.testingDevice = 'PC';
5455% create the filenames: this include a step to check that all the information is there (checkCFG)
5556[cfg, expParameters] = createFilename(cfg, expParameters);
5657
57- % initialize the events files with the typical BIDS
58- % columns (onsets, duration, trial_type)
59- % and add some more in this case (Speed and is_Fixation)
60- logFile = saveEventsFile('open', expParameters, [], 'Speed', 'is_Fixation');
58+ % initialize the events files with the typical BIDS columns (onsets, duration, trial_type)
59+ % logFile = saveEventsFile('open', expParameters);
6160
62- % to initialize a stim file in case you want to store the info about the stimuli in it
63- stimFile = saveEventsFile('open_stim', expParameters, []);
61+ % You can add some more in this case (Speed and is_Fixation)
62+ logFile.extraColumns = {'Speed', 'is_Fixation'};
63+ logFile = saveEventsFile('open', expParameters, logFile);
6464
65- % create the information about 2 events that we want to save
65+ % The information about 2 events that we want to save
66+ % NOTE : If the user DOES NOT provide `onset`, `trial_type`, this events will be skipped.
6667logFile(1,1).onset = 2;
6768logFile(1,1).trial_type = 'motion_up';
6869logFile(1,1).duration = 1;
69- logFile(1,1).speed = 2;
70- logFile(1,1).is_fixation = true;
70+ logFile(1,1).Speed = 2;
71+ logFile(1,1).is_Fixation = true;
7172
7273logFile(2,1).onset = 3;
7374logFile(2,1).trial_type = 'static';
7475logFile(2,1).duration = 4;
75- logFile(2,1).is_fixation = 3;
76+ logFile(2,1).is_Fixation = 3;
7677
7778% add those 2 events to the events.tsv file
78- saveEventsFile('save', expParameters, logFile, 'speed', 'is_fixation' );
79+ saveEventsFile('save', expParameters, logFile);
7980
8081% close the file
8182saveEventsFile('close', expParameters, logFile);
8283
8384```
8485
86+ If you want to save more complex events.tsv file you can save several columns at once.
87+
88+ ``` matlab
89+ expParameters.subjectNb = 1;
90+ expParameters.runNb = 1;
91+ expParameters.task = 'testtask';
92+ expParameters.outputDir = outputDir;
93+
94+ cfg.testingDevice = 'mri';
95+
96+ [cfg, expParameters] = createFilename(cfg, expParameters);
97+
98+ % You can specify how many columns we want for each variable
99+ % will set 1 columns with name Speed
100+ % will set 12 columns with names LHL24-01, LHL24-02, ...
101+ % will set 1 columns with name is_Fixation
102+
103+ logFile.extraColumns.Speed.length = 1;
104+ logFile.extraColumns.LHL24.length = 12;
105+ logFile.extraColumns.is_Fixation.length = 1;
106+
107+ logFile = saveEventsFile('open', expParameters, logFile);
108+
109+ logFile(1, 1).onset = 2;
110+ logFile(end, 1).trial_type = 'motion_up';
111+ logFile(end, 1).duration = 3;
112+ logFile(end, 1).Speed = 2;
113+ logFile(end, 1).is_Fixation = true;
114+ logFile(end, 1).LHL24 = 1:12;
115+
116+ saveEventsFile('save', expParameters, logFile);
117+
118+ saveEventsFile('close', expParameters, logFile);
119+
120+ ```
121+
122+ If you have many columns to define but only a few with several columns, you can do this:
123+
124+ ``` matlab
125+ % define the extra columns: they will be added to the tsv files in the order the user input them
126+ logFile.extraColumns = {'Speed', 'is_Fixation'};
127+
128+ [cfg, expParameters] = createFilename(cfg, expParameters);
129+
130+ % dummy call to initialize the logFile variable
131+ logFile = saveEventsFile('open', expParameters, logFile);
132+
133+ % set the real length we really want
134+ logFile.extraColumns.Speed.length = 12;
135+
136+ % actual inititalization
137+ logFile = saveEventsFile('open', expParameters, logFile);
138+ ```
139+
85140## Functions descriptions
86141
87142### userInputs
@@ -127,7 +182,11 @@ For the moment the date of acquisition is appended to the filename
127182
128183Function to save output files for events that will be BIDS compliant.
129184
185+ If the user DOES NOT provide ` onset ` , ` trial_type ` , this events will be skipped. ` duration ` will be set to "NaN" if
186+ no value is provided.
187+
130188### checkCFG
189+
131190Check that we have all the fields that we need in the experiment parameters.
132191
133192## How to install
0 commit comments