1- function [expParameters , cfg ] = checkCFG(cfg , expParameters )
2- % check that we have all the fields that we need in the experiment
3- % parameters
1+ function [cfg , expParameters ] = checkCFG(cfg , expParameters )
2+ % check that we have all the fields that we need in the experiment parameters
43
5- if ~isfield(expParameters , ' verbose' ) || isempty(expParameters .verbose )
6- expParameters.verbose = 0 ;
7- end
8-
9- if ~isfield(expParameters , ' outputDir' )
10- expParameters.outputDir = fullfile( ...
4+ %% set the expParameters defaults
5+
6+ fieldsToSet.verbose = 0 ;
7+ fieldsToSet.outputDir = fullfile( ...
118 fileparts(mfilename(' fullpath' )), ...
129 ' ..' , ...
1310 ' output' );
14- end
15-
16- % 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-
25- fields2Check = { ...
26- ' ce' , ...
27- ' dir' , ...
28- ' rec' , ...
29- ' echo' , ...
30- ' acq' , ...
31- ' subjectGrp' , ...
32- ' sessionNb' };
3311
34- for iField = 1 : numel(fields2Check )
35- if ~isfield(expParameters , fields2Check{iField })
36- expParameters = setfield(expParameters , fields2Check{iField }, []); % #ok<SFLD>
37- end
12+ fieldsToSet.subjectGrp = []; % in case no group was provided
13+ fieldsToSet.sessionNb = []; % in case no session was provided
14+ fieldsToSet.askGrpSess = [true true ];
15+
16+ % BIDS
17+
18+ % dataset description json
19+ % required
20+ fieldsToSet.bids.datasetDescription.json.Name = ' ' ;
21+ fieldsToSet.bids.datasetDescription.json.BIDSVersion = ' ' ;
22+ % recommended
23+ fieldsToSet.bids.datasetDescription.json.License = ' ' ;
24+ fieldsToSet.bids.datasetDescription.json.Authors = {' ' };
25+ fieldsToSet.bids.datasetDescription.json.Acknowledgements = ' ' ;
26+ fieldsToSet.bids.datasetDescription.json.HowToAcknowledge = ' ' ;
27+ fieldsToSet.bids.datasetDescription.json.Funding = {' ' };
28+ fieldsToSet.bids.datasetDescription.json.ReferencesAndLinks = {' ' };
29+ fieldsToSet.bids.datasetDescription.json.DatasetDOI = ' ' ;
30+
31+ % mri
32+ % for json
33+ fieldsToSet.MRI.repetitionTime = [];
34+ % for file naming
35+ fieldsToSet.MRI.ce = [];
36+ fieldsToSet.MRI.dir = []; % phase encoding direction of acquisition for fMRI
37+ fieldsToSet.MRI.rec = []; % reconstruction of fMRI images
38+ fieldsToSet.MRI.echo = []; % echo fMRI images
39+ fieldsToSet.MRI.acq = []; % acquisition of fMRI images
40+
41+ %% loop through the defaults and set them in expParameters if they don't exist
42+ names = fieldnames(fieldsToSet );
43+
44+ for i = 1 : numel(names )
45+ expParameters = setFieldToIfNotPresent(...
46+ expParameters , ...
47+ names{i }, ...
48+ getfield(fieldsToSet , names{i })); % #ok<GFLD>
49+ end
50+
51+ %% set the cfg defaults
52+
53+ clear fieldsToSet
54+ fieldsToSet.testingDevice = ' pc' ;
55+ fieldsToSet.eyeTracker = false ;
56+
57+ % loop through the defaults and set them in cfg if they don't exist
58+ names = fieldnames(fieldsToSet );
59+
60+ for i = 1 : numel(names )
61+ cfg = setFieldToIfNotPresent(...
62+ cfg , ...
63+ names{i }, ...
64+ getfield(fieldsToSet , names{i })); % #ok<GFLD>
3865 end
3966
40- % set false value for a series of field if they have not been specified
41- fields2CheckFalse = { ...
42- ' eyeTracker'
43- };
67+ end
4468
45- for iField = 1 : numel(fields2CheckFalse )
46- if ~isfield(cfg , fields2CheckFalse{iField })
47- cfg = setfield(cfg , fields2CheckFalse{iField }, false ); % #ok<SFLD>
48- end
49- end
5069
51- % other defaults
52- if ~isfield(expParameters , ' askGrpSess ' )
53- expParameters.askGrpSess = [ true true ];
70+ function struct = setFieldToIfNotPresent( struct , fieldName , value )
71+ if ~isfield(struct , fieldName )
72+ struct = setfield( struct , fieldName , value ); % #ok<SFLD>
5473 end
55-
56- end
74+ end
0 commit comments