Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion initPTB.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
% window size info
[cfg.winWidth, cfg.winHeight] = WindowSize(cfg.win);

if strcmpi(cfg.stimPosition, 'scanner')
if strcmpi(cfg.stimPosition, 'mri')
cfg.winRect(1, 4) = cfg.winRect(1, 4) * 2 / 3;
end

Expand Down
32 changes: 20 additions & 12 deletions setDefaultsPTB.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,36 @@

end

if isfield(cfg, 'testingDevice') && strcmpi(cfg.testingDevice, 'scanner')
if isfield(cfg, 'testingDevice') && strcmpi(cfg.testingDevice, 'mri')
fieldsToSet.MRI.repetitionTime = [];
end

%% set the defaults
% loop through the defaults and set them in cfg if they don't exist
cfg = setDefaults(cfg, fieldsToSet);

% sort fields alphabetically
cfg = orderfields(cfg);

end

function structure = setDefaults(structure, fieldsToSet)
% loop through the defaults fiels to set and update if they don't exist

names = fieldnames(fieldsToSet);

for i = 1:numel(names)
cfg = setFieldToIfNotPresent( ...
cfg, ...

thisField = fieldsToSet.(names{i});
structure = setFieldToIfNotPresent( ...
structure, ...
names{i}, ...
getfield(fieldsToSet, names{i})); %#ok<GFLD>
end
thisField);

%% sort fields alphabetically
cfg = orderfields(cfg);
end

end

function struct = setFieldToIfNotPresent(struct, fieldName, value)
if ~isfield(struct, fieldName)
struct = setfield(struct, fieldName, value); %#ok<SFLD>
function structure = setFieldToIfNotPresent(structure, fieldName, value)
if ~isfield(structure, fieldName)
structure.(fieldName) = value;
end
end
2 changes: 1 addition & 1 deletion waitForTrigger.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function waitForTrigger(cfg, deviceNumber)

triggerCounter = 0;

if strcmpi(cfg.testingDevice, 'scanner')
if strcmpi(cfg.testingDevice, 'mri')

msg = 'Waiting for trigger';
talkToMe(cfg, msg);
Expand Down