Skip to content

Commit 329056e

Browse files
committed
fix non integer event latencies
1 parent 38b89f7 commit 329056e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

functions/popfunc/eeg_eegrej.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136
% add boundary events
137137
% -------------------
138138
[ EEG.event ] = eeg_insertbound(EEG.event, oldEEGpnts, regions);
139+
% Normalize all latencies to double so that .5 boundary positions survive
140+
% [struct.field] concatenation (which would otherwise coerce to int64).
141+
for iEvt = 1:length(EEG.event)
142+
EEG.event(iEvt).latency = double(EEG.event(iEvt).latency);
143+
end
139144
EEG = eeg_checkset(EEG, 'eventconsistency');
140145
if ~isempty(EEG.event) && EEG.trials == 1 && EEG.event(end).latency-0.5 > EEG.pnts
141146
EEG.event(end) = []; % remove last event if necessary

functions/sigprocfunc/epoch.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@
150150
if ~isempty(g.allevents)
151151
posinit = pos0 + g.alleventrange(1)*g.srate; % compute offset
152152
posend = pos0 + g.alleventrange(2)*g.srate; % compute offset
153-
eventtrial = intersect_bc( find(g.allevents*g.srate >= posinit), find(g.allevents*g.srate < posend) );
153+
ae_pts = double(g.allevents)*g.srate; % double cast prevents int64 rounding of .5 latencies
154+
eventtrial = intersect_bc( find(ae_pts >= posinit), find(ae_pts < posend) );
154155
alleventout{index} = eventtrial;
155-
alllatencyout{index} = g.allevents(eventtrial)*g.srate-pos0;
156+
alllatencyout{index} = ae_pts(eventtrial)-pos0;
156157
end
157158
end
158159
newtime(1) = reallim(1)/g.srate;

0 commit comments

Comments
 (0)