[FieldTrip] Frequency Analysis Coming Up with NaNs - related to removal of TMS artifcat?

Eelke Spaak e.spaak at donders.ru.nl
Wed Sep 19 09:43:01 CEST 2018


Dear Paul,

Internally, ft_freqanalysis will always do a Fourier transform of the
entire trial for efficiency reasons, which is why any nan in the data
will result in nans in the output, irrespective of cfg.toi. Have a
look at ft_interpolatenan to fix the raw data before doing frequency
analysis.

Cheers, Eelke
On Tue, 18 Sep 2018 at 20:10, Paul Dhami <pdhami06 at gmail.com> wrote:
>
> Dear Fieldtrip community,
>
> I have an TMS-EEG dataset, epoched from -1 to 1 second, with the trigger being the TMS pulse. Due to the TMS pulse artifact, data from -5 ms to 10 ms is trimmed (removed and replaced with NaNs).
>
> After importing the preprocessed data from eeglab using eeglab2fieldtrip(EEG, 'preprocessing'), I tried running a multitaper TFR analysis, with the code below being what I have used:
>
> dataSPfreq              = eeglab2fieldtrip(EEG, 'preprocessing');
>
> cfg = [];
>
> cfg.output     = 'pow';
>
> cfg.method     = 'mtmconvol';
>
> cfg.foi        = 4:2:30;
>
> cfg.t_ftimwin  = 2 ./ cfg.foi;
>
> cfg.tapsmofrq  = 0.4 *cfg.foi;
>
> cfg.toi        = -0.1:0.01:0.5;
>
>
>
> dataSPfreq = ft_freqanalysis(cfg, dataSPfreq)
>
>
> The output then is filled with NaNs.
>
>
> I'm assuming it has something to do with the NaNs in the dataset, but then when trying to select TOIs that shouldn't be affected by the NaN's, such as:
>
>
> dataSPfreq              = eeglab2fieldtrip(EEG, 'preprocessing');
>
> cfg = [];
>
> cfg.output     = 'pow';
>
> cfg.method     = 'mtmconvol';
>
> cfg.foi        = 4:2:30;
>
> cfg.t_ftimwin  = 2 ./ cfg.foi;
>
> cfg.tapsmofrq  = 0.4 *cfg.foi;
>
> cfg.toi        = 0.1:0.01:0.6;
>
>
>
> dataSPfreq = ft_freqanalysis(cfg, dataSPfreq)
>
>
> with toi adjusted (which I believe should contain the appropriate time window size for the lowest frequency at 0.5 s) I still end up with NaNs.
>
>
> Sorry if there is an obvious mistake that I am missing. Any help with this would be greatly appreciated.
>
>
> Best,
>
> Paul
>
>
>
>
>
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202



More information about the fieldtrip mailing list