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
5 changes: 2 additions & 3 deletions initEnv.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
% If external dir is empty throw an exception
% and ask user to update submodules.
libDirectory = fullfile(fileparts(mfilename('fullpath')), 'lib');

if numel(dir(libDirectory)) <= 2 % Means that the external is empty
error(['Git submodules are not cloned!', ...
'Try this in your terminal:', ...
Expand Down Expand Up @@ -89,8 +89,7 @@ function addDependencies()

pth = fileparts(mfilename('fullpath'));
addpath(genpath(fullfile(pth, 'lib', 'CPP_BIDS', 'src')));
addpath(fullfile(pth, 'lib', 'CPP_PTB'));
% addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src')));
addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src')));
addpath(fullfile(pth, 'subfun'));

end
28 changes: 24 additions & 4 deletions setParameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
%% Engine parameters

cfg.testingDevice = 'mri';
cfg.eyeTracker.do = true;
cfg.eyeTracker.do = false;
cfg.audio.do = false;

cfg = setMonitor(cfg);
Expand All @@ -32,6 +32,8 @@
% MRI settings
cfg = setMRI(cfg);

cfg.pacedByTriggers.do = true;

%% Experiment Design

% cfg.design.motionType = 'translation';
Expand All @@ -49,6 +51,8 @@
% IBI
% block length = (cfg.eventDuration + cfg.ISI) * cfg.design.nbEventsPerBlock

cfg.timing.eventDuration = 0.850; % second

% Time between blocs in secs
cfg.timing.IBI = 1.8;
% Time between events in secs
Expand All @@ -58,7 +62,23 @@
% Number of seconds after the end all the stimuli before ending the run
cfg.timing.endDelay = 3.6;

cfg.timing.eventDuration = 0.9; % second
% reexpress those in terms of repetition time
if cfg.pacedByTriggers.do

cfg.pacedByTriggers.quietMode = true;
cfg.pacedByTriggers.nbTriggers = 1;

cfg.timing.eventDuration = cfg.mri.repetitionTime / 2 - 0.04; % second

% Time between blocs in secs
cfg.timing.IBI = 1;
% Time between events in secs
cfg.timing.ISI = 0;
% Number of seconds before the motion stimuli are presented
cfg.timing.onsetDelay = 0;
% Number of seconds after the end all the stimuli before ending the run
cfg.timing.endDelay = 2;
end

%% Visual Stimulation

Expand Down Expand Up @@ -106,10 +126,10 @@

function cfg = setKeyboards(cfg)
cfg.keyboard.escapeKey = 'ESCAPE';
cfg.keyboard.responseKey = {...
cfg.keyboard.responseKey = { ...
'r', 'g', 'y', 'b', ...
'd', 'n', 'z', 'e', ...
't'}; %dnze rgyb
't'}; % dnze rgyb
cfg.keyboard.keyboard = [];
cfg.keyboard.responseBox = [];

Expand Down
22 changes: 15 additions & 7 deletions visualLocTranslational.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

getResponse('start', cfg.keyboard.responseBox);

WaitSecs(cfg.timing.onsetDelay);
waitFor(cfg, cfg.timing.onsetDelay);

%% For Each Block

Expand All @@ -99,6 +99,15 @@
thisEvent.speed = cfg.design.speeds(iBlock, iEvent);
thisEvent.target = cfg.design.fixationTargets(iBlock, iEvent);

% we wait for a trigger every 2 events
if cfg.pacedByTriggers.do && mod(iEvent, 2) == 1
waitForTrigger( ...
cfg, ...
cfg.keyboard.responseBox, ...
cfg.pacedByTriggers.quietMode, ...
cfg.pacedByTriggers.nbTriggers);
end

% play the dots and collect onset and duraton of the event
[onset, duration] = doDotMo(cfg, thisEvent);

Expand All @@ -107,14 +116,14 @@
thisEvent.keyName = 'n/a';
thisEvent.duration = duration;
thisEvent.onset = onset - cfg.experimentStart;

% % this value should be in degrees / second in the log file
% % highlights that the way speed is passed around could be
% % simplified.
% %
% thisEvent.speed
% %

% Save the events txt logfile
% we save event by event so we clear this variable every loop
thisEvent.fileID = logFile.fileID;
Expand All @@ -132,14 +141,13 @@
triggerString = ['trigger_' cfg.design.blockNames{iBlock}];
saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString);

% wait for the inter-stimulus interval
WaitSecs(cfg.timing.ISI);
waitFor(cfg, cfg.timing.ISI);

end

eyeTracker('StopRecordings', cfg);

WaitSecs(cfg.timing.IBI);
waitFor(cfg, cfg.timing.IBI);

% trigger monitoring
triggerEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...
Expand All @@ -151,7 +159,7 @@
end

% End of the run for the BOLD to go down
WaitSecs(cfg.timing.endDelay);
waitFor(cfg, cfg.timing.endDelay);

cfg = getExperimentEnd(cfg);

Expand Down