[FieldTrip] Power time Course (Re: fieldtrip Digest, Vol 12, Issue 13)

Robert Oostenveld r.oostenveld at donders.ru.nl
Wed Nov 9 21:48:12 CET 2011


Hi Francesco,

> The strange thing is that
> while the 'powspctrm' output field of ft_freqanalysis contains "NaN" values,
> I see its content by plotting it using ft_singleplotTFR..

At the edges of your time axis for the lower frequencies where the wavelet does not fully fit in the data window you'll get nans. That is for example what you see in the figure
http://fieldtrip.fcdonders.nl/_detail/tutorial/timefrequencyanalysis/tfrhann7_24_mrt_2009.png?id=tutorial%3Atimefrequencyanalysis


> Also summing up over all the frequencies in this way
> 
> cfg=[];
> cfg.method = 'mtmconvol';
> cfg.output = 'pow';
> cfg.taper = 'hanning';
> cfg.trials = 'all';
> cfg.foi = 1:150;
> cfg.toi = [comp.time{1}(1,1):0.02:comp.time{1}(1,end)];
> cfg.t_ftimwin = 4./cfg.foi;
> [freq_comp_tr] = ft_freqanalysis(cfg,comp);
> 
> pow_f=sum(freq_comp_tr.powspctrm,2);
> pelec= squeeze(pow_f);
> 
> both pow_f and pelec contain NaN values, but plotting it I see the content!?

Doing normal math with nans does not work, i.e. nan+1=nan. You might want to use nansum instead of sum. But the FT plotting functions know how to plot the nans.

>> If you are interested in the total energy over time of your signal, but
>> only for the 1-150 Hz part, it might be easier to do a bandpass, and
>> taking the square of your raw signal (energy is usually squared
>> amplitude I thought?). If that is what your intending though.
> 
> Right, this is the way I do it in general.. It was just to try using field trip functions...

that is also possible (well, almost that is). Do ft_preprocessing on your data with a bandpassfilter and specify cfg.hilbert=yes. That will give you the amplitude envelope. It is not squared however, so it you want ft^2 you'll still have to do a little in matlab yourself

  for i=1:numel(data.trial), data.trial{i} = data.trial{i}.^2; end

best
Robert


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20111109/66be8249/attachment.html>


More information about the fieldtrip mailing list