Skip to content

Commit

Permalink
Merge pull request #74 from unfoldtoolbox/roundVsFloor
Browse files Browse the repository at this point in the history
Update uf_epoch.m
  • Loading branch information
behinger authored Oct 16, 2019
2 parents 215a38d + f441da6 commit dd486b7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/uf_toolbox/uf_epoch.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@
},'mode','ignore');
if(ischar(cfg)), error(cfg); end

% Latencies in EEGlab convention do not have to be integer samples.
% Convert latencies to sample-rounded latencies. Eeglab by default uses "floor" which is unintuitive to us
% and inconsistent with how we generate Xdc. Also other tools e.g. fieldtrip use "round"
% Eeglab:
% Line 115 in epoch.m
%
% Fieldtrip:
% https://github.com/fieldtrip/fieldtrip/blob/b029f63b965a4e796a931bb7c109fdd9e66faea8/fileio/ft_read_event.m#L691
% https://github.com/fieldtrip/fieldtrip/blob/26aee7b1be549389abb8627cd0242e8bfce1af47/trialfun/ft_trialfun_trial.m#L50
%
% Unfold:
% https://github.com/unfoldtoolbox/unfold/blob/5f72ad62065b126afd124694ebc20f63277d0c2b/src/uf_toolbox/uf_timeexpandDesignmat.m#L103

for e = 1:length(EEG.event)
EEG.event(e).latency = round(EEG.event(e).latency);
end

%% Remove events in windows with bad (continuous) EEG data
% This routine checks whether an event is contained in the rejection window
% If yes, it removes it from further analyses
Expand Down Expand Up @@ -75,4 +92,4 @@
convertIND = find(ismember({EEG.event(:).type},eventType));
EEG_epoch.unfold.X = EEG_epoch.unfold.X(convertIND(event_ind),:);

EEG_epoch.urevent = EEG.urevent(event_ind);
EEG_epoch.urevent = EEG.urevent(event_ind);

0 comments on commit dd486b7

Please sign in to comment.