<div dir="ltr"><div><br></div><div>Dear FieldTrip community,</div><div><br></div><div>I came across a problem when using dB baseline correction for single trial power-spectrum time courses. My problem is that all values turn to be negative, even in the baseline. When I averaged across trials and subjects, to see if this was noise, I found that the values in the baseline were around -1 dB. I am using revision 20220104.</div><div><br></div><div>When I inspected the function ft_freqbaseline, I came to see that the dB transformation is calculated after averaging the power in the temporal domain. That is:</div><div>I calculate power spectrum:</div><div>cfg=[];<br>cfg.method='mtmconvol';       %STFT<br>cfg.taper='hanning';       %Taper window used<br>cfg.pad='nextpow2';<br>cfg.foi=5:1:7;     %Frequencies of interest (in Hz)<br>cfg.toi=-0.5-0.24:0.05:1.5;<br>cfg.t_ftimwin=0.5*ones(length(cfg.foi),1);<br>cfg.keeptrials='yes';        %We will inspect only the average power<br>cfg.output='pow';<br></div><div>fdata=ft_freqanalysis(cfg,data);</div><div><br></div><div>In ft_freqbaseline:</div><div><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">meanVals </span><span class="gmail-pl-k" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">=</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-en" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">repmat</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">(</span><span class="gmail-pl-en" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">nanmean</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">(</span><span class="gmail-pl-en" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">data</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">(</span><span class="gmail-pl-k" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">:</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">,</span><span class="gmail-pl-k" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">:</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">,</span><span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">baselineTimes</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">), </span><span class="gmail-pl-c1" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">3</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">), [</span><span class="gmail-pl-c1" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">1</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-c1" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">1</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-en" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">size</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">(</span><span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">data</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">, </span><span class="gmail-pl-c1" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">3</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">)]);</span><br></div><div>Then, the dB transform is calculated as follows:</div><div><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre"> data </span><span class="gmail-pl-k" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">=</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-c1" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">10</span><span class="gmail-pl-k" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">*</span><span class="gmail-pl-en" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">log10</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">(</span><span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">data</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-k" style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">./</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">meanVals</span><span style="color:rgb(36,41,47);font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;white-space:pre">);</span><br></div><div><br></div><div>As I mentioned, when I apply this procedure to my data using the following setting:</div><div>cfg=[];<br>cfg.baseline=[-0.5 0];<br>cfg.baselinetype='db';<br>fdata_baseline=ft_freqbaseline(cfg,fdata);<br></div><div><br></div><div> I get very negative values in the baseline. However, if I first do the transform and then the baseline like this:<br></div><div><br></div><div>cfg=[];<br>cfg.operation='10*log10(x1)';<br>cfg.parameter='powspctrm';<br>fdata_log=ft_math(cfg,fdata);<br></div><div><br></div><div>cfg=[];<br>cfg.baseline=[-0.5 0];<br>cfg.baselinetype='absolute';<br>fdata_baseline=ft_freqbaseline(cfg,fdata_log);</div><div><br></div><div>Taking advantage of the properties of the logarithm, then for trial and subject averaged data I obtain what I should expect, that the values in the baseline period are small and fluctuating around zero.</div><div><br></div><div>I don't know, maybe the approach for calculating dB correction should be different for single and trial averaged power spectrum. Or maybe there was some error in my procedure.</div><div><br></div><div>Thanks in advance,</div><div><br></div><div>Mireia<br><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Mireia Torralba Cuello</div><div style="color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Multisensory Research Group </div><div style="color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Center for Brain and Cognition, Universitat Pompeu Fabra</div><div style="color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span lang="en">Address: Edifici Mercè Rodoreda 24.313<span title="Nom, número de despatx
                      "><br>
                      </span><span title="Ramon Trias Fargas, 25-27
                      ">c\ Ramon Trias Fargas, 25-27<br>
                      </span><span title="08005 Barcelona     ">08005
              Barcelona</span></span><br></div><div style="color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><a href="https://urldefense.com/v3/__http://www.mrg.upf.edu/__;!!HJOPV4FYYWzcc1jazlU!4sCV7xFJiK_VsVjZKxw5wNhPArLa1bmn6sjBfkf4XUH6MHmklClR3K21eGCks43NgrUUJ-t_-sYBqdsDMHjdgCs49R3n0Spy$" style="color:rgb(17,85,204)" target="_blank">http://www.mrg.upf.edu</a></div><div style="color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Tel <a value="+34935421382" style="color:rgb(17,85,204)">+34 935422745</a><br><br></div></div></div></div></div></div></div></div>