Skip to content

Commit 8248f28

Browse files
committed
mh autofix
1 parent 583d72f commit 8248f28

File tree

2 files changed

+84
-85
lines changed

2 files changed

+84
-85
lines changed

src/saveEventsFile.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,14 @@ function printHeaderExtraColumns(logFile)
218218
if any(isnan(data))
219219
warning('saveEventsFile:missingData', ...
220220
'Missing some %s data for this event.', namesExtraColumns{iExtraColumn});
221-
221+
222222
if cfg.verbose
223223
disp(logFile(iEvent));
224224
end
225-
225+
226226
elseif all(isnan(data))
227227
warning('Missing %s data for this event.', namesExtraColumns{iExtraColumn});
228-
228+
229229
if cfg.verbose
230230
disp(logFile(iEvent));
231231
end

tests/test_saveEventsFileSave.m

Lines changed: 81 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@
77
end
88

99
function test_saveEventsFileSaveBasic()
10-
10+
1111
%% set up
12-
12+
1313
[cfg, logFile] = setUp();
14-
14+
1515
% create the events file and header
1616
logFile = saveEventsFile('open', cfg, logFile);
17-
17+
1818
% ROW 2: normal events : all info is there
1919
logFile(1, 1).onset = 2;
2020
logFile(end, 1).trial_type = 'motion_up';
2121
logFile(end, 1).duration = 3;
2222
logFile(end, 1).Speed = 2;
2323
logFile(end, 1).is_Fixation = true;
2424
logFile(end, 1).LHL24 = 1:12;
25-
25+
2626
logFile = saveEventsFile('save', cfg, logFile);
27-
27+
2828
% close the file
2929
saveEventsFile('close', cfg, logFile);
30-
30+
3131
%% test
32-
32+
3333
% check the extra columns of the header and some of the content
3434
content = getFileContent(cfg, logFile);
35-
35+
3636
% event 1/ ROW 2: check that values are entered correctly
3737
assertEqual(content{1}{2}, sprintf('%f', 2));
3838
assertEqual(content{3}{2}, 'motion_up');
@@ -41,209 +41,208 @@ function test_saveEventsFileSaveBasic()
4141
assertEqual(content{5}{2}, sprintf('%f', 1));
4242
assertEqual(content{16}{2}, sprintf('%f', 12));
4343
assertEqual(content{17}{2}, 'true');
44-
44+
4545
end
4646

4747
function test_saveEventsFileSaveSkipEmptyEvents()
48-
48+
4949
%% set up
50-
50+
5151
[cfg, logFile] = setUp();
52-
52+
5353
cfg.verbose = false;
54-
54+
5555
% create the events file and header
5656
logFile = saveEventsFile('open', cfg, logFile);
57-
57+
5858
% "empty" events except the last one
5959
logFile(1, 1).onset = [];
6060
logFile(end, 1).duration = [];
61-
61+
6262
logFile(2, 1).onset = 1;
6363
logFile(end, 1).duration = 'test';
64-
64+
6565
logFile(3, 1).onset = 1;
6666
logFile(end, 1).duration = nan;
67-
67+
6868
logFile(4, 1).onset = 'test';
6969
logFile(end, 1).duration = 1;
70-
70+
7171
logFile(5, 1).onset = nan;
7272
logFile(end, 1).duration = 1;
73-
73+
7474
logFile(6, 1).onset = 1;
7575
logFile(end, 1).duration = 1;
76-
77-
assertWarning(@()saveEventsFile('save', cfg, logFile), 'saveEventsFile:emptyEvent')
78-
76+
77+
assertWarning(@()saveEventsFile('save', cfg, logFile), 'saveEventsFile:emptyEvent');
78+
7979
saveEventsFile('save', cfg, logFile);
80-
80+
8181
% close the file
8282
saveEventsFile('close', cfg, logFile);
83-
83+
8484
%% test
85-
85+
8686
% check the extra columns of the header and some of the content
8787
content = getFileContent(cfg, logFile);
88-
88+
8989
% event 4-5 / ROW 5-6: skip empty events
90-
assertTrue(isequal(size(content{1},1), 2));
90+
assertTrue(isequal(size(content{1}, 1), 2));
9191
assertTrue(~isequal(content{1}{1}, sprintf('%f', 1)));
92-
92+
9393
end
9494

9595
function test_saveEventsFileSaveMissingInfo()
96-
96+
9797
%% set up
98-
98+
9999
[cfg, logFile] = setUp();
100-
100+
101101
% create the events file and header
102102
logFile = saveEventsFile('open', cfg, logFile);
103-
103+
104104
% ROW 1: missing info (speed, LHL24)
105105
logFile(1, 1).onset = 3;
106106
logFile(end, 1).trial_type = 'static';
107107
logFile(end, 1).duration = 4;
108108
logFile(end, 1).is_Fixation = false;
109-
109+
110110
% ROW 2: missing info (trial_type is missing and speed is empty)
111111
logFile(2, 1).onset = 4;
112112
logFile(end, 1).duration = 2;
113113
logFile(end, 1).Speed = [];
114114
logFile(end, 1).is_Fixation = true;
115115
logFile(end, 1).LHL24 = 1:12;
116-
116+
117117
saveEventsFile('save', cfg, logFile);
118-
118+
119119
% close the file
120120
saveEventsFile('close', cfg, logFile);
121-
121+
122122
%% test
123-
123+
124124
% check the extra columns of the header and some of the content
125125
content = getFileContent(cfg, logFile);
126-
126+
127127
% event 2 / ROW 3: missing info replaced by n/a
128128
assertEqual(content{4}{2}, 'n/a');
129129
assertEqual(content{5}{2}, 'n/a');
130130
assertEqual(content{16}{2}, 'n/a');
131131
assertEqual(content{17}{2}, 'false');
132-
132+
133133
% event 3 / ROW 4: missing info (trial_type is missing and speed is empty)
134134
assertEqual(content{3}{3}, 'n/a');
135135
assertEqual(content{4}{3}, 'n/a');
136-
136+
137137
end
138138

