Skip to content

Commit 334da37

Browse files
committed
synch with CPP BIDS and refactor
1 parent ce6de21 commit 334da37

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

initPTB.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
% window size info
7373
[cfg.winWidth, cfg.winHeight] = WindowSize(cfg.win);
7474

75-
if strcmpi(cfg.stimPosition, 'scanner')
75+
if strcmpi(cfg.stimPosition, 'mri')
7676
cfg.winRect(1, 4) = cfg.winRect(1, 4) * 2 / 3;
7777
end
7878

setDefaultsPTB.m

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,36 @@
4646

4747
end
4848

49-
if isfield(cfg, 'testingDevice') && strcmpi(cfg.testingDevice, 'scanner')
49+
if isfield(cfg, 'testingDevice') && strcmpi(cfg.testingDevice, 'mri')
5050
fieldsToSet.MRI.repetitionTime = [];
5151
end
5252

53-
%% set the defaults
54-
% loop through the defaults and set them in cfg if they don't exist
53+
cfg = setDefaults(cfg, fieldsToSet);
54+
55+
% sort fields alphabetically
56+
cfg = orderfields(cfg);
57+
58+
end
59+
60+
function structure = setDefaults(structure, fieldsToSet)
61+
% loop through the defaults fiels to set and update if they don't exist
62+
5563
names = fieldnames(fieldsToSet);
5664

5765
for i = 1:numel(names)
58-
cfg = setFieldToIfNotPresent( ...
59-
cfg, ...
66+
67+
thisField = fieldsToSet.(names{i});
68+
structure = setFieldToIfNotPresent( ...
69+
structure, ...
6070
names{i}, ...
61-
getfield(fieldsToSet, names{i})); %#ok<GFLD>
62-
end
71+
thisField);
6372

64-
%% sort fields alphabetically
65-
cfg = orderfields(cfg);
73+
end
6674

6775
end
6876

69-
function struct = setFieldToIfNotPresent(struct, fieldName, value)
70-
if ~isfield(struct, fieldName)
71-
struct = setfield(struct, fieldName, value); %#ok<SFLD>
77+
function structure = setFieldToIfNotPresent(structure, fieldName, value)
78+
if ~isfield(structure, fieldName)
79+
structure.(fieldName) = value;
7280
end
7381
end

waitForTrigger.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function waitForTrigger(cfg, deviceNumber)
2323

2424
triggerCounter = 0;
2525

26-
if strcmpi(cfg.testingDevice, 'scanner')
26+
if strcmpi(cfg.testingDevice, 'mri')
2727

2828
msg = 'Waiting for trigger';
2929
talkToMe(cfg, msg);

0 commit comments

Comments
 (0)