[FieldTrip] Different cfg.poststim values in ft_preprocessing alters signal
Stephen Whitmarsh
stephen.whitmarsh at gmail.com
Tue Feb 2 17:14:09 CET 2021
Hey Benjy,
I would suspect this has to do with your (dft) filtering, which depends on
the amount of data, and perhaps some small numerical differences due to
resampling. Strange jumps at onset/offset of data segments also often
indicate something to do with filtering.
To avoid this, and to create a fair comparison between your different trial
duration segmentation, I would do the following:
- preprocess all your data as one long 'trial'. I.e. without segmentation.
Do all your filtering at this step, i.e. at one go over all your data. This
gives you the maximum frequency resolution & ability to filter low
frequencies.
- segment your filtered data into trials using ft_redefinetrial.
- do your resampling
- check the different triallengths.
If anything stays slightly different, I would imagine it has to do with the
resampling, because samples will end up slightly different on your axis,
creating numerical differences. You could resample before segmenting, which
would be more efficient, but then you'll have to deal with changing timing
of your markers which would still be in the original samplerate. Dealing
with time-axis and samples is a pain so personally I therefore always let
FT deal with the resampling after trial segmentation.
Have fun,
Stephen
Op di 2 feb. 2021 om 16:36 schreef Barnett, Benjy <
benjy.barnett.20 at ucl.ac.uk>:
> Hey. When I am preprocessing my MEG neuromag data, I’m noticing that the
> signal of my channels are altered depending on how long after the stimulus
> I include in the trial, even in the portion of the trial that is
> overlapping between the two cases. For instance, if I use cfg.poststim =
> 2.5 in one run and cfg.poststim = 0.6 in a second, the two signals are not
> identical up until 0.6 seconds. Please see my code and attached plots of a
> Grad sensor in these two cases up to 0.6 seconds.
>
> % define trials
> cfg = [];
> cfg.dataset = full_path;
> cfg.trialdef.prestim = 0.175;
> cfg.trialdef.poststim = 0.6; % compare with 2.5 seconds
> cfg.trialdef.eventvalue = [6 7 9];
>
> cfg.trialdef.eventtype = 'STI101';
> cfg = ft_definetrial(cfg);
>
>
> % preprocess
>
>
> cfg.demean = 'yes';
> cfg.baselinewindow = [-0.175 0.025];
> cfg.lpfilter = 'no';
> cfg.hpfilter = 'no';
> cfg.dftfilter = 'yes';
> split_files{1} = ft_preprocessing(cfg); %preprocess
>
>
> %%%%%%%%%%%Downsampling%%%%%%%%%
> cfg = [];
> cfg.resamplefs = 250;
> data = ft_resampledata(cfg, split_files{1});
>
>
> %%Visualisation
> cfg = [];
> cfg.channel = 'MEGGRAD';
> cfg.keeptrials = 'yes';
> data = ft_timelockanalysis(cfg,data);
> Xlim([-0.2 0.6])
> plot(data.time,squeeze(mean(data.trial(:,39,:),1)))
>
> As you can see from the plots attached, these signals are not identical
> when they should be (shouldn’t they?). The first plot is when I Use
> 2.5 seconds post stim and the second is using 0.6. I’ve altered the xlim to
> show only up to 600ms on both. Also, can anyone explain these huge spikes
> at the beginning of trials, that’s my next problem to solve.
>
> Thanks
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210202/fac76421/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2_5_ch39_full.png
Type: image/png
Size: 21505 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210202/fac76421/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 600_ch39_full.png
Type: image/png
Size: 19576 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210202/fac76421/attachment-0003.png>
More information about the fieldtrip
mailing list