[FieldTrip] Epoching EEG data after downsampling

Robert Oostenveld r.oostenveld at donders.ru.nl
Fri Mar 18 08:50:11 CET 2016

Hi Gunnar,

This is a known challenge, especially for large datasets. Your considerations for the filtering during preprocessing are well taken. Since different resampling methods can be used with either integer or fractional resamling ratio's, it is not completely straightforward for to specify how the old and new samples map to each other. 

However, a trick is to add a channel to your original data that contains the sample indices of the original dataset. E.g.

cfg = []
cfg = …
data_old = ft_preprocessing(cfg)

data_old.label{end+1} = ‘sample’;
for i=1:size(data_old.sampleinfo,1)
  % this works for one or more trials
  data_old.trial{i}(end+1,:) = data_old.sampleinfo(i,1):data_old.sampleinfo(i,2);

cfg = []
cfg = …
data_new = ft_resampledata(cfg, data_old);

The effect is that the linearly increasing sample channel also gets downsampled. In data_new you can subsequently look up the mapping between the new (index) and the old (value) samples. 

best regards,

On 17 Mar 2016, at 08:36, Gunnar Norrman <gunnar.norrman at biling.su.se> wrote:

> Hello,
> I have a set of BioSemi EEG data that I want to import, downsample and high pass filter as continuous data before epoching. However, when I load the original triggers from the .bsd file they are still in the original sample frequency, and when I want to apply the trials (extracted using ft_definetrial) using ft_redefinetrial, I get the following error:
> > In ft_redefinetrial (line 222)
> Subscripted assignment dimension mismatch.
> Now, the obvious solution would be to downsample the data after epoching, of course, but then highpass filtering (in the original sample rate) takes a very long time to complete. I also want to save the continuous, filtered and downsampled data before epoching for plotting.
> Any suggestions? Is there any way to change the sample rate of the trial definitions, or to load the continuous data including trial information prior to downsampling?
> Thank you!
> Best regards,
> Gunnar Norrman 
> ---
> Gunnar Norrman
> Centre for Research on Bilingualism, Stockholm University
> +46 (0)8 16 3643 | gunnar.norrman at biling.su.se
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20160318/e1e072a7/attachment-0002.html>

More information about the fieldtrip mailing list