Skip to content

Commit e47b8d6

Browse files
committed
collect trigger in the same file as responses
1 parent cdd1528 commit e47b8d6

File tree

4 files changed

+65
-25
lines changed

4 files changed

+65
-25
lines changed

lib/CPP_BIDS

lib/CPP_PTB

setParameters.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,24 @@
4242
cfg.design.nbEventsPerBlock = 12; % DO NOT CHANGE
4343

4444
%% Timing
45+
46+
% FOR 7T: if you want to create localizers on the fly, the following must be
47+
% multiples of the scanneryour sequence TR
48+
%
49+
% IBI
50+
% block length = (cfg.eventDuration + cfg.ISI) * cfg.design.nbEventsPerBlock
4551

4652
% Time between blocs in secs
47-
cfg.IBI = .1; % 8;
53+
cfg.IBI = 1.8*3; % 8;
4854
% Time between events in secs
4955
cfg.ISI = 0.1;
5056
% Number of seconds before the motion stimuli are presented
5157
cfg.onsetDelay = .1;
5258
% Number of seconds after the end all the stimuli before ending the run
5359
cfg.endDelay = .1;
5460

55-
cfg.eventDuration = 3; % second
56-
61+
cfg.eventDuration = 0.8; % second
62+
5763
%% Visual Stimulation
5864

5965
% Speed in visual angles / second
@@ -94,13 +100,13 @@
94100
cfg.target.maxNbPerBlock = 2;
95101
cfg.target.duration = 0.05; % In secs
96102

97-
cfg.extraColumns = {'direction', 'speed', 'target', 'event', 'block'};
103+
cfg.extraColumns = {'direction', 'speed', 'target', 'event', 'block', 'keyName'};
98104

99105
end
100106

101107
function cfg = setKeyboards(cfg)
102108
cfg.keyboard.escapeKey = 'ESCAPE';
103-
cfg.keyboard.responseKey = {'space'};
109+
cfg.keyboard.responseKey = {'space', 't'};
104110
cfg.keyboard.keyboard = [];
105111
cfg.keyboard.responseBox = [];
106112

@@ -115,7 +121,7 @@
115121
cfg.mri.triggerKey = 't';
116122
cfg.mri.triggerNb = 4;
117123

118-
cfg.mri.repetitionTime = 2;
124+
cfg.mri.repetitionTime = 1.8;
119125

120126
cfg.bids.MRI.Instructions = 'Detect the RED fixation cross';
121127
cfg.bids.MRI.TaskDescription = [];

visualLocTanslational.m

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646

4747
% dots are displayed on a square with a length in visual angle equal to the
4848
% field of view
49-
cfg.dot.number = round(cfg.dot.density * (cfg.screen.winWidth / cfg.screen.ppd)^2);
49+
cfg.dot.number = round(cfg.dot.density * ...
50+
(cfg.dot.matrixWidth / cfg.screen.ppd)^2);
5051

5152
[el] = eyeTracker('Calibration', cfg);
5253

@@ -55,7 +56,7 @@
5556
% Prepare for the output logfiles with all
5657
logFile.extraColumns = cfg.extraColumns;
5758
logFile = saveEventsFile('open', cfg, logFile);
58-
59+
5960
% prepare textures
6061
cfg = apertureTexture('init', cfg);
6162
cfg = dotTexture('init', cfg);
@@ -101,6 +102,7 @@
101102

102103
thisEvent.event = iEvent;
103104
thisEvent.block = iBlock;
105+
thisEvent.keyName = 'n/a';
104106
thisEvent.duration = duration;
105107
thisEvent.onset = onset - cfg.experimentStart;
106108

@@ -115,32 +117,64 @@
115117

116118
% collect the responses and appends to the event structure for
117119
% saving in the tsv file
118-
responseEvents = collectAndSaveResponses(cfg, logFile, cfg.experimentStart);
119-
120-
responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, getOnlyPress);
121-
120+
responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...
121+
getOnlyPress);
122+
122123
if isfield(responseEvents(1), 'onset') && ~isempty(responseEvents(1).onset)
123-
124+
124125
for iResp = 1:size(responseEvents, 1)
125-
126-
responseEvents(iResp).event = iEvent;
127-
responseEvents(iResp).block = iBlock;
126+
responseEvents(iResp).onset = ...
127+
responseEvents(iResp).onset - cfg.experimentStart;
128+
responseEvents(iResp).event = 'n/a';
129+
responseEvents(iResp).block = 'n/a';
130+
responseEvents(iResp).direction = 'n/a';
131+
responseEvents(iResp).speed = 'n/a';
132+
responseEvents(iResp).target = 'n/a';
133+
if strcmp(responseEvents(iResp).keyName, 't')
134+
responseEvents(iResp).trial_type = 'trigger';
135+
end
128136
end
129-
137+
138+
responseEvents(1).fileID = logFile.fileID;
139+
responseEvents(1).extraColumns = logFile.extraColumns;
130140
saveEventsFile('save', cfg, responseEvents);
131-
141+
132142
end
133-
143+
134144
% wait for the inter-stimulus interval
135145
WaitSecs(cfg.ISI);
136146

137-
getResponse('flush', cfg.keyboard.responseBox);
138-
139147
end
140-
148+
141149
eyeTracker('StopRecordings', cfg);
142-
150+
143151
WaitSecs(cfg.IBI);
152+
153+
% trigger monitoring
154+
triggerEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...
155+
getOnlyPress);
156+
157+
if isfield(triggerEvents(1), 'onset') && ~isempty(triggerEvents(1).onset)
158+
159+
for iResp = 1:size(triggerEvents, 1)
160+
triggerEvents(iResp).onset = ...
161+
triggerEvents(iResp).onset - cfg.experimentStart;
162+
triggerEvents(iResp).event = 'n/a';
163+
triggerEvents(iResp).block = 'n/a';
164+
triggerEvents(iResp).direction = 'n/a';
165+
triggerEvents(iResp).speed = 'n/a';
166+
triggerEvents(iResp).target = 'n/a';
167+
if strcmp(triggerEvents(iResp).keyName, 't')
168+
triggerEvents(iResp).trial_type = 'trigger-baseline';
169+
end
170+
end
171+
172+
triggerEvents(1).fileID = logFile.fileID;
173+
triggerEvents(1).extraColumns = logFile.extraColumns;
174+
saveEventsFile('save', cfg, triggerEvents);
175+
176+
end
177+
144178

145179
end
146180

0 commit comments

Comments
 (0)