11function test_makeRawDataset()
2-
2+
33 outputDir = fullfile(fileparts(mfilename(' fullpath' )), ' output' );
4-
4+
55 if isdir(outputDir )
66 rmdir(outputDir , ' s' );
77 end
8-
8+
99 %% set up
1010 cfg.dir.output = outputDir ;
11-
11+
1212 cfg.bids.datasetDescription.Name = ' dummy' ;
1313 cfg.bids.datasetDescription.BIDSVersion = ' 1.0.0' ;
1414 cfg.bids.datasetDescription.Authors = {' Jane Doe' , ' John Doe' };
15-
15+
1616 cfg.testingDevice = ' mri' ;
17-
17+
1818 %% MRI task data
1919 cfg.mri.repetitionTime = 1.56 ;
20-
20+
2121 cfg.subject.subjectNb = 1 ;
2222 cfg.subject.runNb = 1 ;
23-
23+
2424 cfg.task.name = ' testtask' ;
2525 cfg.task.instructions = ' do this' ;
26-
26+
2727 logFile.extraColumns.Speed.length = 1 ;
2828 logFile.extraColumns.LHL24.length = 3 ;
2929 logFile.extraColumns.is_Fixation.length = 1 ;
30-
30+
3131 cfg = createFilename(cfg );
32-
32+
3333 extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
3434 createJson(cfg , extraInfo );
35-
35+
3636 createDatasetDescription(cfg );
37-
37+
3838 % create the events file and header
3939 logFile = saveEventsFile(' open' , cfg , logFile );
40-
40+
4141 % ROW 2: normal events : all info is there
4242 logFile(1 , 1 ).onset = 2 ;
4343 logFile(end , 1 ).trial_type = ' MotionUp' ;
4444 logFile(end , 1 ).duration = 3 ;
4545 logFile(end , 1 ).Speed = 2 ;
4646 logFile(end , 1 ).is_Fixation = true ;
4747 logFile(end , 1 ).LHL24 = 1 : 3 ;
48-
48+
4949 % ROW 3: missing info (speed, LHL24)
5050 logFile(1 , 1 ).onset = 3 ;
5151 logFile(end , 1 ).trial_type = ' static' ;
5252 logFile(end , 1 ).duration = 4 ;
5353 logFile(end , 1 ).is_Fixation = false ;
54-
54+
5555 % ROW 4: missing info (duration is missing and speed is empty)
5656 logFile(2 , 1 ).onset = 4 ;
5757 logFile(end , 1 ).trial_type = ' BLUES' ;
5858 logFile(end , 1 ).Speed = [];
5959 logFile(end , 1 ).is_Fixation = true ;
6060 logFile(end , 1 ).LHL24 = rand(1 , 3 );
61-
61+
6262 % ROW 5: missing info (array is not the right size)
6363 logFile(5 , 1 ).onset = 5 ;
6464 logFile(end , 1 ).trial_type = ' jazz' ;
6565 logFile(end , 1 ).duration = 3 ;
6666 logFile(end , 1 ).LHL24 = rand(1 , 2 );
67-
67+
6868 saveEventsFile(' save' , cfg , logFile );
69-
69+
7070 % close the file
7171 saveEventsFile(' close' , cfg , logFile );
72-
72+
7373 % add dummy stim data
7474 stimLogFile = saveEventsFile(' open_stim' , cfg , logFile );
7575 for i = 1 : 100
@@ -85,169 +85,168 @@ function test_makeRawDataset()
8585
8686 %% MRI bold rest data and fancy suffixes
8787 clear cfg ;
88-
88+
8989 cfg.dir.output = outputDir ;
90-
90+
9191 cfg.testingDevice = ' mri' ;
92-
92+
9393 cfg.subject.subjectNb = 1 ;
9494 cfg.subject.runNb = 1 ;
95-
95+
9696 % deal with MRI suffixes
9797 cfg.suffix.reconstruction = ' fast recon' ;
9898 cfg.suffix.contrastEnhancement = ' test' ;
9999 cfg.suffix.phaseEncodingDirection = ' y pos' ;
100100 cfg.suffix.echo = ' 1' ;
101101 cfg.suffix.acquisition = ' new tYpe' ;
102-
102+
103103 cfg.mri.repetitionTime = 1.56 ;
104-
104+
105105 cfg.task.name = ' rest' ;
106-
106+
107107 cfg = createFilename(cfg );
108-
108+
109109 extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
110110 createJson(cfg , extraInfo );
111-
112-
111+
113112 %% EEG data and fancy suffixes
114113 clear cfg ;
115-
114+
116115 cfg.dir.output = outputDir ;
117-
116+
118117 cfg.testingDevice = ' eeg' ;
119-
118+
120119 cfg.subject.subjectNb = 1 ;
121120 cfg.subject.runNb = 1 ;
122-
121+
123122 cfg.task.name = ' target practice' ;
124123 cfg.task.instructions = ' do this' ;
125-
124+
126125 cfg.bids.eeg.EEGReference = ' Cz' ;
127126 cfg.bids.eeg.SamplingFrequency = 2400 ;
128127 cfg.bids.eeg.PowerLineFrequency = 50 ;
129128 cfg.bids.eeg.SoftwareFilters = ' n/a' ;
130129
131130 cfg = createFilename(cfg );
132-
131+
133132 extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
134133 createJson(cfg , extraInfo );
135-
134+
136135 %% iEEG data and fancy suffixes
137136 clear cfg ;
138-
137+
139138 cfg.dir.output = outputDir ;
140-
139+
141140 cfg.testingDevice = ' ieeg' ;
142-
141+
143142 cfg.subject.subjectNb = 1 ;
144143 cfg.subject.runNb = 1 ;
145-
144+
146145 cfg.task.name = ' implanted target practice' ;
147146 cfg.task.instructions = ' do this' ;
148-
147+
149148 cfg.bids.ieeg.iEEGReference = ' Cz' ;
150149 cfg.bids.ieeg.SamplingFrequency = 2400 ;
151150 cfg.bids.ieeg.PowerLineFrequency = 50 ;
152151 cfg.bids.ieeg.SoftwareFilters = ' n/a' ;
153-
152+
154153 cfg = createFilename(cfg );
155-
154+
156155 extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
157156 createJson(cfg , extraInfo );
158-
157+
159158 %% MEG data and fancy suffixes
160159 clear cfg ;
161-
160+
162161 cfg.dir.output = outputDir ;
163-
162+
164163 cfg.testingDevice = ' meg' ;
165-
164+
166165 cfg.subject.subjectNb = 1 ;
167166 cfg.subject.runNb = 1 ;
168-
167+
169168 cfg.task.name = ' magnetic target practice' ;
170169 cfg.task.instructions = ' do this' ;
171-
170+
172171 cfg.bids.meg.SamplingFrequency = 2400 ;
173172 cfg.bids.meg.PowerLineFrequency = 60 ;
174173 cfg.bids.meg.DewarPosition = ' upright' ;
175174 cfg.bids.meg.SoftwareFilters = ' n/a' ;
176175 cfg.bids.meg.DigitizedLandmarks = false ;
177176 cfg.bids.meg.DigitizedHeadPoints = false ;
178-
177+
179178 cfg = createFilename(cfg );
180-
179+
181180 extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
182181 createJson(cfg , extraInfo );
183-
182+
184183 %% beh data and fancy suffixes
185184 clear cfg ;
186-
185+
187186 cfg.dir.output = outputDir ;
188-
187+
189188 cfg.testingDevice = ' pc' ;
190-
189+
191190 cfg.subject.subjectNb = 1 ;
192191 cfg.subject.runNb = 1 ;
193-
192+
194193 cfg.task.name = ' easy target practice' ;
195194 cfg.task.instructions = ' do this' ;
196-
195+
197196 cfg = createFilename(cfg );
198-
197+
199198 extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
200199 createJson(cfg , extraInfo );
201-
200+
202201 %% add dummy data
203202 subjectDir = fullfile(cfg .dir .output , ' source' , ' sub-001' , ' ses-001' );
204203 funcDir = fullfile(subjectDir , ' func' );
205-
204+
206205 boldFilename = ' sub-001_ses-001_task-testtask_run-001_bold.nii.gz' ;
207-
206+
208207 copyfile( ...
209208 fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
210209 fullfile(funcDir , boldFilename ));
211-
210+
212211 boldFilename = [' sub-001_ses-001_task-rest' , ...
213212 ' _acq-newTYpe_ce-test_dir-yPos_rec-fastRecon' , ...
214213 ' _run-001_echo-1_bold.nii.gz' ];
215-
214+
216215 copyfile( ...
217216 fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
218217 fullfile(funcDir , boldFilename ));
219-
218+
220219 eegDir = fullfile(subjectDir , ' eeg' );
221220 megDir = fullfile(subjectDir , ' meg' );
222221 ieegDir = fullfile(subjectDir , ' ieeg' );
223222 behDir = fullfile(subjectDir , ' beh' );
224-
223+
225224 eegFilename = ' sub-001_ses-001_task-targetPractice_run-001_eeg.edf' ;
226225 megFilename = ' sub-001_ses-001_task-magneticTargetPractice_run-001_meg.fif' ;
227226 ieegFilename = ' sub-001_ses-001_task-implantedTargetPractice_run-001_ieeg.edf' ;
228227 behFilename = ' sub-001_ses-001_task-easyTargetPractice_run-001_beh.tsv' ;
229-
228+
230229 copyfile( ...
231230 fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
232231 fullfile(eegDir , eegFilename ));
233-
232+
234233 copyfile( ...
235234 fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
236235 fullfile(megDir , megFilename ));
237-
236+
238237 copyfile( ...
239238 fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
240239 fullfile(ieegDir , ieegFilename ));
241-
240+
242241 copyfile( ...
243242 fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
244243 fullfile(behDir , behFilename ));
245-
244+
246245 %% actually do the conversion of the source data thus created
247246 clear ;
248-
247+
249248 outputDir = fullfile(fileparts(mfilename(' fullpath' )), ' output' );
250249 cfg.dir.output = outputDir ;
251250 convertSourceToRaw(cfg );
252-
251+
253252end
0 commit comments