diff --git a/initEnv.m b/initEnv.m index cb51fd7..bd40b17 100644 --- a/initEnv.m +++ b/initEnv.m @@ -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:', ... @@ -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 diff --git a/lib/CPP_PTB b/lib/CPP_PTB index fe4f16c..7861863 160000 --- a/lib/CPP_PTB +++ b/lib/CPP_PTB @@ -1 +1 @@ -Subproject commit fe4f16c22e173709a84b6144588cbffa080e5a96 +Subproject commit 78618636295d4e52036d04c210f6ec5c6c4e68eb diff --git a/setParameters.m b/setParameters.m index 04fba09..0b99eef 100644 --- a/setParameters.m +++ b/setParameters.m @@ -21,7 +21,7 @@ %% Engine parameters cfg.testingDevice = 'mri'; - cfg.eyeTracker.do = true; + cfg.eyeTracker.do = false; cfg.audio.do = false; cfg = setMonitor(cfg); @@ -32,6 +32,8 @@ % MRI settings cfg = setMRI(cfg); + cfg.pacedByTriggers.do = true; + %% Experiment Design % cfg.design.motionType = 'translation'; @@ -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 @@ -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 @@ -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 = []; diff --git a/visualLocTranslational.m b/visualLocTranslational.m index 7afccb1..5c99476 100644 --- a/visualLocTranslational.m +++ b/visualLocTranslational.m @@ -77,7 +77,7 @@ getResponse('start', cfg.keyboard.responseBox); - WaitSecs(cfg.timing.onsetDelay); + waitFor(cfg, cfg.timing.onsetDelay); %% For Each Block @@ -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); @@ -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; @@ -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, ... @@ -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);