<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Caro Luca,
<div class=""><br class="">
</div>
<div class="">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 class="">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 class=""><br class="">
</div>
<div class="">You should work with the ‘mom’ field at the source level.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class=""><br class="">
</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 27 May 2020, at 09:33, Luca La Fisca <<a href="mailto:534843@umons.ac.be" class="">534843@umons.ac.be</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Dear community,
<div class=""><br class="">
</div>
<div class="">I'm Luca La Fisca, PhD student in Belgium and I'm validating the source reconstruction algorithm using "ft_dipolesimulation".</div>
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">Timelock:</div>
<div class="">
<div class=""><span id="cid:ii_kap0i9980"><image.png></span><br class="">
</div>
</div>
<div class=""><br class="">
</div>
<div class="">Reconstructed sources:</div>
<div class="">
<div class=""><span id="cid:ii_kap0m1941"><image.png></span><br class="">
</div>
</div>
<div class=""><br class="">
</div>
<div class="">Here is the code used to get the timelock signal:</div>
<div class=""><font color="#999999" class="">fs = 2048;</font></div>
<div class=""><font color="#999999" class="">fs_down = 512;</font></div>
<div class=""><font color="#999999" class=""><br class="">
</font></div>
<div class=""><font color="#999999" class="">% generate EEG pseudo-signal<br class="">
cfg      = [];<br class="">
cfg.headmodel = vol;<br class="">
cfg.elec = elec_aligned;<br class="">
cfg.channel = elec_aligned.label(1:64);<br class="">
<br class="">
cfg.dip.pos = [<br class="">
   -1 65 36           % dipole left<br class="">
   1 -62 43          % dipole right<br class="">
   ];<br class="">
<br class="">
unif_dip = 3^(1/2)/3;<br class="">
cfg.dip.mom = ...       <br class="">
  [ unif_dip unif_dip unif_dip 0 0 0 ]' + ...<br class="">
  [ 0 0 0 unif_dip unif_dip unif_dip ]';<br class="">
<br class="">
event = ft_read_event(EEG_FILE);<br class="">
event = event(3:end);<br class="">
signal1 = zeros(length(eeg_data.trial));<br class="">
signal2 = zeros(length(eeg_data.trial));<br class="">
val = [event.value];<br class="">
for s = drange([event(val==10).sample, event(val==11).sample, event(val==12).sample])<br class="">
    time = (0:ceil(fs*0.5))/fs;<br class="">
    signal1(s:s+ceil(fs*0.5)) = 10*sin(10*time*2*pi);<br class="">
    signal2(s:s+ceil(fs*0.5)) = 30*cos(85*time*2*pi);<br class="">
