<div dir="ltr">Dear Jan-Mathijs,<div><br></div><div>It is exactly the problem! </div><div><br></div><div>Thank you very much :)</div><div><br></div><div>Have a nice day,<br><br class="gmail-Apple-interchange-newline"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="text-align:left"><img src="https://docs.google.com/uc?export=download&id=1kIixsLbG6VMY0eKRmD_V2qGfWdocai3Y&revid=0B-dw3epKQGxwWWNSYThqWVJCZjZYOGJtNnljTHg1OGR5WFNJPQ" width="96" height="34"></div><div style="text-align:left"><b>Luca La Fisca</b><br></div><div style="text-align:left"><b><span lang="FR" style="color:gray">PhD Student</span></b></div><div style="text-align:left"><span style="color:rgb(192,0,0)">Service d'Information, Signal et Intelligence Artificielle</span><br></div><div style="text-align:left"><p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)">Boulevard Dolez, 31</span><span lang="FR"><u></u><u></u></span></p><p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)">7000 Mons</span></p><p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)">+32 (0)65/37.40.83</span></p><p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)"><u style="color:rgb(34,34,34)"><span lang="FR" style="color:black"><span style="color:blue"><span><a href="mailto:Luca.LAFISCA@umons.ac.be" style="color:rgb(17,85,204)" target="_blank">Luca.LAFISCA@umons.ac.be</a></span></span></span></u><br></span></p><p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)"><u style="color:rgb(34,34,34)"><span lang="FR" style="color:black"><span style="color:blue"><br></span></span></u></span></p><p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)"><u style="color:rgb(34,34,34)"><span lang="FR" style="color:black"><span style="color:blue"><img src="https://docs.google.com/uc?export=download&id=1Os8PgOWiHRZwQs_oiXqKDg2gkH2mcJDb&revid=0B-dw3epKQGxweUxueTZMZzRNd2pYR1docldnQzJzWExCWGpFPQ" width="200" height="58"><br></span></span></u></span></p></div></div></div></div></div></div></div></div></div></div></div></div><br></div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br> <table style="border-top:1px solid #d3d4de">
        <tr>
      <td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
                <td style="width:470px;padding-top:17px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Garanti sans virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" style="color:#4453ea">www.avast.com</a>           </td>
        </tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 27, 2020 at 10:15 AM Schoffelen, J.M. (Jan Mathijs) <<a href="mailto:jan.schoffelen@donders.ru.nl">jan.schoffelen@donders.ru.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div style="overflow-wrap: break-word;">
Caro Luca,
<div><br>
</div>
<div>I haven’t read your code in detail, but I suspect that you perform a spectral analysis on the source.avg.pow, which is the magnitude(-squared) version of the signal’s time course.</div>
<div>As a consequence of this, your frequency ‘doubles’. Consider a sine wave with a given frequency (i.e. a period of 1/f), say 1 Hz. If you take that absolute(-squared) of that sine wave, you get a signal with ’two bumps’ per second, which reflects
 a periodicity of 2 Hz.</div>
<div><br>
</div>
<div>You should work with the ‘mom’ field at the source level.</div>
<div><br>
</div>
<div>Best wishes,</div>
<div><br>
</div>
<div>Jan-Mathijs</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>On 27 May 2020, at 09:33, Luca La Fisca <<a href="mailto:534843@umons.ac.be" target="_blank">534843@umons.ac.be</a>> wrote:</div>
<br>
<div>
<div dir="ltr">Dear community,
<div><br>
</div>
<div>I'm Luca La Fisca, PhD student in Belgium and I'm validating the source reconstruction algorithm using "ft_dipolesimulation".</div>
<div><br>
</div>
<div>After having performed a frequency analysis, I noticed the reconstructed sources have twice the initial frequencies as shown in the following figures (initial dipole frequencies = 10 and 85 Hz) :</div>
<div><br>
</div>
<div>Timelock:</div>
<div>
<div><span id="gmail-m_8293927082035701930cid:ii_kap0i9980"><image.png></span><br>
</div>
</div>
<div><br>
</div>
<div>Reconstructed sources:</div>
<div>
<div><span id="gmail-m_8293927082035701930cid:ii_kap0m1941"><image.png></span><br>
</div>
</div>
<div><br>
</div>
<div>Here is the code used to get the timelock signal:</div>
<div><font color="#999999">fs = 2048;</font></div>
<div><font color="#999999">fs_down = 512;</font></div>
<div><font color="#999999"><br>
</font></div>
<div><font color="#999999">% generate EEG pseudo-signal<br>
cfg      = [];<br>
cfg.headmodel = vol;<br>
cfg.elec = elec_aligned;<br>
cfg.channel = elec_aligned.label(1:64);<br>
<br>
cfg.dip.pos = [<br>
   -1 65 36           % dipole left<br>
   1 -62 43          % dipole right<br>
   ];<br>
<br>
unif_dip = 3^(1/2)/3;<br>
cfg.dip.mom = ...       <br>
  [ unif_dip unif_dip unif_dip 0 0 0 ]' + ...<br>
  [ 0 0 0 unif_dip unif_dip unif_dip ]';<br>
<br>
event = ft_read_event(EEG_FILE);<br>
event = event(3:end);<br>
signal1 = zeros(length(eeg_data.trial));<br>
signal2 = zeros(length(eeg_data.trial));<br>
val = [event.value];<br>
for s = drange([event(val==10).sample, event(val==11).sample, event(val==12).sample])<br>
    time = (0:ceil(fs*0.5))/fs;<br>
    signal1(s:s+ceil(fs*0.5)) = 10*sin(10*time*2*pi);<br>
    signal2(s:s+ceil(fs*0.5)) = 30*cos(85*time*2*pi);<br>
