Skip to content

Commit 72b5768

Browse files
committed
mh autofix
1 parent 98d8ccf commit 72b5768

File tree

8 files changed

+109
-111
lines changed

8 files changed

+109
-111
lines changed

src/createDataDictionary.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ function createDataDictionary(cfg, logFile)
2020
jsonContent = setJsonContent(logFile);
2121

2222
opts.Indent = ' ';
23-
23+
2424
bids.util.jsonencode(fullFilename, jsonContent, opts);
2525

2626
end
2727

2828
function jsonContent = setJsonContent(logFile)
2929

3030
% regular _events file: add default _event file fields to the json content
31-
if ~isfield(logFile,'isStim') || isempty(logFile.isStim) || ~logFile.isStim
32-
33-
jsonContent = logFile.columns;
31+
if ~isfield(logFile, 'isStim') || isempty(logFile.isStim) || ~logFile.isStim
32+
33+
jsonContent = logFile.columns;
3434

35-
% _stim file: write stim-specific fields to the json content
35+
% _stim file: write stim-specific fields to the json content
3636
elseif logFile.isStim
37-
37+
3838
samplingFrequency = nan;
3939
startTime = nan;
4040

@@ -50,10 +50,10 @@ function createDataDictionary(cfg, logFile)
5050
'StartTime', startTime, ...
5151
'Columns', []);
5252
end
53-
53+
5454
% transfer content of extra fields to json content
5555
namesExtraColumns = returnNamesExtraColumns(logFile);
56-
56+
5757
for iExtraColumn = 1:numel(namesExtraColumns)
5858

5959
nbCol = returnNbColumns(logFile, namesExtraColumns{iExtraColumn});
@@ -62,7 +62,7 @@ function createDataDictionary(cfg, logFile)
6262

6363
headerName = returnHeaderName(namesExtraColumns{iExtraColumn}, nbCol, iCol);
6464

65-
if isfield(logFile,'isStim') && ~isempty(logFile.isStim) && logFile.isStim
65+
if isfield(logFile, 'isStim') && ~isempty(logFile.isStim) && logFile.isStim
6666
jsonContent.Columns{end + 1} = headerName;
6767
end
6868

src/saveEventsFile.m

Lines changed: 68 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
%
7474

