Skip to content

Commit 35aa098

Browse files
committed
make groupa and session potentially optional
1 parent 9793199 commit 35aa098

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

checkCFG.m

+15-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,26 @@
1414
end
1515

1616
% set empty values for a series of field if they have not been specified
17+
% 'ce'
18+
% 'dir' For BIDS file naming: phase encoding direction of acquisition for fMRI
19+
% 'rec' For BIDS file naming: reconstruction of fMRI images
20+
% 'echo' For BIDS file naming: echo fMRI images
21+
% 'acq' For BIDS file naming: acquisition of fMRI images
22+
% 'subjectGrp' in case no group was provided
23+
% 'sessionNb' in case no session was provided
24+
1725
fields2Check = { ...
1826
'ce', ...
19-
'dir', ... % For BIDS file naming: phase encoding direction of acquisition for fMRI
20-
'rec', ... % For BIDS file naming: reconstruction of fMRI images
21-
'echo', ... % For BIDS file naming: echo fMRI images
22-
'acq' % For BIDS file naming: acquisition of fMRI images
23-
};
27+
'dir', ...
28+
'rec', ...
29+
'echo', ...
30+
'acq', ...
31+
'subjectGrp', ...
32+
'sessionNb'};
2433

2534
fields2CheckFalse = { ...
2635
'eyeTracker'
27-
}
36+
};
2837

2938
for iField = 1:numel(fields2Check)
3039
if ~isfield(expParameters, fields2Check{iField})

userInputs.m

+30-19
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,65 @@
1-
function [expParameters] = userInputs(cfg, expParameters)
1+
function [expParameters] = userInputs(cfg, expParameters, askGrpSess)
22
% Get subject, run and session number and make sure they are
33
% positive integer values
4+
%
5+
% skipGrpSess
6+
% a 1 X 2 array of booleans (default is [true true] ):
7+
% - the first value set to false will skip asking for the participants
8+
% group
9+
% - the second value set to false will skip asking for the session
410

511
if nargin<1
612
cfg.debug = false;
713
end
8-
914
if nargin<2
1015
expParameters = [];
1116
end
17+
if nargin<3
18+
askGrpSess = [true true];
19+
end
1220

1321

22+
% When in debug more this function returns some dummy values
1423
if cfg.debug
15-
1624
subjectGrp = 'ctrl';
1725
subjectNb = 666;
1826
runNb = 666;
1927
sessionNb = 666;
20-
28+
29+
% Otherwise it prompts the user for some information
2130
else
22-
23-
subjectGrp = lower(input('Enter subject group (leave empty if none): ', 's'));
24-
31+
32+
% subject group
33+
if askGrpSess(1)
34+
subjectGrp = lower(input('Enter subject group (leave empty if none): ', 's'));
35+
end
36+
37+
% the subject number
2538
subjectNb = str2double(input('Enter subject number (1-999): ', 's') );
2639
subjectNb = checkInput(subjectNb);
27-
28-
sessionNb = str2double(input('Enter the session (i.e day - 1-999)) number: ', 's'));
29-
sessionNb = checkInput(sessionNb);
30-
40+
41+
% the session number
42+
if askGrpSess(2)
43+
sessionNb = str2double(input('Enter the session (i.e day - 1-999)) number: ', 's'));
44+
sessionNb = checkInput(sessionNb);
45+
end
46+
47+
% the run number
3148
runNb = str2double(input('Enter the run number (1-999): ', 's'));
3249
runNb = checkInput(runNb);
33-
50+
3451
end
3552

36-
3753
expParameters.subjectGrp = subjectGrp;
3854
expParameters.subjectNb = subjectNb;
3955
expParameters.sessionNb = sessionNb;
4056
expParameters.runNb = runNb;
4157

42-
4358
end
4459

45-
4660
function input2check = checkInput(input2check)
47-
48-
61+
% this function checks the input to makes sure the user enters a positive integer
4962
while isnan(input2check) || fix(input2check) ~= input2check || input2check<0
5063
input2check = str2double(input('Please enter a positive integer: ', 's'));
5164
end
52-
53-
5465
end

0 commit comments

Comments
 (0)