<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Dear Jan-Mathijs,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you for your response! (And, yes, I had forgotten to mention that the data is log10 transformed after the call to ft_freqstatistics.)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Now that I know what to look for in the cfg, I can see that the pad length is different between the 2018 and 2019 versions, and I can see the latency issue from ft_timelockanalysis as well. If I encounter any issues going forward, I will
 make sure to double-check the cfg first!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">However, I was still curious as to why the pad lengths were different for the two conditions (finger-tapping vs. rest) within the 2019 version of FieldTrip. After inspecting the cfg information as you suggested, I found an issue with the
 cfg latency related to the epoch time limits I had specified in EEGLAB. Now that is fixed, the difference in padlength between the two conditions appears fully resolved.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you again for your help!<o:p></o:p></p>
<p class="MsoNormal">Alison<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:black">--<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:black">Alison Harris, PhD</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:black">Ostby-Cook Associate Professor of Psychology & George R. Roberts Fellow</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:black">Claremont McKenna College</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:black">850 Columbia Avenue</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:black">Claremont, CA 91711</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:black">Phone: (909) 607-9397</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:black">Email:
<a href="mailto:aharris@cmc.edu">aharris@cmc.edu</a></span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">Web: <a href="https://urldefense.com/v3/__http://www1.cmc.edu/pages/faculty/AHarris__;!!HJOPV4FYYWzcc1jazlU!_Tv5Dc5OHwI1UY32HHOSWvHdR2JhlB-TIeBmW3NL9r6A5o9cRwb3yQqpSmSthEvughDKJLgc55Z15KcBLr6p3QozW2wZTMVOtISUfRI$">
http://www1.cmc.edu/pages/faculty/AHarris</a></span><span style="color:black"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> fieldtrip <fieldtrip-bounces@science.ru.nl> <b>
On Behalf Of </b>Schoffelen, J.M. (Jan Mathijs) via fieldtrip<br>
<b>Sent:</b> Saturday, March 4, 2023 5:42 AM<br>
<b>To:</b> FieldTrip discussion list <fieldtrip@science.ru.nl><br>
<b>Cc:</b> Schoffelen, J.M. (Jan Mathijs) <janmathijs.schoffelen@donders.ru.nl><br>
<b>Subject:</b> Re: [FieldTrip] Change in output of ft_freqanalysis<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Dear Alison, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks for your detailed report.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Given that you did not send along any time domain data in the data you shared, I tried to reproduce your observation by simulating some data, and then passing those data on to ft_freqanalysis, in 4 different versions of the fieldtrip code:
 20171231, 20181231, 20191231, and today’s version. I did not manage to reproduce your issue, that is, all four sets of spectra are numerically identical. Based on this, there is no reason to suspect that something changed in the code.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Next, I inspected some of the data that you shared, specifically the files:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">S005_Action_FreqCorr.mat<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">S005_Action_FreqCorrFFT_Boot_2018.mat<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">S005_Action_FreqCorrFFT_Boot_2019.mat<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I can confirm that the power spectra look different, but upon inspection of the cfg’s of the data objects; <variable>.cfg -> so were the cfgs!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In other words, my working hypothesis is now that the cfg details cause the changes in the spectra.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The specification of cfg.taper/cfg.tapsmofrq influences the shape of the spectra, but I won’t discuss that aspect any further here.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Specifically what seems to explain your observations, are the different values of the cfg.pad parameter.  This value has an effect on the overall scaling of the spectra, which could explain the vertical shift of some of the spectra that
 you reported (BTW, as a side note, I don’t understand why the values in the spectra are < 0 for the higher frequencies: this suggests that the numbers were post-processed in some way, because power is always postive, so I suspect an undocumented/unmentioned
 log10 transform or so).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In more detail: if you increase the padding parameter, the extra zero-padding ramps up the spectral resolution of the power spectrum, which means that all signal power is to be divided across a larger amount of frequency bins. This reduces
 the amount of energy per bin, and may explain the overall shift down if the padding is increased. This is because the integral of the power spectrum (i.e. the sum across all frequency bins - which amounts to more bins than you may have requested for your output)
 should amount to the total variance of the underlying signal. If I subtract the ‘2018’ file’s power spectrum from the ‘2019’ file’s power spectrum I get an on average difference of 0.3, which is in line with the log10(2) difference implied by an increase of
 the padding parameter from 8 to 16.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Now, what was a bit confusing to me is the fact that I noticed the difference in padding when looking at the value of  <variable>.cfg.pad. This is the number that is used in the algorithm, and which relates to the lengthy paragraph above.
 When I looked a bit further, in <variable>.cfg.callinfo.usercfg.pad I noticed the ’nextpow2’, which is the default value that you also reported in your e-mail. So, somehow FieldTrip’s translation of ’nextpow2’ into a numeric value for padding was different
 in the two versions. Then I recursed into the function call history, and noticed that the call to ft_freqanalysis was preceded by a call to ft_timelockanalysis. Now my suspicion is that it could be that there was a change in the code of ft_timelockanalysis,
 between end 2018 and 2019. This indeed seems to be the case. The cfg to ft_timelockanalysis contained an option cfg.latency = [1 9]. This option, however, was not functional in the 2018 version (I tried it myself and got a warning that the option cfg.latency
 was forbidden, and removed from the cfg). In the 2019 version the latency selection was functional. In other words, when subjecting the data to ft_timelockanalysis of 2018 did NOT lead to a cutting of 8 seconds of data, and hence to potentially longer than
 8 seconds of data that served as an input into ft_freqanalysis, which consequently translated ’nextpow2’ into 16 seconds of padded with 0’s data, rather than the value of 8 in the 2019 version.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I hope this helps, I am going back to BWV867 now.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Best wishes,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Jan-Mathijs<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On 3 Mar 2023, at 20:50, Harris, Alison via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl">fieldtrip@science.ru.nl</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="color:#212121">Dear FieldTrip community,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">My name is Alison Harris and I have been using FieldTrip functions for time-frequency analysis for several years now as part of my EEG research. However, I recently attempted to re-analyze some old data using
 ft_freqanalysis in the latest version of FieldTrip, and the output does not match my earlier results.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">I am trying to perform a frequency analysis for a motor execution task with alternating 8-s periods of finger-tapping and rest. The two conditions are preprocessed in EEGLAB and then separately imported to FieldTrip
 for frequency analysis. The cfg and command are as follows:</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg = [];</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg.method = 'mtmfft';</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg.output = 'pow';</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg.keeptrials       = 'no';</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg.keeptapers       = 'no';</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg.foi = [1:30];</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg.taper = 'dpss';</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg.tapsmofrq  = 1;</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    freqcfg.pad              = 'nextpow2';</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">   <span class="apple-converted-space"> </span>freqcfg.feedback         = 'text';</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">    [freqdata] = ft_freqanalysis(freqcfg,tldata);</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">When I initially ran this analysis in 2019, the power spectra for action and rest conditions were largely overlapping. However, when I reran the analysis earlier this week (using the same data and cfg), the two
 power spectra were offset, such that one power spectrum was noticeably lower on the y-axis than the other. For the two participants I examined, there was not a consistent pattern in terms of which power spectrum was offset: the power spectrum for the finger-tapping
 condition was higher in one, whereas the resting power spectrum was lower in the other.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">I then tested out my program with two earlier versions of FieldTrip that were available for download: fieldtrip-20191231 and fieldtrip-20191213. The change in the output of ft_freqanalysis seems to date to the
 2019 version, as the 2018 output looked more similar to my existing results from a previous version of FieldTrip. I also tried specifying the “polyremoval” parameter, and redid the preprocessing in EEGLAB with and without detrending, but none of these changes
 seem to fundamentally affect the offset of the power spectra.<span class="apple-converted-space"> </span></span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">Here is a link with data from two participants and plots of the power spectra from before and after 2019:<span class="apple-converted-space"> </span><a href="https://urldefense.com/v3/__https:/claremontmckenna.box.com/s/gu796rvvsgipnwkm4cb13k5fhtdpu5f0__;!!HJOPV4FYYWzcc1jazlU!_AWV1fOSVX5tHme3OeHf6q76srFJ4TcvvLtenRnbF2VDh6fOQW4CMFSLoytvKYc-XQQjU18ERSfYG-nv1jeraFpKi4vjyHuaNupSNy8$" title="https://claremontmckenna.box.com/s/gu796rvvsgipnwkm4cb13k5fhtdpu5f0"><span style="color:#0078D7">https://claremontmckenna.box.com/s/gu796rvvsgipnwkm4cb13k5fhtdpu5f0</span></a>.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">Is there some difference in how the ft_freqanalysis command is called from 2019 onward that would explain this output?<span class="apple-converted-space"> </span></span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">Thank you for your help!</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121">Alison Harris</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#212121"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">--</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Alison Harris, PhD</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Ostby-Cook Associate Professor of Psychology & George R. Roberts Fellow</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Claremont McKenna College</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">850 Columbia Avenue</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Claremont, CA 91711</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Phone: (909) 607-9397</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Email: <a href="mailto:aharris@cmc.edu" title="mailto:aharris@cmc.edu"><span style="color:#0563C1">aharris@cmc.edu</span></a></span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Web: <a href="https://urldefense.com/v3/__https:/www1.cmc.edu/pages/faculty/aharris__;!!HJOPV4FYYWzcc1jazlU!_AWV1fOSVX5tHme3OeHf6q76srFJ4TcvvLtenRnbF2VDh6fOQW4CMFSLoytvKYc-XQQjU18ERSfYG-nv1jeraFpKi4vjyHua46XzWYw$" title="https://www1.cmc.edu/pages/faculty/aharris"><span style="color:#0563C1">https://www1.cmc.edu/pages/faculty/aharris</span></a></span><o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt"> </span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Helvetica",sans-serif">_______________________________________________<br>
fieldtrip mailing list<br>
</span><a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip"><span style="font-size:10.5pt;font-family:"Helvetica",sans-serif;color:#0563C1">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</span></a><span style="font-size:10.5pt;font-family:"Helvetica",sans-serif"><br>
</span><a href="https://urldefense.com/v3/__https:/doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!6-XHrlUkkd_1vVSBACjQ5qHDM_nHf2XPA6MhiyMtazq0wT8M-I6yHJf_JCkX0wwtBcqY4Id84no93eWi4zDChGcV9iQ5SThIWVw8vg$"><span style="font-size:10.5pt;font-family:"Helvetica",sans-serif;color:#0563C1">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!6-XHrlUkkd_1vVSBACjQ5qHDM_nHf2XPA6MhiyMtazq0wT8M-I6yHJf_JCkX0wwtBcqY4Id84no93eWi4zDChGcV9iQ5SThIWVw8vg$</span></a><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>