7575
if nargin < 2
76-
error(['Missing arguments. Please specify <action input> ',...
76+
error(['Missing arguments. Please specify <action input> ', ...
7777
'and <cfg file> as the first two arguments']);
7878
end
7979

@@ -86,36 +86,35 @@
8686
case 'init'
8787

8888
% flag to indicate that this will be an _events file
89-
logFile(1).isStim = false;
89+
logFile(1).isStim = false;
9090

91-
if isfield(cfg,'fileName') && ...
92-
isfield(cfg.fileName,'events') && ...
91+
if isfield(cfg, 'fileName') && ...
92+
isfield(cfg.fileName, 'events') && ...
9393
~isempty(cfg.fileName.events)
9494
logFile(1).filename = cfg.fileName.events;
9595
else
96-
logFile(1).filename = '';
96+
logFile(1).filename = '';
9797
end
9898
logFile = initializeFile(logFile);
99-
99+
100100
case 'init_stim'
101101

102102
% flag to indicate that this will be an _stim file
103-
logFile(1).isStim = true;
104-
105-
if isfield(cfg,'fileName') && ...
106-
isfield(cfg.fileName,'stim') && ...
103+
logFile(1).isStim = true;
104+
105+
if isfield(cfg, 'fileName') && ...
106+
isfield(cfg.fileName, 'stim') && ...
107107
~isempty(cfg.fileName.stim)
108108
logFile(1).filename = cfg.fileName.stim;
109109
else
110-
logFile(1).filename = '';
110+
logFile(1).filename = '';
111111
end
112112
logFile = initializeStimFile(logFile);
113113

114114
case 'open'
115115

116116
logFile = openFile(cfg, logFile);
117117

118-
119118
case 'save'
120119

121120
checklLogFile('checkID', logFile);
@@ -178,32 +177,33 @@
178177
end
179178

180179
function logFile = initializeFile(logFile)
181-
% This function creates the bids field structure for json files for the
182-
% three basic bids event columns, and for all requested extra columns.
183-
%
184-
% Note that subfields (e.g. unit, levels etc. can be changed by the user
185-
% before calling openFile.
180+
% This function creates the bids field structure for json files for the
181+
% three basic bids event columns, and for all requested extra columns.
182+
%
183+
% Note that subfields (e.g. unit, levels etc. can be changed by the user
184+
% before calling openFile.
186185

187186
% initialize holy trinity (onset, trial_type, duration) columns
188187
logFile(1).columns = struct( ...
189-
'onset', struct( ...
190-
'Description', 'time elapsed since experiment start', ...
191-
'Units', 's'), ...
192-
'trial_type', struct( ...
193-
'Description', 'types of trial', ...
194-
'Levels', ''), ...
195-
'duration', struct( ...
196-
'Description', 'duration of the event or the block', ...
197-
'Units', 's') ...
198-
);
199-
188+
'onset', struct( ...
189+
'Description', ...
190+
'time elapsed since experiment start', ...
191+
'Units', 's'), ...
192+
'trial_type', struct( ...
193+
'Description', 'types of trial', ...
194+
'Levels', ''), ...
195+
'duration', struct( ...
196+
'Description', ...
197+
'duration of the event or the block', ...
198+
'Units', 's') ...
199+
);
200200

201201
logFile = initializeExtraColumns(logFile);
202202

203203
end
204204

205205
function logFile = initializeStimFile(logFile)
206-
206+
207207
logFile = initializeExtraColumns(logFile);
208208

209209
end
@@ -231,10 +231,10 @@
231231
% next line so we start printing at the right place
232232
fprintf(logFile(1).fileID, '\n');
233233
fprintf(1, '\n');
234-
234+
235235
elseif logFile(1).isStim
236236
% don't print column headers for _stim.tsv
237-
237+
238238
end
239239

240240
end
@@ -266,7 +266,7 @@ function printHeaderExtraColumns(logFile)
266266
% if the field we are looking for does not exist or is empty in the
267267
% action logFile structure we will write a n/a
268268
% otherwise we write its content
269-
269+
270270
namesExtraColumns = returnNamesExtraColumns(logFile);
271271

272272
for iExtraColumn = 1:numel(namesExtraColumns)
@@ -294,7 +294,7 @@ function printHeaderExtraColumns(logFile)
294294

295295
elseif ~ischar(data) && all(isnan(data))
296296
warning('Missing %s data for this event.', namesExtraColumns{iExtraColumn});
297-
297+
298298
if cfg.verbose > 1
299299
disp(logFile(iEvent));
300300
end
@@ -344,86 +344,85 @@ function printHeaderExtraColumns(logFile)
344344

345345
function logFile = saveToLogFile(logFile, cfg)
346346

347-
348347
% appends to the logfile all the data stored in the structure
349348
% first with the standard BIDS data and then any extra things
350349
for iEvent = 1:size(logFile, 1)
351350

352351
logFile = checklLogFile('fields', logFile, iEvent, cfg);
353352

354353
% check if this event should be skipped
355-
skipEvent = false;
356-
357-
% if this is _events file, we skip events with onset or duration
358-
% that are empty, nan or char.
354+
skipEvent = false;
355+
356+
% if this is _events file, we skip events with onset or duration
357+
% that are empty, nan or char.
359358
if ~logFile(1).isStim
360-
359+
361360
onset = logFile(iEvent).onset;
362361
duration = logFile(iEvent).duration;
363362
trial_type = logFile(iEvent).trial_type;
364363

365364
if any(cell2mat(cellfun(@isnan, {onset duration}, 'UniformOutput', false))) || ...
366365
any(cellfun(@ischar, {onset duration})) || ...
367-
any(isempty({onset duration}))
366+
any(isempty({onset duration}))
368367

369-
skipEvent = true;
368+
skipEvent = true;
370369

371-
warningMessageID = 'saveEventsFile:emptyEvent';
370+
warningMessageID = 'saveEventsFile:emptyEvent';
372371
warningMessage = sprintf(['Skipping saving this event. \n '...
373372
'onset: %s \n duration: %s \n'], ...
374373
onset, ...
375374
duration);
376375
end
377-
378-
% if this is _stim file, we skip missing events (i.e. events where
379-
% all extra columns have NO values)
376+
377+
% if this is _stim file, we skip missing events (i.e. events where
378+
% all extra columns have NO values)
380379
elseif logFile(1).isStim
381-
380+
382381
namesExtraColumns = returnNamesExtraColumns(logFile);
383-
isValid = ones(1,numel(namesExtraColumns));
382+
isValid = ones(1, numel(namesExtraColumns));
384383
for iExtraColumn = 1:numel(namesExtraColumns)
385-
data = logFile(iEvent).(namesExtraColumns{iExtraColumn});
386-
if isempty(data) || isnan(data) || ( ischar(data) && strcmp(data,'n/a') )
387-
isValid(iExtraColumn) = 0;
384+
data = logFile(iEvent).(namesExtraColumns{iExtraColumn});
385+
if isempty(data) || isnan(data) || (ischar(data) && strcmp(data, 'n/a'))
386+
isValid(iExtraColumn) = 0;
388387
end
389388
end
390-
if all(~isValid)
391-
skipEvent = true;
392-
393-
warningMessageID = 'saveEventsFile:emptyEvent';
389+
if all(~isValid)
390+
skipEvent = true;
391+
392+
warningMessageID = 'saveEventsFile:emptyEvent';
394393
warningMessage = sprintf(['Skipping saving this event. \n', ...
395-
'No values defined. \n']);
396-
elseif any(~isValid)
397-
skipEvent = false;
398-
399-
warningMessageID = 'saveEventsFile:missingData';
394+
'No values defined. \n']);
395+
elseif any(~isValid)
396+
skipEvent = false;
397+
398+
warningMessageID = 'saveEventsFile:missingData';
400399
warningMessage = sprintf('Missing some %s data for this event. \n', ...
401-
namesExtraColumns{find(isValid)});
400+
namesExtraColumns{find(isValid)});
402401
end
403402
end
404-
403+
405404
% now save the event to log file (if not skipping)
406-
if skipEvent
407-
408-
warning(warningMessageID, warningMessage);
409-
405+
if skipEvent
406+
407+
warning(warningMessageID, warningMessage);
408+
410409
else
411-
410+
412411
if ~logFile(1).isStim
413-
412+
414413
printData(logFile(1).fileID, onset, cfg);
415414
printData(logFile(1).fileID, duration, cfg);
416415
printData(logFile(1).fileID, trial_type, cfg);
417416

