1
1
function test_makeRawDataset()
2
-
2
+
3
3
outputDir = fullfile(fileparts(mfilename(' fullpath' )), ' output' );
4
-
4
+
5
5
if isdir(outputDir )
6
6
rmdir(outputDir , ' s' );
7
7
end
8
-
8
+
9
9
%% set up
10
10
cfg.dir.output = outputDir ;
11
-
11
+
12
12
cfg.bids.datasetDescription.Name = ' dummy' ;
13
13
cfg.bids.datasetDescription.BIDSVersion = ' 1.0.0' ;
14
14
cfg.bids.datasetDescription.Authors = {' Jane Doe' , ' John Doe' };
15
-
15
+
16
16
cfg.testingDevice = ' mri' ;
17
-
17
+
18
18
%% MRI task data
19
19
cfg.mri.repetitionTime = 1.56 ;
20
-
20
+
21
21
cfg.subject.subjectNb = 1 ;
22
22
cfg.subject.runNb = 1 ;
23
-
23
+
24
24
cfg.task.name = ' testtask' ;
25
25
cfg.task.instructions = ' do this' ;
26
-
26
+
27
27
logFile.extraColumns.Speed.length = 1 ;
28
28
logFile.extraColumns.LHL24.length = 3 ;
29
29
logFile.extraColumns.is_Fixation.length = 1 ;
30
-
30
+
31
31
cfg = createFilename(cfg );
32
-
32
+
33
33
extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
34
34
createJson(cfg , extraInfo );
35
-
35
+
36
36
createDatasetDescription(cfg );
37
-
37
+
38
38
% create the events file and header
39
39
logFile = saveEventsFile(' open' , cfg , logFile );
40
-
40
+
41
41
% ROW 2: normal events : all info is there
42
42
logFile(1 , 1 ).onset = 2 ;
43
43
logFile(end , 1 ).trial_type = ' MotionUp' ;
44
44
logFile(end , 1 ).duration = 3 ;
45
45
logFile(end , 1 ).Speed = 2 ;
46
46
logFile(end , 1 ).is_Fixation = true ;
47
47
logFile(end , 1 ).LHL24 = 1 : 3 ;
48
-
48
+
49
49
% ROW 3: missing info (speed, LHL24)
50
50
logFile(1 , 1 ).onset = 3 ;
51
51
logFile(end , 1 ).trial_type = ' static' ;
52
52
logFile(end , 1 ).duration = 4 ;
53
53
logFile(end , 1 ).is_Fixation = false ;
54
-
54
+
55
55
% ROW 4: missing info (duration is missing and speed is empty)
56
56
logFile(2 , 1 ).onset = 4 ;
57
57
logFile(end , 1 ).trial_type = ' BLUES' ;
58
58
logFile(end , 1 ).Speed = [];
59
59
logFile(end , 1 ).is_Fixation = true ;
60
60
logFile(end , 1 ).LHL24 = rand(1 , 3 );
61
-
61
+
62
62
% ROW 5: missing info (array is not the right size)
63
63
logFile(5 , 1 ).onset = 5 ;
64
64
logFile(end , 1 ).trial_type = ' jazz' ;
65
65
logFile(end , 1 ).duration = 3 ;
66
66
logFile(end , 1 ).LHL24 = rand(1 , 2 );
67
-
67
+
68
68
saveEventsFile(' save' , cfg , logFile );
69
-
69
+
70
70
% close the file
71
71
saveEventsFile(' close' , cfg , logFile );
72
-
72
+
73
73
% add dummy stim data
74
74
stimLogFile = saveEventsFile(' open_stim' , cfg , logFile );
75
75
for i = 1 : 100
@@ -85,169 +85,168 @@ function test_makeRawDataset()
85
85
86
86
%% MRI bold rest data and fancy suffixes
87
87
clear cfg ;
88
-
88
+
89
89
cfg.dir.output = outputDir ;
90
-
90
+
91
91
cfg.testingDevice = ' mri' ;
92
-
92
+
93
93
cfg.subject.subjectNb = 1 ;
94
94
cfg.subject.runNb = 1 ;
95
-
95
+
96
96
% deal with MRI suffixes
97
97
cfg.suffix.reconstruction = ' fast recon' ;
98
98
cfg.suffix.contrastEnhancement = ' test' ;
99
99
cfg.suffix.phaseEncodingDirection = ' y pos' ;
100
100
cfg.suffix.echo = ' 1' ;
101
101
cfg.suffix.acquisition = ' new tYpe' ;
102
-
102
+
103
103
cfg.mri.repetitionTime = 1.56 ;
104
-
104
+
105
105
cfg.task.name = ' rest' ;
106
-
106
+
107
107
cfg = createFilename(cfg );
108
-
108
+
109
109
extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
110
110
createJson(cfg , extraInfo );
111
-
112
-
111
+
113
112
%% EEG data and fancy suffixes
114
113
clear cfg ;
115
-
114
+
116
115
cfg.dir.output = outputDir ;
117
-
116
+
118
117
cfg.testingDevice = ' eeg' ;
119
-
118
+
120
119
cfg.subject.subjectNb = 1 ;
121
120
cfg.subject.runNb = 1 ;
122
-
121
+
123
122
cfg.task.name = ' target practice' ;
124
123
cfg.task.instructions = ' do this' ;
125
-
124
+
126
125
cfg.bids.eeg.EEGReference = ' Cz' ;
127
126
cfg.bids.eeg.SamplingFrequency = 2400 ;
128
127
cfg.bids.eeg.PowerLineFrequency = 50 ;
129
128
cfg.bids.eeg.SoftwareFilters = ' n/a' ;
130
129
131
130
cfg = createFilename(cfg );
132
-
131
+
133
132
extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
134
133
createJson(cfg , extraInfo );
135
-
134
+
136
135
%% iEEG data and fancy suffixes
137
136
clear cfg ;
138
-
137
+
139
138
cfg.dir.output = outputDir ;
140
-
139
+
141
140
cfg.testingDevice = ' ieeg' ;
142
-
141
+
143
142
cfg.subject.subjectNb = 1 ;
144
143
cfg.subject.runNb = 1 ;
145
-
144
+
146
145
cfg.task.name = ' implanted target practice' ;
147
146
cfg.task.instructions = ' do this' ;
148
-
147
+
149
148
cfg.bids.ieeg.iEEGReference = ' Cz' ;
150
149
cfg.bids.ieeg.SamplingFrequency = 2400 ;
151
150
cfg.bids.ieeg.PowerLineFrequency = 50 ;
152
151
cfg.bids.ieeg.SoftwareFilters = ' n/a' ;
153
-
152
+
154
153
cfg = createFilename(cfg );
155
-
154
+
156
155
extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
157
156
createJson(cfg , extraInfo );
158
-
157
+
159
158
%% MEG data and fancy suffixes
160
159
clear cfg ;
161
-
160
+
162
161
cfg.dir.output = outputDir ;
163
-
162
+
164
163
cfg.testingDevice = ' meg' ;
165
-
164
+
166
165
cfg.subject.subjectNb = 1 ;
167
166
cfg.subject.runNb = 1 ;
168
-
167
+
169
168
cfg.task.name = ' magnetic target practice' ;
170
169
cfg.task.instructions = ' do this' ;
171
-
170
+
172
171
cfg.bids.meg.SamplingFrequency = 2400 ;
173
172
cfg.bids.meg.PowerLineFrequency = 60 ;
174
173
cfg.bids.meg.DewarPosition = ' upright' ;
175
174
cfg.bids.meg.SoftwareFilters = ' n/a' ;
176
175
cfg.bids.meg.DigitizedLandmarks = false ;
177
176
cfg.bids.meg.DigitizedHeadPoints = false ;
178
-
177
+
179
178
cfg = createFilename(cfg );
180
-
179
+
181
180
extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
182
181
createJson(cfg , extraInfo );
183
-
182
+
184
183
%% beh data and fancy suffixes
185
184
clear cfg ;
186
-
185
+
187
186
cfg.dir.output = outputDir ;
188
-
187
+
189
188
cfg.testingDevice = ' pc' ;
190
-
189
+
191
190
cfg.subject.subjectNb = 1 ;
192
191
cfg.subject.runNb = 1 ;
193
-
192
+
194
193
cfg.task.name = ' easy target practice' ;
195
194
cfg.task.instructions = ' do this' ;
196
-
195
+
197
196
cfg = createFilename(cfg );
198
-
197
+
199
198
extraInfo = struct(' extraInfo' , struct(' nestedExtraInfo' , ' something extra' ));
200
199
createJson(cfg , extraInfo );
201
-
200
+
202
201
%% add dummy data
203
202
subjectDir = fullfile(cfg .dir .output , ' source' , ' sub-001' , ' ses-001' );
204
203
funcDir = fullfile(subjectDir , ' func' );
205
-
204
+
206
205
boldFilename = ' sub-001_ses-001_task-testtask_run-001_bold.nii.gz' ;
207
-
206
+
208
207
copyfile( ...
209
208
fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
210
209
fullfile(funcDir , boldFilename ));
211
-
210
+
212
211
boldFilename = [' sub-001_ses-001_task-rest' , ...
213
212
' _acq-newTYpe_ce-test_dir-yPos_rec-fastRecon' , ...
214
213
' _run-001_echo-1_bold.nii.gz' ];
215
-
214
+
216
215
copyfile( ...
217
216
fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
218
217
fullfile(funcDir , boldFilename ));
219
-
218
+
220
219
eegDir = fullfile(subjectDir , ' eeg' );
221
220
megDir = fullfile(subjectDir , ' meg' );
222
221
ieegDir = fullfile(subjectDir , ' ieeg' );
223
222
behDir = fullfile(subjectDir , ' beh' );
224
-
223
+
225
224
eegFilename = ' sub-001_ses-001_task-targetPractice_run-001_eeg.edf' ;
226
225
megFilename = ' sub-001_ses-001_task-magneticTargetPractice_run-001_meg.fif' ;
227
226
ieegFilename = ' sub-001_ses-001_task-implantedTargetPractice_run-001_ieeg.edf' ;
228
227
behFilename = ' sub-001_ses-001_task-easyTargetPractice_run-001_beh.tsv' ;
229
-
228
+
230
229
copyfile( ...
231
230
fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
232
231
fullfile(eegDir , eegFilename ));
233
-
232
+
234
233
copyfile( ...
235
234
fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
236
235
fullfile(megDir , megFilename ));
237
-
236
+
238
237
copyfile( ...
239
238
fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
240
239
fullfile(ieegDir , ieegFilename ));
241
-
240
+
242
241
copyfile( ...
243
242
fullfile(' dummyData' , ' dummyData.nii.gz' ), ...
244
243
fullfile(behDir , behFilename ));
245
-
244
+
246
245
%% actually do the conversion of the source data thus created
247
246
clear ;
248
-
247
+
249
248
outputDir = fullfile(fileparts(mfilename(' fullpath' )), ' output' );
250
249
cfg.dir.output = outputDir ;
251
250
convertSourceToRaw(cfg );
252
-
251
+
253
252
end
0 commit comments