<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi Francesco,</div><div><br><blockquote type="cite"><div>The strange thing is that<br>while the 'powspctrm' output field of ft_freqanalysis contains "NaN" values,<br>I see its content by plotting it using ft_singleplotTFR..<br></div></blockquote><div><br></div><div>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</div><div><a href="http://fieldtrip.fcdonders.nl/_detail/tutorial/timefrequencyanalysis/tfrhann7_24_mrt_2009.png?id=tutorial%3Atimefrequencyanalysis">http://fieldtrip.fcdonders.nl/_detail/tutorial/timefrequencyanalysis/tfrhann7_24_mrt_2009.png?id=tutorial%3Atimefrequencyanalysis</a></div><a href="http://fieldtrip.fcdonders.nl/_detail/tutorial/timefrequencyanalysis/tfrhann7_24_mrt_2009.png?id=tutorial:timefrequencyanalysis"></a><div><br></div><br><blockquote type="cite"><div>Also summing up over all the frequencies in this way<br><br>cfg=[];<br>cfg.method = 'mtmconvol';<br>cfg.output = 'pow';<br>cfg.taper = 'hanning';<br>cfg.trials = 'all';<br>cfg.foi = 1:150;<br>cfg.toi = [comp.time{1}(1,1):0.02:comp.time{1}(1,end)];<br>cfg.t_ftimwin = 4./cfg.foi;<br>[freq_comp_tr] = ft_freqanalysis(cfg,comp);<br><br>pow_f=sum(freq_comp_tr.powspctrm,2);<br>pelec= squeeze(pow_f);</div></blockquote><blockquote type="cite"><div><br>both pow_f and pelec contain NaN values, but plotting it I see the content!?<br></div></blockquote><div><br></div>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.</div><div><br><blockquote type="cite"><div><blockquote type="cite">If you are interested in the total energy over time of your signal, but<br></blockquote><blockquote type="cite">only for the 1-150 Hz part, it might be easier to do a bandpass, and<br></blockquote><blockquote type="cite">taking the square of your raw signal (energy is usually squared<br></blockquote><blockquote type="cite">amplitude I thought?). If that is what your intending though.<br></blockquote><br>Right, this is the way I do it in general.. It was just to try using field trip functions...<br></div></blockquote><div><br></div><div>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</div><div><br></div><div>  for i=1:numel(data.trial), data.trial{i} = data.trial{i}.^2; end</div><div><br></div><div>best</div><div>Robert</div><div><br></div><div><br></div></div></body></html>