418417
end
419-
418+
420419
printExtraColumns(logFile, iEvent, cfg);
421420

422421
fprintf(logFile(1).fileID, '\n');
423422
fprintf(1, '\n');
424423

425424
end
426-
425+
427426
end
428427

429428
end

src/utils/utilsForTests/setUp.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
cfg.task.name = 'testtask';
1111

1212
cfg.testingDevice = 'mri';
13-
13+
1414
cfg = createFilename(cfg);
1515

16-
logFile.extraColumns = {'Speed','LHL24','is_Fixation'};
17-
16+
logFile.extraColumns = {'Speed', 'LHL24', 'is_Fixation'};
17+
1818
logFile = saveEventsFile('init', cfg, logFile);
1919

2020
logFile.extraColumns.Speed.length = 1;

tests/test_createDataDictionary.m

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ function test_createDataDictionaryBasic()
2525

2626
cfg = createFilename(cfg);
2727

28-
logFile.extraColumns = {'Speed','LHL24'};
29-
28+
logFile.extraColumns = {'Speed', 'LHL24'};
29+
3030
logFile = saveEventsFile('init', cfg, logFile);
3131

3232
logFile.extraColumns.Speed.length = 1;
@@ -59,9 +59,9 @@ function test_createDataDictionaryBasic()
5959
% data to test against
6060
expectedStruct = bids.util.jsondecode( ...
6161
fullfile( ...
62-
pwd, ...
63-
'testData', ...
64-
'eventsDataDictionary.json'));
62+
pwd, ...
63+
'testData', ...
64+
'eventsDataDictionary.json'));
6565

6666
% test
6767
assertTrue(isequal(expectedStruct, actualStruct));
@@ -87,8 +87,8 @@ function test_createDataDictionaryStim()
8787

8888
cfg = createFilename(cfg);
8989

90-
stimLogFile.extraColumns = {'Speed','LHL24','is_Fixation'};
91-
90+
stimLogFile.extraColumns = {'Speed', 'LHL24', 'is_Fixation'};
91+
9292
stimLogFile = saveEventsFile('init_stim', cfg, stimLogFile);
9393

9494
stimLogFile.extraColumns.Speed.length = 1;
@@ -119,15 +119,15 @@ function test_createDataDictionaryStim()
119119
% jsondecode:27 (/github/workspace/lib/bids-matlab/+bids/+util/jsondecode.m)
120120
% test_createDataDictionary>test_createDataDictionaryBasic:48
121121
% (/github/workspace/tests/test_createDataDictionary.m)
122-
122+
123123
actualStruct = bids.util.jsondecode(fullfile(funcDir, jsonFilename));
124124

125125
% data to test against
126126
expectedStruct = bids.util.jsondecode( ...
127127
fullfile( ...
128-
pwd, ...
129-
'testData', ...
130-
'stimDataDictionary.json'));
128+
pwd, ...
129+
'testData', ...
130+
'stimDataDictionary.json'));
131131

132132
% test
133133
assertTrue(isequal(expectedStruct, actualStruct));

tests/test_createQuestionList.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function test_createQuestionListBasic()
2323

2424
end
2525

26-
2726
function test_createQuestionListRestricted()
2827

2928
%% set up

0 commit comments

Comments
 (0)