Skip to content

Commit 1848b45

Browse files
committed
use triggers to pace experiment
1 parent 9f862b3 commit 1848b45

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

initEnv.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
% If external dir is empty throw an exception
6060
% and ask user to update submodules.
6161
libDirectory = fullfile(fileparts(mfilename('fullpath')), 'lib');
62-
62+
6363
if numel(dir(libDirectory)) <= 2 % Means that the external is empty
6464
error(['Git submodules are not cloned!', ...
6565
'Try this in your terminal:', ...
@@ -89,8 +89,7 @@ function addDependencies()
8989

9090
pth = fileparts(mfilename('fullpath'));
9191
addpath(genpath(fullfile(pth, 'lib', 'CPP_BIDS', 'src')));
92-
addpath(fullfile(pth, 'lib', 'CPP_PTB'));
93-
% addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src')));
92+
addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src')));
9493
addpath(fullfile(pth, 'subfun'));
9594

9695
end

setParameters.m

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
%% Engine parameters
2222

2323
cfg.testingDevice = 'mri';
24-
cfg.eyeTracker.do = true;
24+
cfg.eyeTracker.do = false;
2525
cfg.audio.do = false;
2626

2727
cfg = setMonitor(cfg);
@@ -32,6 +32,8 @@
3232
% MRI settings
3333
cfg = setMRI(cfg);
3434

35+
cfg.pacedByTriggers.do = true;
36+
3537
%% Experiment Design
3638

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

54+
cfg.timing.eventDuration = 0.850; % second
55+
5256
% Time between blocs in secs
5357
cfg.timing.IBI = 1.8;
5458
% Time between events in secs
@@ -58,7 +62,23 @@
5862
% Number of seconds after the end all the stimuli before ending the run
5963
cfg.timing.endDelay = 3.6;
6064

61-
cfg.timing.eventDuration = 0.9; % second
65+
% reexpress those in terms of repetition time
66+
if cfg.pacedByTriggers.do
67+
68+
cfg.pacedByTriggers.quietMode = true;
69+
cfg.pacedByTriggers.nbTriggers = 1;
70+
71+
cfg.timing.eventDuration = cfg.mri.repetitionTime / 2 - 0.04; % second
72+
73+
% Time between blocs in secs
74+
cfg.timing.IBI = 1;
75+
% Time between events in secs
76+
cfg.timing.ISI = 0;
77+
% Number of seconds before the motion stimuli are presented
78+
cfg.timing.onsetDelay = 0;
79+
% Number of seconds after the end all the stimuli before ending the run
80+
cfg.timing.endDelay = 2;
81+
end
6282

6383
%% Visual Stimulation
6484

@@ -106,10 +126,10 @@
106126

107127
function cfg = setKeyboards(cfg)
108128
cfg.keyboard.escapeKey = 'ESCAPE';
109-
cfg.keyboard.responseKey = {...
129+
cfg.keyboard.responseKey = { ...
110130
'r', 'g', 'y', 'b', ...
111131
'd', 'n', 'z', 'e', ...
112-
't'}; %dnze rgyb
132+
't'}; % dnze rgyb
113133
cfg.keyboard.keyboard = [];
114134
cfg.keyboard.responseBox = [];
115135

visualLocTranslational.m

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

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

80-
WaitSecs(cfg.timing.onsetDelay);
80+
waitFor(cfg, cfg.timing.onsetDelay);
8181

8282
%% For Each Block
8383

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

102+
% we wait for a trigger every 2 events
103+
if cfg.pacedByTriggers.do && mod(iEvent, 2) == 1
104+
waitForTrigger( ...
105+
cfg, ...
106+
cfg.keyboard.responseBox, ...
107+
cfg.pacedByTriggers.quietMode, ...
108+
cfg.pacedByTriggers.nbTriggers);
109+
end
110+
102111
% play the dots and collect onset and duraton of the event
103112
[onset, duration] = doDotMo(cfg, thisEvent);
104113

@@ -107,14 +116,14 @@
107116
thisEvent.keyName = 'n/a';
108117
thisEvent.duration = duration;
109118
thisEvent.onset = onset - cfg.experimentStart;
110-
119+
111120
% % this value should be in degrees / second in the log file
112121
% % highlights that the way speed is passed around could be
113122
% % simplified.
114123
% %
115124
% thisEvent.speed
116125
% %
117-
126+
118127
% Save the events txt logfile
119128
% we save event by event so we clear this variable every loop
120129
thisEvent.fileID = logFile.fileID;
@@ -132,14 +141,13 @@
132141
triggerString = ['trigger_' cfg.design.blockNames{iBlock}];
133142
saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString);
134143

135-
% wait for the inter-stimulus interval
136-
WaitSecs(cfg.timing.ISI);
144+
waitFor(cfg, cfg.timing.ISI);
137145

138146
end
139147

140148
eyeTracker('StopRecordings', cfg);
141149

142-
WaitSecs(cfg.timing.IBI);
150+
waitFor(cfg, cfg.timing.IBI);
143151

144152
% trigger monitoring
145153
triggerEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...
@@ -151,7 +159,7 @@
151159
end
152160

153161
% End of the run for the BOLD to go down
154-
WaitSecs(cfg.timing.endDelay);
162+
waitFor(cfg, cfg.timing.endDelay);
155163

156164
cfg = getExperimentEnd(cfg);
157165

0 commit comments

Comments
 (0)