end<br>
<br>
cfg.dip.signal = {[signal1; signal2]};<br>
cfg.fsample = fs;<br>
raw1 = ft_dipolesimulation(cfg);<br>
<br>
% Timelock analysis<br>
% define trials<br>
cfg = [];<br>
cfg.dataset = EEG_FILE;<br>
cfg.trialdef.eventtype  = 'STATUS';<br>
cfg.trialdef.eventvalue = [10 11 12];<br>
cfg.trialdef.prestim    = 0.5;<br>
cfg.trialdef.poststim   = 1; <br>
cfg = ft_definetrial(cfg);<br>
data_trial = ft_redefinetrial(cfg, raw1);<br>
<br>
% downsample<br>
cfg = [];<br>
cfg.resamplefs = fs_down;<br>
data_trial = ft_resampledata(cfg,data_trial);<br>
<br>
cfg = [];<br>
timelock = ft_timelockanalysis(cfg, data_trial);</font><br>
</div>
<div><font color="#999999"><br>
</font></div>
<div><font><br>
</font></div>
<div><font>Here the code related to the source reconstruction:</font></div>
<div><font color="#999999">% Estimating the leadfield<br>
cfg = [];<br>
cfg.sourcemodel = sourcemodel;    %% where are the sources?<br>
cfg.headmodel   = vol;      %% how do currents spread?<br>
cfg.elec        = elec_aligned; %% where are the sensors?<br>
cfg.channel = elec_aligned.label(1:64);<br>
sourcemodel_and_leadfield = ft_prepare_leadfield(cfg, timelock);<br>
<br>
% Source reconstruction<br>
cfg                     = [];<br>
cfg.method              = 'mne';                    <br>
cfg.sourcemodel         = sourcemodel_and_leadfield;        %the precomputed leadfield<br>
cfg.headmodel           = vol;                      %the head model<br>
cfg.elec                = elec_aligned;             %the electrodes<br>
cfg.channel             = elec_aligned.label(1:64); %the useful channels<br>
cfg.mne.prewhiten       = 'yes';                    %prewhiten data<br>
cfg.mne.lambda          = 0.01;                     %regularisation parameter<br>
cfg.mne.scalesourcecov  = 'yes';                %scaling the source covariance matrix<br>
minimum_norm_eeg        = ft_sourceanalysis(cfg,timelock);</font><font><br>
</font></div>
<div><br>
</div>
<div><font>Here the code to perform the frequency analysis:</font></div>
<div><font color="#999999">tmp_pow = minimum_norm_eeg.avg.pow;<br>
pow_fft = fft(tmp_pow'); %freq analysis of reconstructed sources<br>
% pow_fft = fft(timelock.avg'); %freq analysis of timelock signal<br>
% (un)comment depending on the desired one<br>
<br>
L = length(timelock.avg);<br>
f = fs_down*(0:(L/2))/L;<br>
<br>
P2 = abs(pow_fft/L);<br>
P1 = P2(1:L/2+1,:);<br>
P1 = P1.*f';<br>
<br>
figure()<br>
plot(f,P1)<br>
title('Single-Sided Amplitude Spectrum of Reconstructed Sources')<br>
xlabel('f (Hz)')<br>
ylabel('|P1(f)|')</font><font><br>
</font></div>
<div><br>
</div>
<div>Do you have any idea of what is responsible to this double frequency?<br>
Do you think it is a general issue?</div>
<div>Is it a major issue leading to wrong analysis of the reconstructed signal (e.g. connectivity analysis)?</div>
<div><br>
</div>
<div>I thank you in advance.</div>
<div><br>
</div>
<div>Best regards,</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div style="text-align:left"><img src="https://docs.google.com/uc?export=download&id=1kIixsLbG6VMY0eKRmD_V2qGfWdocai3Y&revid=0B-dw3epKQGxwWWNSYThqWVJCZjZYOGJtNnljTHg1OGR5WFNJPQ" width="96" height="34"></div>
<div style="text-align:left"><b>Luca La Fisca</b><br>
</div>
<div style="text-align:left"><b><span lang="FR" style="color:gray">PhD Student</span></b></div>
<div style="text-align:left"><span style="color:rgb(192,0,0)">Service d'Information, Signal et Intelligence Artificielle</span><br>
</div>
<div style="text-align:left">
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)">Boulevard Dolez, 31</span><span lang="FR"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)">7000 Mons</span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)">+32 (0)65/37.40.83</span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)"><u style="color:rgb(34,34,34)"><span lang="FR"><span style="color:blue"><span><a href="mailto:Luca.LAFISCA@umons.ac.be" style="color:rgb(17,85,204)" target="_blank">Luca.LAFISCA@umons.ac.be</a></span></span></span></u><br>
</span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)"><u style="color:rgb(34,34,34)"><span lang="FR"><span style="color:blue"><br>
</span></span></u></span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)"><u style="color:rgb(34,34,34)"><span lang="FR"><span style="color:blue"><img src="https://docs.google.com/uc?export=download&id=1Os8PgOWiHRZwQs_oiXqKDg2gkH2mcJDb&revid=0B-dw3epKQGxweUxueTZMZzRNd2pYR1docldnQzJzWExCWGpFPQ" width="200" height="58"><br>
</span></span></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="gmail-m_8293927082035701930DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid rgb(211,212,222)">
<tbody>
<tr>
<td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
<td style="width:470px;padding-top:17px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">
Garanti sans virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" style="color:rgb(68,83,234)" target="_blank">
www.avast.com</a> </td>
</tr>
</tbody>
</table>
<a width="1" height="1"></a></div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</div>
</blockquote>
</div>
<br>
</div>
</div>

_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote></div>