Skip to content

Commit 20113fd

Browse files
authored
Merge pull request #21 from CerenB/master
checkCFG update
2 parents 4d1a4f4 + adc1cc3 commit 20113fd

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
*DS_Store
23

34
*.m~
@@ -6,3 +7,4 @@
67
# exclude content of logfiles folders
78
*.tsv
89
*.mat
10+

checkCFG.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function expParameters = checkCFG(expParameters)
1+
function [expParameters, cfg] = checkCFG(cfg,expParameters)
22
% check that we have all the fields that we need in the experiment
33
% parameters
44

@@ -22,11 +22,21 @@
2222
'acq' % For BIDS file naming: acquisition of fMRI images
2323
};
2424

25+
fields2CheckFalse = { ...
26+
'eyeTracker'
27+
}
28+
2529
for iField = 1:numel(fields2Check)
2630
if ~isfield(expParameters, fields2Check{iField})
2731
expParameters = setfield(expParameters, fields2Check{iField}, []); %#ok<SFLD>
2832
end
2933
end
3034

35+
for iField = 1:numel(fields2CheckFalse)
36+
if ~isfield(cfg, fields2CheckFalse{iField})
37+
cfg = setfield(cfg, fields2CheckFalse{iField}, false); %#ok<SFLD>
38+
end
39+
end
3140

32-
end
41+
42+
end

createFilename.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function expParameters = createFilename(expParameters, cfg)
1+
function expParameters = createFilename(cfg,expParameters)
22
% create the BIDS compliant directories and filenames for the behavioral output for this subject /
33
% session / run using the information from cfg and expParameters.
44
% Will also create the right filename for the eyetracking data file.
@@ -30,7 +30,7 @@
3030
dateFormat = 'yyyymmdd_HHMM';
3131

3232
% Setting some defaults: no need to change things here
33-
expParameters = checkCFG(expParameters);
33+
[expParameters, cfg] = checkCFG(cfg,expParameters);
3434

3535
% extract input
3636
subjectGrp = expParameters.subjectGrp;
@@ -92,7 +92,7 @@
9292
[~, ~, ~] = mkdir(expParameters.outputDir);
9393
[~, ~, ~] = mkdir(fullfile(expParameters.outputDir, modality));
9494

95-
if cfg.eyeTracker
95+
if isfield(cfg,'eyeTracker')
9696
[~, ~, ~] = mkdir(fullfile(expParameters.outputDir, 'eyetracker'));
9797
end
9898

@@ -127,8 +127,8 @@
127127

128128
end
129129

130+
130131
if cfg.eyeTracker
131-
132132
expParameters.fileName.eyetracker = ...
133133
[expParameters.fileName.base, expParameters.acqSuffix, ...
134134
runSuffix, '_eyetrack_date-' expParameters.date '.edf'];

tests/test_createFilename.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function test_createFilename()
1414
cfg.eyeTracker = true;
1515
cfg.device = 'PC';
1616

17-
expParameters = checkCFG(expParameters);
18-
expParameters = createFilename(expParameters, cfg);
17+
expParameters = checkCFG(cfg,expParameters);
18+
expParameters = createFilename(cfg,expParameters);
1919

2020
outputDir = fullfile(pwd, ...
2121
'..', '..', ...
@@ -49,8 +49,8 @@ function test_createFilename()
4949
cfg.eyeTracker = false;
5050
cfg.device = 'scanner';
5151

52-
expParameters = checkCFG(expParameters);
53-
expParameters = createFilename(expParameters, cfg);
52+
expParameters = checkCFG(cfg,expParameters);
53+
expParameters = createFilename(cfg,expParameters);
5454

5555
outputDir = fullfile(pwd, ...
5656
'..', '..', ...

tests/test_saveEventsFile.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ function test_saveEventsFile()
1313
cfg.eyeTracker = false;
1414
cfg.device = 'scanner';
1515

16-
expParameters = checkCFG(expParameters);
17-
expParameters = createFilename(expParameters, cfg);
16+
expParameters = checkCFG(cfg,expParameters);
17+
expParameters = createFilename(cfg,expParameters);
1818

1919

2020

0 commit comments

Comments
 (0)