Skip to content

Commit b466640

Browse files
committed
make script be paced by triggers of the scanner
1 parent 2a9d30b commit b466640

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

audioLocTranslational.m

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

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

66-
WaitSecs(cfg.timing.onsetDelay);
66+
waitFor(cfg, cfg.timing.onsetDelay);
6767

6868
%% For Each Block
6969

@@ -84,14 +84,20 @@
8484
thisEvent.direction = cfg.design.directions(iBlock, iEvent);
8585
% thisEvent.speed = cfg.design.speeds(iBlock, iEvent);
8686
thisEvent.target = cfg.design.fixationTargets(iBlock, iEvent);
87+
88+
% we wait for a trigger every 2 events
89+
if cfg.pacedByTriggers.do && mod(iEvent, 2) == 1
90+
waitForTrigger( ...
91+
cfg, ...
92+
cfg.keyboard.responseBox, ...
93+
cfg.pacedByTriggers.quietMode, ...
94+
cfg.pacedByTriggers.nbTriggers);
95+
end
8796

8897
% % % REFACTOR THIS FUNCTION % % %
89-
9098
% play the sounds and collect onset and duration of the event
9199
[onset, duration] = doAudMot(cfg, thisEvent);
92100

93-
% % % REFACTOR THIS FUNCTION % % %
94-
95101
thisEvent.event = iEvent;
96102
thisEvent.block = iBlock;
97103
thisEvent.keyName = 'n/a';
@@ -116,13 +122,13 @@
116122
saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString);
117123

118124
% wait for the inter-stimulus interval
119-
WaitSecs(cfg.timing.ISI);
125+
waitFor(cfg, cfg.timing.ISI);
120126

121127
end
122128

123129
eyeTracker('StopRecordings', cfg);
124130

125-
WaitSecs(cfg.timing.IBI);
131+
waitFor(cfg, cfg.timing.IBI);
126132

127133
% trigger monitoring
128134
triggerEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...
@@ -134,7 +140,7 @@
134140
end
135141

136142
% End of the run for the BOLD to go down
137-
WaitSecs(cfg.timing.endDelay);
143+
waitFor(cfg, cfg.timing.endDelay);
138144

139145
cfg = getExperimentEnd(cfg);
140146

setParameters.m

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
% MRI settings
3333
cfg = setMRI(cfg);
34+
35+
cfg.pacedByTriggers.do = true;
3436

3537
%% Experiment Design
3638

@@ -50,15 +52,35 @@
5052
% IBI
5153
% block length = (cfg.eventDuration + cfg.ISI) * cfg.design.nbEventsPerBlock
5254

55+
cfg.timing.eventDuration = 0.850; % second
56+
5357
% Time between blocs in secs
54-
cfg.timing.IBI = 1.8; % 8;
58+
cfg.timing.IBI = 1.8;
5559
% Time between events in secs
5660
cfg.timing.ISI = 0;
5761
% Number of seconds before the motion stimuli are presented
58-
cfg.timing.onsetDelay = .1;
62+
cfg.timing.onsetDelay = 0;
5963
% Number of seconds after the end all the stimuli before ending the run
6064
cfg.timing.endDelay = 3.6;
6165

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

6486
cfg.audio.channels = 2;

0 commit comments

Comments
 (0)