Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pop_resample() ignores boundary event latencies when option_boundary99==1 #854

Open
Bysmuth opened this issue Feb 25, 2025 · 0 comments
Open

Comments

@Bysmuth
Copy link

Bysmuth commented Feb 25, 2025

I imported a data file, removed long pauses between blocks using pop_select(), and then resampled the data. Prior to resampling, there were 16 boundary events in my data file, all with correct latencies where data had been removed. After resampling, all of the boundary events been moved to the start of the file, with all latencies set to 0.5.

The problem appears to be due to lines 228 and 229 in pop_resample():

iBnd = sum(EEG.event(iEvt).latency + 0.5 >= bounds);
EEG.event(iEvt).latency = indices(iBnd) - 0.5;

The result of those lines is that the prior value of EEG.event(iEvt).latency is not used to compute the revised value of EEG.event(iEvt).latency: For all events in the dataset, iBnd is set 1, and the revised latency is set to 0.5.

This issue can be demonstrated using the sample EEGLAB data set, as demonstrated below. Note that this occurs if (and only if) the "use type "-99" for boundary events" box is checked in the EEGLAB preferences window.

% load file
EEG = pop_loadset('filename','eeglab_data.set','filepath','/Library/MathWorks/MATLAB/eeglab2024.0/sample_data/');

% remove 1s of data every 30s
times_to_remove = [29 30; 59 60; 89 90; 119 120; 149 150; 179 180; 209 210];
EEG = pop_select(EEG, 'rmtime', times_to_remove);

% create event list using ERPLAB
EEG = pop_creabasiceventlist( EEG , 'AlphanumericCleaning', 'on', 'BoundaryNumeric', { -99 }, 'BoundaryString', { 'boundary' } ); % GUI: 25-Feb-2025 11:58:43

% boundary event latencies are correct
[EEG.event([EEG.event.type]==-99).latency]/EEG.srate

% downsample to 64 Hz
EEG = pop_resample(EEG, 64);

% boundary event latencies are incorrect iff "use type "-99" for boundary
% events" preference box is checked
[EEG.event([EEG.event.type]==-99).latency]/EEG.srate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant