Skip to content

Commit 8a70b93

Browse files
committed
mh autofix
1 parent d67f828 commit 8a70b93

14 files changed

+137
-138
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
function cfg = askForGroupAndOrSession(cfg)
2-
2+
33
askGrpSess = [true true];
4-
4+
55
if isfield(cfg, 'subject') && ...
66
isfield(cfg.subject, 'askGrpSess') && ...
77
~isempty(cfg.subject.askGrpSess)
88

99
askGrpSess = cfg.subject.askGrpSess;
1010

1111
end
12-
12+
1313
if numel(askGrpSess) < 2
1414
askGrpSess(2) = 1;
1515
end
16-
16+
1717
cfg.subject.askGrpSess = askGrpSess;
18-
19-
end
18+
19+
end

src/subfun/askUserCli.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
%
44
% command line interface to ask questions to user
55
%
6-
6+
77
for iQuestion = 1:size(questions.questionsToAsk, 1)
8-
9-
if ~isempty(questions.questionsToAsk{iQuestion,1})
10-
8+
9+
if ~isempty(questions.questionsToAsk{iQuestion, 1})
10+
1111
thisResponse = ...
12-
input(['\n' questions.questionsToAsk{iQuestion,1}], 's'); %#ok<*AGROW>
13-
14-
if questions.questionsToAsk{iQuestion,2}
12+
input(['\n' questions.questionsToAsk{iQuestion, 1}], 's'); %#ok<*AGROW>
13+
14+
if questions.questionsToAsk{iQuestion, 2}
1515
thisResponse = checkInput(thisResponse, questions);
1616
end
17-
17+
1818
responses{iQuestion, 1} = thisResponse;
19-
19+
2020
end
21-
21+
2222
end
23-
23+
2424
end
2525

2626
function input2check = checkInput(input2check, questions)
@@ -29,5 +29,5 @@
2929
while ~isPositiveInteger(input2check)
3030
input2check = str2double(input(questions.mustBePositiveInteger, 's'));
3131
end
32-
32+
3333
end