end<br class="">
<br class="">
cfg.dip.signal = {[signal1; signal2]};<br class="">
cfg.fsample = fs;<br class="">
raw1 = ft_dipolesimulation(cfg);<br class="">
<br class="">
% Timelock analysis<br class="">
% define trials<br class="">
cfg = [];<br class="">
cfg.dataset = EEG_FILE;<br class="">
cfg.trialdef.eventtype  = 'STATUS';<br class="">
cfg.trialdef.eventvalue = [10 11 12];<br class="">
cfg.trialdef.prestim    = 0.5;<br class="">
cfg.trialdef.poststim   = 1; <br class="">
cfg = ft_definetrial(cfg);<br class="">
data_trial = ft_redefinetrial(cfg, raw1);<br class="">
<br class="">
% downsample<br class="">
cfg = [];<br class="">
cfg.resamplefs = fs_down;<br class="">
data_trial = ft_resampledata(cfg,data_trial);<br class="">
<br class="">
cfg = [];<br class="">
timelock = ft_timelockanalysis(cfg, data_trial);</font><br class="">
</div>
<div class=""><font color="#999999" class=""><br class="">
</font></div>
<div class=""><font class=""><br class="">
</font></div>
<div class=""><font class="">Here the code related to the source reconstruction:</font></div>
<div class=""><font color="#999999" class="">% Estimating the leadfield<br class="">
cfg = [];<br class="">
cfg.sourcemodel = sourcemodel;    %% where are the sources?<br class="">
cfg.headmodel   = vol;      %% how do currents spread?<br class="">
cfg.elec        = elec_aligned; %% where are the sensors?<br class="">
cfg.channel = elec_aligned.label(1:64);<br class="">
sourcemodel_and_leadfield = ft_prepare_leadfield(cfg, timelock);<br class="">
<br class="">
% Source reconstruction<br class="">
cfg                     = [];<br class="">
cfg.method              = 'mne';                    <br class="">
cfg.sourcemodel         = sourcemodel_and_leadfield;        %the precomputed leadfield<br class="">
cfg.headmodel           = vol;                      %the head model<br class="">
cfg.elec                = elec_aligned;             %the electrodes<br class="">
cfg.channel             = elec_aligned.label(1:64); %the useful channels<br class="">
cfg.mne.prewhiten       = 'yes';                    %prewhiten data<br class="">
cfg.mne.lambda          = 0.01;                     %regularisation parameter<br class="">
cfg.mne.scalesourcecov  = 'yes';                %scaling the source covariance matrix<br class="">
minimum_norm_eeg        = ft_sourceanalysis(cfg,timelock);</font><font class=""><br class="">
</font></div>
<div class=""><br class="">
</div>
<div class=""><font class="">Here the code to perform the frequency analysis:</font></div>
<div class=""><font color="#999999" class="">tmp_pow = minimum_norm_eeg.avg.pow;<br class="">
pow_fft = fft(tmp_pow'); %freq analysis of reconstructed sources<br class="">
% pow_fft = fft(timelock.avg'); %freq analysis of timelock signal<br class="">
% (un)comment depending on the desired one<br class="">
<br class="">
L = length(timelock.avg);<br class="">
f = fs_down*(0:(L/2))/L;<br class="">
<br class="">
P2 = abs(pow_fft/L);<br class="">
P1 = P2(1:L/2+1,:);<br class="">
P1 = P1.*f';<br class="">
<br class="">
figure()<br class="">
plot(f,P1)<br class="">
title('Single-Sided Amplitude Spectrum of Reconstructed Sources')<br class="">
xlabel('f (Hz)')<br class="">
ylabel('|P1(f)|')</font><font class=""><br class="">
</font></div>
<div class=""><br class="">
</div>
<div class="">Do you have any idea of what is responsible to this double frequency?<br class="">
Do you think it is a general issue?</div>
<div class="">Is it a major issue leading to wrong analysis of the reconstructed signal (e.g. connectivity analysis)?</div>
<div class=""><br class="">
</div>
<div class="">I thank you in advance.</div>
<div class=""><br class="">
</div>
<div class="">Best regards,</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div style="text-align:left" class=""><img src="https://docs.google.com/uc?export=download&id=1kIixsLbG6VMY0eKRmD_V2qGfWdocai3Y&revid=0B-dw3epKQGxwWWNSYThqWVJCZjZYOGJtNnljTHg1OGR5WFNJPQ" width="96" height="34" class=""></div>
<div style="text-align:left" class=""><b class="">Luca La Fisca</b><br class="">
</div>
<div style="text-align:left" class=""><b class=""><span lang="FR" style="color:gray" class="">PhD Student</span></b></div>
<div style="text-align:left" class=""><span style="color:rgb(192,0,0)" class="">Service d'Information, Signal et Intelligence Artificielle</span><br class="">
</div>
<div style="text-align:left" class="">
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)" class="">Boulevard Dolez, 31</span><span lang="FR" class=""><u class=""></u><u class=""></u></span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)" class="">7000 Mons</span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)" class="">+32 (0)65/37.40.83</span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)" class=""><u style="color:rgb(34,34,34)" class=""><span lang="FR" style="" class=""><span style="color:blue" class=""><span class=""><a href="mailto:Luca.LAFISCA@umons.ac.be" style="color:rgb(17,85,204)" target="_blank" class="">Luca.LAFISCA@umons.ac.be</a></span></span></span></u><br class="">
</span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)" class=""><u style="color:rgb(34,34,34)" class=""><span lang="FR" style="" class=""><span style="color:blue" class=""><br class="">
</span></span></u></span></p>
<p class="MsoNormal"><span lang="FR" style="color:rgb(166,166,166)" class=""><u style="color:rgb(34,34,34)" class=""><span lang="FR" style="" class=""><span style="color:blue" class=""><img src="https://docs.google.com/uc?export=download&id=1Os8PgOWiHRZwQs_oiXqKDg2gkH2mcJDb&revid=0B-dw3epKQGxweUxueTZMZzRNd2pYR1docldnQzJzWExCWGpFPQ" width="200" height="58" class=""><br class="">
</span></span></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" class=""><br class="">
<table style="border-top:1px solid #d3d4de" class="">
<tbody class="">
<tr class="">
<td style="width:55px;padding-top:18px" class=""><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" class=""><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;" class=""></a></td>
<td style="width:470px;padding-top:17px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px" class="">
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" class="">
www.avast.com</a> </td>
</tr>
</tbody>
</table>
<a href="x-msg://5/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1" class=""></a></div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://doi.org/10.1371/journal.pcbi.1002202<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>