<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Vladimir,<div class=""><br class=""></div><div class="">I suggest that you first start with a simpler case, like this</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier" class="">fsample = 1000;</font></div><div class=""><font face="Courier" class="">time = (1:1000)/fsample;</font></div><div class=""><font face="Courier" class="">dat = randn(size(time));</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">[spectrum1,ntaper1,freqoi1] = ft_specest_mtmfft(dat, time, 'taper', 'hanning');</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">power1 = abs(spectrum1).^2;</font></div><div class=""><font face="Courier" class="">power1 = squeeze(power1);</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">[spectrum2,ntaper2,freqoi2,timeoi2] = ft_specest_mtmconvol(dat, time, 'taper', 'hanning', 'timeoi', mean(time), 'timwin', 0.5);</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">power2 = abs(spectrum2).^2;</font></div><div class=""><font face="Courier" class="">power2 = squeeze(power2);</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">figure</font></div><div class=""><font face="Courier" class="">plot(freqoi1, power1);</font></div><div class=""><font face="Courier" class="">hold on</font></div><div class=""><font face="Courier" class="">plot(freqoi2, power2, 'r');</font></div></div><div class=""><br class=""></div><div class="">Note that these are not the same (albeit similar), which I had expected…</div><div class=""><br class=""></div><div class="">best</div><div class="">Robert</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 20 Sep 2017, at 12:56, Vladimir Litvak <<a href="mailto:litvak.vladimir@gmail.com" class="">litvak.vladimir@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div dir="ltr" class="">Dear Fieldtrippers,<div class=""><br class=""></div><div class="">I'm looking into an issue of one of SPM users who gets different results when doing TF decomposition compared to computing a spectrum for the same time window. I'm not sure I got to the bottom of it yet but one thing I found is that ft_specest_mtmfft and ft_specest_mtmconvol are affected differently by increasing padding. For short padding the results are similar but with increasing padding there are differences both in offset of the spectrum and its overall shape. See attached images where the top one shows original spectra and the bottom one aligns the lowermost bin to zero. </div><div class=""><br class=""></div><div class="">Is this a bug or a feature?</div><div class=""><br class=""></div><div class="">Below is the script that produces these plots. I could provide the data as well but this could probably be reproduced with any data.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Vladimir</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">-------------------------------------</div><div class=""><br class=""></div><div class=""><div class="">pad = 0.5;%1%10</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">freqoi = 5:45;</div><div class="">timwin = 0.4+0*freqoi;</div><div class=""><br class=""></div><div class="">[spectrum,ntaper,freqoi,timeoi] = ft_specest_mtmconvol(data, time, 'taper', 'hanning', 'timeoi', 1.2, 'freqoi', freqoi,...</div><div class="">    'timwin', timwin, 'tapsmofrq', 1, 'verbose', 0, 'pad', pad);</div><div class=""><br class=""></div><div class="">s1 = squeeze(mean(mean(abs(spectrum), 4), 2));</div><div class=""><br class=""></div><div class="">figure;</div><div class="">subplot(2,1,1)</div><div class="">plot(freqoi, s1);</div><div class="">subplot(2,1,2);</div><div class="">plot(freqoi, s1-s1(1));</div><div class="">%%</div><div class="">[spectrum,ntaper,freqoi] = ft_specest_mtmfft(data, time, 'taper', 'hanning', 'freqoi', freqoi,...</div><div class="">    'tapsmofrq', 1, 'verbose', 0, 'pad', pad);</div><div class=""><br class=""></div><div class="">s2 = squeeze(mean(mean(abs(spectrum), 2), 1));</div><div class=""><br class=""></div><div class="">subplot(2,1,1)</div><div class="">hold on</div><div class="">plot(freqoi, s2, 'r');</div><div class="">subplot(2,1,2)</div><div class="">hold on</div><div class="">plot(freqoi, s2-s2(1), 'r');</div></div></div>
<span id="cid:644C10BA-EE23-4C79-817F-AED817ACCF00@ki.se"><pad0_5.png></span><span id="cid:0A594045-C414-4F44-90FF-32D0857460C8@ki.se"><pad1.png></span><span id="cid:6709F946-F5E8-4614-AA94-A53AEFA36EFA@ki.se"><pad10.png></span>_______________________________________________<br class="">fieldtrip mailing list<br class=""><a href="mailto:fieldtrip@donders.ru.nl" class="">fieldtrip@donders.ru.nl</a><br class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</div></blockquote></div><br class=""></div></body></html>