Skip to content

Commit a79f829

Browse files
committed
fix bug due to field of responseEvents defined as cell by default
1 parent ec00b44 commit a79f829

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Visual-loc_translational/subfun/CPP_PTB/getResponse.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@
5252
end
5353

5454
responseEvents = struct;
55-
responseEvents.onset = {};
56-
responseEvents.trial_type = {};
57-
responseEvents.duration = {};
58-
responseEvents.key_name = {};
59-
responseEvents.pressed = {};
55+
responseEvents.onset = [];
56+
responseEvents.trial_type = [];
57+
responseEvents.duration = [];
58+
responseEvents.key_name = [];
59+
responseEvents.pressed = [];
6060

6161
responseBox = cfg.responseBox;
6262

@@ -137,8 +137,6 @@
137137
iEvent = iEvent + 1;
138138

139139
end
140-
141-
142140

143141
case 'flush'
144142

Visual-loc_translational/visualLocTanslational.m

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,22 @@
150150
% saving in the tsv file
151151
responseEvents = getResponse('check', cfg, expParameters);
152152

153-
responseEvents.eventLogFile = logFile.eventLogFile;
154-
for iResp = 1:size(responseEvents, 1)
155-
responseEvents(iResp).onset = ...
156-
responseEvents(iResp).onset - cfg.experimentStart;
157-
responseEvents(iResp).target = expParameters.designFixationTargets(iBlock,iEvent);
158-
responseEvents(iResp).event = iEvent;
159-
responseEvents(iResp).block = iBlock;
160-
end
161-
162-
saveEventsFile('save', expParameters, responseEvents, ...
153+
if ~isempty(responseEvents(1).onset)
154+
155+
responseEvents.eventLogFile = logFile.eventLogFile;
156+
157+
for iResp = 1:size(responseEvents, 1)
158+
responseEvents(iResp).onset = ...
159+
responseEvents(iResp).onset - cfg.experimentStart;
160+
responseEvents(iResp).target = expParameters.designFixationTargets(iBlock,iEvent);
161+
responseEvents(iResp).event = iEvent;
162+
responseEvents(iResp).block = iBlock;
163+
end
164+
165+
saveEventsFile('save', expParameters, responseEvents, ...
163166
'direction', 'speed', 'target', 'event', 'block');
164-
167+
end
168+
165169

166170
% wait for the inter-stimulus interval
167171
WaitSecs(expParameters.ISI);

0 commit comments

Comments
 (0)