139139
function test_saveEventsFileSaveArraySize()
140-
140+
141141
%% set up
142-
142+
143143
[cfg, logFile] = setUp();
144-
144+
145145
cfg.verbose = false;
146-
146+
147147
% create the events file and header
148148
logFile = saveEventsFile('open', cfg, logFile);
149-
149+
150150
% ROW 1: missing info (array is too short)
151151
logFile(1, 1).onset = 5;
152152
logFile(end, 1).trial_type = 'jazz';
153153
logFile(end, 1).duration = 3;
154154
logFile(end, 1).LHL24 = rand(1, 10);
155-
156-
assertWarning(@()saveEventsFile('save', cfg, logFile), 'saveEventsFile:missingData')
157-
155+
156+
assertWarning(@()saveEventsFile('save', cfg, logFile), 'saveEventsFile:missingData');
157+
158158
saveEventsFile('save', cfg, logFile);
159-
159+
160160
% ROW 2: too much info (array is too long)
161161
logFile(1, 1).onset = 5;
162162
logFile(end, 1).trial_type = 'blues';
163163
logFile(end, 1).duration = 3;
164164
logFile(end, 1).LHL24 = rand(1, 15);
165-
166-
assertWarning(@()saveEventsFile('save', cfg, logFile), 'saveEventsFile:arrayTooLong')
167-
165+
166+
assertWarning(@()saveEventsFile('save', cfg, logFile), 'saveEventsFile:arrayTooLong');
167+
168168
saveEventsFile('save', cfg, logFile);
169-
169+
170170
% close the file
171171
saveEventsFile('close', cfg, logFile);
172-
172+
173173
%% test
174174
content = getFileContent(cfg, logFile);
175-
175+
176176
% check values entered properly
177177
assertEqual(content{15}{2}, 'n/a');
178178
assertEqual(content{16}{2}, 'n/a');
179-
179+
180180
end
181181

182182
function test_saveEventsFileSaveErrors()
183-
183+
184184
%% set up
185-
185+
186186
cfg = struct();
187187
logFile = struct();
188-
188+
189189
assertExceptionThrown(@()saveEventsFile('error', cfg, logFile), ...
190190
'saveEventsFile:unknownActionType');
191-
191+
192192
assertExceptionThrown(@()saveEventsFile('save', cfg, logFile), ...
193193
'saveEventsFile:missingFileID');
194-
194+
195195
[cfg, logFile] = setUp();
196-
196+
197197
logFile = saveEventsFile('open', cfg, logFile);
198-
198+
199199
% ROW 1: missing info (array is too short)
200200
logFile(1, 2).onset = 5;
201201
logFile(end, end).trial_type = 'jazz';
202202
logFile(end, end).duration = 3;
203203
logFile(end, end).LHL24 = rand(1, 10);
204-
204+
205205
assertExceptionThrown(@()saveEventsFile('save', cfg, logFile), ...
206206
'saveEventsFile:wrongLogSize');
207-
208-
207+
209208
end
210209

211210
function [cfg, logFile] = setUp()
212-
211+
213212
outputDir = fullfile(fileparts(mfilename('fullpath')), '..', 'output');
214-
213+
215214
cfg.verbose = true;
216-
215+
217216
cfg.subject.subjectNb = 1;
218217
cfg.subject.runNb = 1;
219-
218+
220219
cfg.task.name = 'testtask';
221-
220+
222221
cfg.dir.output = outputDir;
223-
222+
224223
cfg.testingDevice = 'mri';
225-
224+
226225
cfg = createFilename(cfg);
227-
226+
228227
logFile.extraColumns.Speed.length = 1;
229228
logFile.extraColumns.LHL24.length = 12;
230229
logFile.extraColumns.is_Fixation.length = 1;
231-
230+
232231
end
233232

234233
function content = getFileContent(cfg, logFile)
235-
234+
236235
% check the extra columns of the header and some of the content
237236
nbExtraCol = ...
238237
logFile(1).extraColumns.Speed.length + ...
239238
logFile(1).extraColumns.LHL24.length + ...
240239
logFile(1).extraColumns.is_Fixation.length;
241-
240+
242241
funcDir = fullfile(cfg.dir.outputSubject, cfg.fileName.modality);
243-
242+
244243
eventFilename = cfg.fileName.events;
245-
244+
246245
FID = fopen(fullfile(funcDir, eventFilename), 'r');
247246
content = textscan(FID, repmat('%s', 1, nbExtraCol + 3), 'Delimiter', '\t', 'EndOfLine', '\n');
248-
249-
end
247+
248+
end

0 commit comments

Comments
 (0)