src/subfun/askUserGui.m

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
function responses = askUserGui(questions, responses)
2-
2+
33
% boolean for which question should be asked
4-
isQuestionToAsk = ~cellfun('isempty', questions.questionsToAsk(:,1));
5-
4+
isQuestionToAsk = ~cellfun('isempty', questions.questionsToAsk(:, 1));
5+
66
responses = cellstr(string(responses(isQuestionToAsk)));
7-
7+
88
responses = askQuestionsGui(questions, responses, isQuestionToAsk);
9-
9+
1010
% keep asking the question till we get a positive integer value for each
1111
for iQuestion = 1:size(questions.questionsToAsk)
12-
questions.questionsToAsk{iQuestion} = sprintf('%s %s\n %s',...
12+
questions.questionsToAsk{iQuestion} = sprintf('%s %s\n %s', ...
1313
'\color{red}', ...
1414
questions.questionsToAsk{iQuestion}, ...
1515
questions.mustBePositiveInteger);
1616
end
17-
18-
while 1
17+
18+
while 1
1919
isQuestionToAsk = getIsQuestionToAsk(questions, responses);
2020
if all(~isQuestionToAsk)
2121
break
2222
end
2323
responses = askQuestionsGui(questions, responses, isQuestionToAsk);
2424
end
25-
25+
2626
end
2727

2828
function resp = askQuestionsGui(quest, resp, isQuestionToAsk)
29-
29+
3030
opts.Interpreter = 'tex';
31-
31+
3232
fieldDim = repmat([1 50], sum(isQuestionToAsk), 1);
33-
34-
currentResp = inputdlg(quest.questionsToAsk(isQuestionToAsk, 1),...
33+
34+
currentResp = inputdlg(quest.questionsToAsk(isQuestionToAsk, 1), ...
3535
'Subject info', ...
3636
fieldDim, ...
3737
resp(isQuestionToAsk), ...
3838
opts);
39-
39+
4040
resp(isQuestionToAsk) = currentResp;
41-
42-
end
4341

42+
end

src/subfun/createQuestionList.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
function questions = createQuestionList(cfg)
2-
2+
33
cfg = askForGroupAndOrSession(cfg);
4-
4+
55
questions.group = 'Enter subject group (leave empty if none): ';
66
questions.subject = 'Enter subject number (1-999): ';
77
questions.session = 'Enter the session number (i.e day ; 1-999): ';
88
questions.run = 'Enter the run number (1-999): ';
99
questions.mustBePositiveInteger = 'Please enter a positive integer: ';
1010
% questions.questionsToAsk is a cell array : second column is a boolean
1111
% set to true if we must run inputCheck on the response
12-
questions.questionsToAsk = cell(4,2);
13-
12+
questions.questionsToAsk = cell(4, 2);
13+
1414
% subject group
1515
if cfg.subject.askGrpSess(1)
1616
questions.questionsToAsk{1, 1} = questions.group;
1717
questions.questionsToAsk{1, 2} = false;
1818
end
19-
19+
2020
% the subject number
2121
questions.questionsToAsk{2, 1} = questions.subject;
2222
questions.questionsToAsk{2, 2} = true;
23-
23+
2424
% the session number
2525
if cfg.subject.askGrpSess(2)
2626
questions.questionsToAsk{3, 1} = questions.session;
2727
questions.questionsToAsk{3, 2} = true;
2828
end
29-
29+
3030
% the run number
3131
questions.questionsToAsk{4, 1} = questions.run;
3232
questions.questionsToAsk{4, 2} = true;
33-
34-
end
33+
34+
end

src/subfun/getIsQuestionToAsk.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function isQuestionToAsk = getIsQuestionToAsk(questions, responses)
22

3-
isQuestionToAsk = cell2mat(questions.questionsToAsk(:,2));
3+
isQuestionToAsk = cell2mat(questions.questionsToAsk(:, 2));
44
for j = 1:size(isQuestionToAsk, 1)
55
input2check = str2double(responses{j});
6-
isQuestionToAsk(j,2) = ~isPositiveInteger(input2check);
6+
isQuestionToAsk(j, 2) = ~isPositiveInteger(input2check);
77
end
88
isQuestionToAsk = all(isQuestionToAsk, 2);
9-
10-
end
9+
10+
end

src/subfun/isPositiveInteger.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
%
44
% works on column vector of values
55
%
6-
7-
trueOrFalse = ~any( [ ...
6+
7+
trueOrFalse = ~any([ ...
88
~isnumeric(input2check), ...
99
isnan(input2check), ...
1010
fix(input2check) ~= input2check, ...
1111
input2check < 0 ...
1212
]);
13-
14-
end
13+
14+
end

src/subfun/setDefaultResponses.m

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
function [cfg, responses] = setDefaultResponses(cfg)
2-
2+
33
if nargin < 1
44
cfg = struct('debug', []);
55
end
6-
6+
77
if ~isfield(cfg, 'debug') || isempty(cfg.debug)
88
cfg.debug.do = false;
99
end
10-
11-
responses{1,1} = ''; % subjectGrp
12-
responses{2,1} = ''; % subjectNb
13-
responses{3,1} = 1; % session
14-
responses{4,1} = ''; % run
15-
10+
11+
responses{1, 1} = ''; % subjectGrp
12+
responses{2, 1} = ''; % subjectNb
13+
responses{3, 1} = 1; % session
14+
responses{4, 1} = ''; % run
15+
1616
if cfg.debug.do
17-
18-
responses{1,1} = 'ctrl';
19-
responses{2,1} = 666;
20-
responses{3,1} = 666;
21-
responses{4,1} = 666;
22-
17+
18+
responses{1, 1} = 'ctrl';
19+
responses{2, 1} = 666;
20+
responses{3, 1} = 666;
21+
responses{4, 1} = 666;
22+
2323
end
24-
25-
end
24+
25+
end

src/userInputs.m

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@
99
% - the first value set to false will skip asking for the participants
1010
% group
1111
% - the second value set to false will skip asking for the session
12-
12+
1313
if nargin < 1
1414
cfg = struct('debug', []);
1515
end
16-
16+
1717
[cfg, responses] = setDefaultResponses(cfg);
18-
18+
1919
if ~cfg.debug.do
20-
20+
2121
questions = createQuestionList(cfg);
22-
23-
% try
24-
responses = askUserGui(questions, responses);
25-
% catch
26-
% responses = askUserCli(questions, responses);
27-
% end
28-
22+
23+
% try
24+
responses = askUserGui(questions, responses);
25+
% catch
26+
% responses = askUserCli(questions, responses);
27+
% end
28+
2929
end
30-
31-
cfg.subject.subjectGrp = responses{1,1};
32-
cfg.subject.subjectNb = responses{2,1};
33-
cfg.subject.sessionNb = responses{3,1};
34-
cfg.subject.runNb = responses{4,1};
35-
36-
end
30+
31+
cfg.subject.subjectGrp = responses{1, 1};
32+
cfg.subject.subjectNb = responses{2, 1};
33+
cfg.subject.sessionNb = responses{3, 1};
34+
cfg.subject.runNb = responses{4, 1};
35+
36+
end

tests/test_askForGroupAndOrSession.m

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,42 @@ function test_askForGroupAndOrSessionBasic()
1111
%% set up
1212
cfg = struct();
1313
cfg = askForGroupAndOrSession(cfg);
14-
14+
1515
expectedStructure = struct('subject', struct('askGrpSess', [true true]));
16-
17-
assertEqual(expectedStructure, cfg)
18-
16+
17+
assertEqual(expectedStructure, cfg);
18+
1919
end
2020

2121
function test_askForGroupAndOrSessionNoGroup()
2222

2323
cfg.subject.askGrpSess = 0;
2424
cfg = askForGroupAndOrSession(cfg);
25-
25+
2626
expectedStructure = struct('subject', struct('askGrpSess', [false true]));
27-
28-
assertEqual(expectedStructure, cfg)
29-
27+
28+
assertEqual(expectedStructure, cfg);
29+
3030
end
3131

3232
function test_askForGroupAndOrSessionNoGroupNoSession()
3333

3434
cfg.subject.askGrpSess = [0 0];
3535
cfg = askForGroupAndOrSession(cfg);
36-
36+
3737
expectedStructure = struct('subject', struct('askGrpSess', [false false]));
38-
39-
assertEqual(expectedStructure, cfg)
40-
38+
39+
assertEqual(expectedStructure, cfg);
40+
4141
end
4242

4343
function test_askForGroupAndOrSessionNoSession()
4444

4545
cfg.subject.askGrpSess = [1 0];
4646
cfg = askForGroupAndOrSession(cfg);
47-
47+
4848
expectedStructure = struct('subject', struct('askGrpSess', [true false]));
49-
50-
assertEqual(expectedStructure, cfg)
51-
52-
end
49+
50+
assertEqual(expectedStructure, cfg);
51+
52+
end

tests/test_createBoldJson.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ function test_createBoldJsonBasic()
3838
%% test
3939
assertTrue(exist(fullfile(funcDir, eventFilename), 'file') == 2);
4040

41-
end
41+
end

0 commit comments

Comments
 (0)