[FieldTrip] problems using ft_freqanalysis

jan-mathijs schoffelen jan.schoffelen at donders.ru.nl
Fri May 20 07:36:03 CEST 2011


Dear Joe,

To begin with, since you are still 'tabula rasa' in the field of  
frequency analysis, I'd like you to forget about the 'mtmwelch'  
method ;o). I believe that at some point this method was implemented  
to 'just have it in the package'. As far as I am aware, it is hardly  
ever used and not actively maintained.
Essentially, Welch's method cuts the data into overlapping segments,  
computes a power spectrum, and averages across the segments again. The  
way it is implemented in Fieldtrip, is that one needs to specify the  
length of the timewindow in which to cut the data. This is the  
cfg.t_ftimwin. (as a side note: for the underlying computations  
fieldtrip relies on the method 'mtmconvol', which allows for a  
frequency specific segment length, which in this context does not  
really make sense, but is handy to emulate a wavelet analysis).
In your case however, I would advice to use cfg.method = 'mtmfft',  
because at this stage you are not interested in the temporal dimension  
of your spectrum. This method requires a slightly different cfg (in  
terms of fields and their content) with respect to mtmwelch/mtmconvol,  
but I hope that you can find your way around in the documentation to  
get it up and running. As to the 'tapsmofrq' in this case, if you have  
sufficiently long trials, you can still use some smoothing for the  
estimation of the low frequencies. The advice to use hanning for the  
lower frequencies specifically pertains to time-frequency estimation.

Cheers,

Jan-Mathijs



On May 20, 2011, at 4:30 AM, Joseph Dien wrote:

> Hi,
>  I'm just starting to get up to speed on spectral analysis (I'm an  
> ERPer).
> I'm using the following set-up:
>
> I tried the following (for one second long trials with an Fs of  
> 250Hz and interest in frequencies below 30Hz):
>
> cfg.method='mtmwelch';
> cfg.output='pow';
> [freq] = ft_freqanalysis(cfg, data);
>
> I got the error message:
>
> -------------------------
> the input is raw data with 128 channels and 160 trials
> 'mtmwelch' has not been implemented yet in the specest toolbox, the  
> old implementation is being used
> taking every sample as time of interest
> the input is raw data with 128 channels and 160 trials
> ??? Error using ==> ft_freqanalysis at 216
> you must specify a smoothing parameter with taper = dpss
>
> Error in ==> ft_freqanalysis_mtmwelch at 107
> freq = ft_freqanalysis(cfgconvol, data);
>
> Error in ==> ft_freqanalysis at 271
> [freq] =
> feval(sprintf('ft_freqanalysis_%s',lower(cfg.method)), cfg,
> data);
>
> -----------------------
> Two things:
>
> 1) What would be an appropriate smoothing parameter?
>
> 2) Is this a bug?  It defaulted to dpss as specified by the  
> documentation but it didn't provide a default smoothing parameter so  
> the default still resulted in a crash.
>
> Anyway, given the advice in the tutlrial to use a hanning window  
> rather than a multi-taper like dpss for frequencies below 30, I  
> tried the following:
>
> cfg.foi=[1:1:30];
> cfg.taper='hanning';
>
> which resulted in:
>
> --------------------------
>>> [freq] = ft_freqanalysis(cfg, data);
> the input is raw data with 128 channels and 160 trials
> 'mtmwelch' has not been implemented yet in the specest toolbox, the  
> old implementation is being used
> taking every sample as time of interest
> the input is raw data with 128 channels and 160 trials
> processing trials
> ??? Reference to non-existent field 't_ftimwin'.
>
> Error in ==> ft_freqanalysis at 454
>      [spectrum_mtmconvol,ntaper,foi,toi] =
>      ft_specest_mtmconvol(dat, time, 'timeoi', cfg.toi,
>      'timwin', cfg.t_ftimwin, 'taper', ...
>
> Error in ==> ft_freqanalysis_mtmwelch at 107
> freq = ft_freqanalysis(cfgconvol, data);
>
> Error in ==> ft_freqanalysis at 271
> [freq] =
> feval(sprintf('ft_freqanalysis_%s',lower(cfg.method)), cfg,
> data);
>
>
> --------------------
> What am I doing wrong?  I looked through the code but couldn't  
> figure out what the problem was.  I am very confused...
>
> fieldtrip-20110519
> MATLAB Version 7.11.0.584 (R2010b)
> Operating System: Mac OS X  Version: 10.6.7 Build: 10J869
>
>
>>> cfg
>
> cfg =
>
>    dataset: 'SLI_3011m_40m_POA.egis'
>     method: 'mtmwelch'
>     output: 'pow'
>      taper: 'hanning'
>  tapsmofrq: 4
>        foi: [1x30 double]
>
>>> data
>
> data =
>
>         hdr: [1x1 struct]
>       label: {128x1 cell}
>        time: {1x160 cell}
>       trial: {1x160 cell}
>     fsample: 250
>  sampleinfo: [160x2 double]
>         cfg: [1x1 struct]
>
>
> Thanks for any help you can give!
>
> Joe
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

Dr. J.M. (Jan-Mathijs) Schoffelen
Donders Institute for Brain, Cognition and Behaviour,
Centre for Cognitive Neuroimaging,
Radboud University Nijmegen, The Netherlands
J.Schoffelen at donders.ru.nl
Telephone: 0031-24-3614793




More information about the fieldtrip mailing list