[Eeglablist] [erplab] Issue with down-sampling data

Andreas Widmann widmann at uni-leipzig.de
Sat Nov 5 07:13:42 PDT 2016


Hi Eric,

I can replicate the problem and confirm that there is a problem with epoched data and some non-integer resampling ratios. Please, file a bug report at the EEGLAB bug tracker
https://sccn.ucsd.edu/bugzilla/
including a description of the problem and a short sample file (some epochs only). Please, add me to the cc list of the bug report. I have to think about how to approach the problem and will try to provide a patch some time next week.

For now you can work-around the problem by resampling to 128Hz or better by resampling the continuous data. Please note that it is actually to be preferred to resample the continuous data as resampling implies (anti-aliasing) filtering and filtering should be done on continuous data to avoid edge effects. Presumably this is why the bug was not detected for quite some time.

Best,
Andreas

> Am 04.11.2016 um 15:20 schrieb Eric Fields <Eric.Fields at tufts.edu>:
> 
> Hi Andrew,
> 
> For me the values are actually different. Here is the output I get when I run the original script I sent. You can see that the event latencies match for the first epoch, but after that they are wrong. Using {2} on the end just indexes into the latency for the second event in each epoch, but the values still don't match.
> 
> I'm using MATLAB 2015a, EEGLAB 13.5.4b, and ERPLAB 5.0.0 if that helps.
> 
> Thanks,
> 
> Eric
> 
> <MATLAB_output.jpg>
>> 
> -----
> Eric Fields, M.S.
> Doctoral Candidate
> NeuroCognition Lab
> Tufts University
> 617-627-3403
> 
> On Thu, Nov 3, 2016 at 9:32 PM, Dr Andrew X Stewart <axstewart at ucdavis.edu> wrote:
> Hi Eric,
> 
> Thanks for reporting this.
> 
> I think this might be a problem with how you were getting the numbers for checking for equality.
> 
> I checked this on some of my own data, and you are right that the equality check passed on your test on the first epoch, and failed on later epochs.
> 
> But - the epoch latencies printed to the command window were the same. The epoch latencies were 622.1008 at 256 Hz, and 622.1008 after resampling to 128 Hz.
> 
> I changed your equality check to test the second element in the epoch latency cell array, and this equality check now passes before and after resampling.
> 
> Try this, noting the {2}s on the epoch.eventlatency:
>> %Start eeglab and load the EEGset
>> [ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
>> EEG = pop_loadset('filename', set_name, 'filepath', directory);
>> [ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG, 5);
>>  
>> %Create a down-sampled EEGset
>> EEG = pop_resample(EEG, 128);
>> [ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET, 'setname', [EEG.setname '_128Hz'], 'gui', 'off');
>>  
>>  
>> %% HERE'S THE PROBLEM
>>  
>> %In my data event latencies are the same for the events in the first and second epoch in the
>> %original and re-sampled datasets
>> isequal(ALLEEG(1).epoch(1).eventlatency, ALLEEG(2).epoch(1).eventlatency) %Yes
>> disp(ALLEEG(1).epoch(1).eventlatency) %Original data
>> disp(ALLEEG(2).epoch(1).eventlatency) %Down-sampled data
>>  
>> %Starting with the third epoch, they are different
>> isequal(ALLEEG(1).epoch(3).eventlatency{2}, ALLEEG(2).epoch(3).eventlatency{2}) %No
>> disp(ALLEEG(1).epoch(3).eventlatency{2}) %Original data
>> disp(ALLEEG(2).epoch(3).eventlatency{2}) %Down-sampled data
>>  
>> %And then the error increases for later epochs
>> isequal(ALLEEG(1).epoch(10).eventlatency{2}, ALLEEG(2).epoch(10).eventlatency{2}) %No
>> disp(ALLEEG(1).epoch(10).eventlatency{2}) %Original data
>> disp(ALLEEG(2).epoch(10).eventlatency{2}) %Down-sampled data
> 
> 
> Does that work?
> 
> If not, can you tell what event latencies you had before and after resampling? What is the full contents of your ALLEEG(1).epoch(1).eventlatency?
> 
> Thanks,
> Andrew
> 
> 
> 
> 
>> On Nov 3, 2016, at 5:02 PM, Eric Fields <Eric.Fields at tufts.edu> wrote:
>> 
>> Hi,
>> 
>> I'm trying to downsample from 512 Hz to 128 Hz in a EEGset that has been epoched using ERPLAB. When I use the pop_resample function, the latencies listed in EEG.epoch are no longer correct.
>> 
>> I've attached a short script that shows the problem. Unfortunately EEGsets are too large to attach, but you can probably insert any epoched dataset you have on hand and replicate the issue (or if not, I'd be interested to know!).
>> 
>> Has anyone else had this problem and is there an easy fix it or do you have to resample before epoching?
>> 
>> Eric
>> 
>> -----
>> Eric Fields, M.S.
>> Doctoral Candidate
>> NeuroCognition Lab
>> Tufts University
>> 617-627-3403
>> <ResamplingProblems.m>
> 
> 




More information about the eeglablist mailing list