Skip to content

Commit 3102f65

Browse files
committed
MH autofix
1 parent 3f55efd commit 3102f65

File tree

6 files changed

+59
-57
lines changed

6 files changed

+59
-57
lines changed

tests/manualTests/test_makeRawDataset.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function testmanual_makeRawDataset()
1+
function test_makeRawDataset()
22

33
fprintf('\n\n--------------------------------------------------------------------\n\n');
44

tests/manualTests/test_userInput.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
clear
2-
clc
1+
clear;
2+
clc;
33

44
%%
5-
fprintf('Debug\n')
5+
fprintf('Debug\n');
66
cfg.debug = true;
77

88
cfg = userInputs(cfg);
99
disp(cfg.subject);
1010

1111
%%
12-
fprintf('No Group\n')
12+
fprintf('No Group\n');
1313
cfg.debug = false;
1414
cfg.subject.askGrpSess = 0;
1515

1616
cfg = userInputs(cfg);
1717
disp(cfg.subject);
1818

1919
%%
20-
fprintf('No Group or session\n')
20+
fprintf('No Group or session\n');
2121
cfg.debug = false;
2222
cfg.subject.askGrpSess = [0 0];
2323

2424
cfg = userInputs(cfg);
2525
disp(cfg.subject);
2626

2727
%%
28-
fprintf('No session\n')
28+
fprintf('No session\n');
2929
cfg.debug = false;
3030
cfg.subject.askGrpSess = [1 0];
3131

3232
cfg = userInputs(cfg);
3333
disp(cfg.subject);
3434

3535
%%
36-
fprintf('Default\n')
36+
fprintf('Default\n');
3737
cfg.debug = false;
3838
cfg.subject.askGrpSess = [];
3939

tests/test_saveEventsFileOpen.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function test_saveEventsFileOpen()
3333

3434
% check that the file has the right path and name
3535
assert(exist(fullfile(funcDir, eventFilename), 'file') == 2);
36-
36+
3737
FID = fopen(fullfile(funcDir, eventFilename), 'r');
3838
C = textscan(FID, repmat('%s', 1, 3), 'Delimiter', '\t', 'EndOfLine', '\n');
3939

@@ -76,7 +76,7 @@ function test_saveEventsFileOpen()
7676
% open the file
7777
funcDir = fullfile(cfg.dir.outputSubject, cfg.fileName.modality);
7878
eventFilename = cfg.fileName.events;
79-
79+
8080
nbExtraCol = 2;
8181
FID = fopen(fullfile(funcDir, eventFilename), 'r');
8282
C = textscan(FID, repmat('%s', 1, nbExtraCol + 3), 'Delimiter', '\t', 'EndOfLine', '\n');
@@ -87,7 +87,5 @@ function test_saveEventsFileOpen()
8787
assert(isequal(C{3}{1}, 'trial_type'));
8888
assert(isequal(C{4}{1}, 'Speed'));
8989
assert(isequal(C{5}{1}, 'is_Fixation'));
90-
91-
9290

9391
end
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
function test_saveEventsFileOpenMultiColumn()
2-
2+
33
%% check header writing with several columns for one variable
44
clear;
5-
5+
66
outputDir = fullfile(fileparts(mfilename('fullpath')), '..', 'output');
7-
7+
88
%%% set up
9-
9+
1010
cfg.subject.subjectNb = 1;
1111
cfg.subject.runNb = 1;
1212
cfg.task.name = 'testtask';
1313
cfg.dir.output = outputDir;
14-
14+
1515
cfg.testingDevice = 'mri';
16-
16+
1717
cfg = createFilename(cfg);
18-
18+
1919
% define the extra columns: here we specify how many columns we want for
2020
% each variable
2121
logFile.extraColumns.Speed.length = 1; % will set 1 columns with name Speed
2222
logFile.extraColumns.LHL24.length = 12; % will set 12 columns with names LHL24-01, LHL24-02, ...
2323
logFile.extraColumns.is_Fixation = []; % will set 1 columns with name is_Fixation
24-
24+
2525
%%% do stuff
26-
26+
2727
% create the events file and header
2828
logFile = saveEventsFile('open', cfg, logFile);
29-
29+
3030
% close the file
3131
saveEventsFile('close', cfg, logFile);
32-
32+
3333
%%% test section
34-
34+
3535
% check the extra columns of the header and some of the content
3636
funcDir = fullfile(cfg.dir.outputSubject, cfg.fileName.modality);
3737
eventFilename = cfg.fileName.events;
38-
38+
3939
nbExtraCol = ...
4040
logFile(1).extraColumns.Speed.length + ...
4141
logFile(1).extraColumns.LHL24.length + ...
4242
logFile(1).extraColumns.is_Fixation.length;
43-
43+
4444
FID = fopen(fullfile(funcDir, eventFilename), 'r');
4545
C = textscan(FID, repmat('%s', 1, nbExtraCol + 3), 'Delimiter', '\t', 'EndOfLine', '\n');
46-
46+
4747
% check the extra columns of the header
4848
assert(isequal(C{4}{1}, 'Speed'));
4949
assert(isequal(C{5}{1}, 'LHL24_01'));
5050
assert(isequal(C{16}{1}, 'LHL24_12'));
5151
assert(isequal(C{17}{1}, 'is_Fixation'));
52-
52+
5353
end

tests/test_saveEventsFileSave.m

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
11
function test_saveEventsFileSave()
2-
2+
33
%% write things in it
44
clear;
5-
5+
66
outputDir = fullfile(fileparts(mfilename('fullpath')), '..', 'output');
7-
7+
88
%%% set up
9-
9+
1010
cfg.subject.subjectNb = 1;
1111
cfg.subject.runNb = 1;
1212
cfg.task.name = 'testtask';
1313
cfg.dir.output = outputDir;
14-
14+
1515
cfg.testingDevice = 'mri';
16-
16+
1717
cfg = createFilename(cfg);
18-
18+
1919
logFile.extraColumns.Speed.length = 1;
2020
logFile.extraColumns.LHL24.length = 12;
2121
logFile.extraColumns.is_Fixation.length = 1;
22-
22+
2323
% create the events file and header
2424
logFile = saveEventsFile('open', cfg, logFile);
25-
25+
2626
%%% do stuff
27-
27+
2828
% ROW 2: normal events : all info is there
2929
logFile(1, 1).onset = 2;
3030
logFile(end, 1).trial_type = 'motion_up';
3131
logFile(end, 1).duration = 3;
3232
logFile(end, 1).Speed = 2;
3333
logFile(end, 1).is_Fixation = true;
3434
logFile(end, 1).LHL24 = 1:12;
35-
35+
3636
logFile = saveEventsFile('save', cfg, logFile);
37-
37+
3838
% ROW 3: missing info (speed, LHL24)
3939
logFile(1, 1).onset = 3;
4040
logFile(end, 1).trial_type = 'static';
4141
logFile(end, 1).duration = 4;
4242
logFile(end, 1).is_Fixation = false;
43-
43+
4444
% ROW 4: missing info (duration is missing and speed is empty)
4545
logFile(2, 1).onset = 4;
4646
logFile(end, 1).trial_type = 'motion_up';
4747
logFile(end, 1).Speed = [];
4848
logFile(end, 1).is_Fixation = true;
4949
logFile(end, 1).LHL24 = 1:12;
50-
50+
5151
% empty events
5252
logFile(3, 1).onset = [];
5353
logFile(end, 1).trial_type = [];
5454
logFile(end, 1).duration = 3;
55-
55+
5656
logFile(4, 1).onset = 1;
5757
logFile(end, 1).trial_type = '';
58-
58+
5959
% ROW 5: missing info (array is too short)
6060
logFile(5, 1).onset = 5;
6161
logFile(end, 1).trial_type = 'jazz';
6262
logFile(end, 1).duration = 3;
6363
logFile(end, 1).LHL24 = rand(1, 10);
64-
64+
6565
% ROW 6: too much info (array is too long)
6666
% logFile(5, 1).onset = 5;
6767
% logFile(end, 1).trial_type = 'blues';
6868
% logFile(end, 1).duration = 3;
6969
% logFile(end, 1).LHL24 = rand(1, 15);
70-
70+
7171
saveEventsFile('save', cfg, logFile);
72-
72+
7373
% close the file
7474
saveEventsFile('close', cfg, logFile);
75-
75+
7676
%%% test section
77-
77+
7878
% check the extra columns of the header and some of the content
7979
nbExtraCol = ...
8080
logFile(1).extraColumns.Speed.length + ...
8181
logFile(1).extraColumns.LHL24.length + ...
8282
logFile(1).extraColumns.is_Fixation.length;
83-
83+
8484
funcDir = fullfile(cfg.dir.outputSubject, cfg.fileName.modality);
8585
eventFilename = cfg.fileName.events;
8686
FID = fopen(fullfile(funcDir, eventFilename), 'r');
8787
C = textscan(FID, repmat('%s', 1, nbExtraCol + 3), 'Delimiter', '\t', 'EndOfLine', '\n');
88-
88+
8989
% event 1/ ROW 2: check that values are entered correctly
9090
assert(isequal(C{1}{2}, sprintf('%f', 2)));
9191
assert(isequal(C{3}{2}, 'motion_up'));
@@ -94,22 +94,22 @@ function test_saveEventsFileSave()
9494
assert(isequal(C{5}{2}, sprintf('%f', 1)));
9595
assert(isequal(C{16}{2}, sprintf('%f', 12)));
9696
assert(isequal(C{17}{2}, 'true'));
97-
97+
9898
% event 2 / ROW 3: missing info replaced by nans
9999
assert(isequal(C{4}{3}, 'n/a'));
100100
assert(isequal(C{5}{3}, 'n/a'));
101101
assert(isequal(C{16}{3}, 'n/a'));
102102
assert(isequal(C{17}{3}, 'false'));
103-
103+
104104
% event 3 / ROW 4: missing info (duration is missing and speed is empty)
105105
assert(isequal(C{2}{4}, 'n/a'));
106106
assert(isequal(C{4}{4}, 'n/a'));
107-
107+
108108
% event 4-5 / ROW 5-6: skip empty events
109109
assert(~isequal(C{1}{5}, 'n/a'));
110-
110+
111111
% check values entered properly
112112
assert(isequal(C{15}{5}, 'n/a'));
113113
assert(isequal(C{16}{5}, 'n/a'));
114-
114+
115115
end

userInputs.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
end
1717

1818
askGrpSess = [true true];
19-
if isfield(cfg, 'subject') && isfield(cfg.subject, 'askGrpSess') && ~isempty(cfg.subject.askGrpSess)
19+
if isfield(cfg, 'subject') && ...
20+
isfield(cfg.subject, 'askGrpSess') && ...
21+
~isempty(cfg.subject.askGrpSess)
22+
2023
askGrpSess = cfg.subject.askGrpSess;
24+
2125
end
2226
if numel(askGrpSess) < 2
2327
askGrpSess(2) = 1;

0 commit comments

Comments
 (0)