<div dir="ltr">Oh. Yes. <div>FT puts NaN's into sourcespace points outside the brain. You can constrain FT to only calculate leadfields for sourcespace points inside the brain. I generally do this. I don't know how FT handles those outside the brain source points really. You could give this a try.</div>
<div><br></div><div>Check this tutorial/code: </div><div><a href="http://fieldtrip.fcdonders.nl/tutorial/minimumnormestimate#forward_solution">http://fieldtrip.fcdonders.nl/tutorial/minimumnormestimate#forward_solution</a><br>
</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><div><font color="#000000">--</font></div><div><font color="#000000">Regards,<br></font></div><div><span style="font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div style="text-align:left">
<font color="#000000">Kousik Sarathy, S</font></div></span></div><div style="text-align:left"><br></div></div></div>
<br><br><div class="gmail_quote">On Wed, May 28, 2014 at 6:01 PM, Laura Rueda Delgado <span dir="ltr"><<a href="mailto:Laura.Rueda@faber.kuleuven.be" target="_blank">Laura.Rueda@faber.kuleuven.be</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="NL-BE" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Dear Kousik,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I checked for NaN and Inf values in powspctrm and crsspctrm of freqAll. There are none. However, I checked for NaN values in grid.leadfield and
it has some. I thought that these were NaN values in the points of the grid outside a brain region, but I might be mistaken.
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">grid =
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> xgrid: [-58 -48 -38 -28 -18 -8 2 12 22 32 42 52 62 72 82 92 102]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> ygrid: [-61 -51 -41 -31 -21 -11 -1 9 19 29 39 49 59]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> zgrid: [-13 -3 7 17 27 37 47 57 67 77 87 97 107 117]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> dim: [17 13 14]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">
</span><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">pos: [3094x3 double]<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> unit: 'mm'<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> inside: [1x1516 double]<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> outside: [1x1578 double]<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> cfg: [1x1 struct]<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> leadfield: {1x3094 cell}<u></u><u></u></span></p><div class="">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Best regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Laura Rueda Delgado<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
</div><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a> [mailto:<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a>]
<b>On Behalf Of </b>kousik sarathy<br>
<b>Sent:</b> woensdag 28 mei 2014 17:37</span></p><div><div class="h5"><br>
<b>To:</b> FieldTrip discussion list<br>
<b>Subject:</b> Re: [FieldTrip] Error in ft_sourceanalysis: DICS<u></u><u></u></div></div><p></p><div><div class="h5">
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal">Ah. Interesting. Good that error changes. So that was the problem before.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Now, can you check if your Freq matrices contain any NaN's (isnan(freqAll))? It can happen sometimes. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="color:black">--</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">Regards,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black;background:white">Kousik Sarathy, S</span><span style="font-size:10.0pt;font-family:"Arial","sans-serif";background:white"><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, May 28, 2014 at 5:31 PM, Laura Rueda Delgado <<a href="mailto:Laura.Rueda@faber.kuleuven.be" target="_blank">Laura.Rueda@faber.kuleuven.be</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Dear Kousik,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I checked the labels and they were the same, except for whether they were in capital
letters. So I added the following before ft_sourceanalysis:</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">freqAll.label=cellfun(@upper, freqAll.label,
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'UniformOutput'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">, 0);</span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">freqAll.labelcmb=cellfun(@upper, freqAll.labelcmb,
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'UniformOutput'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">, 0);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">This way the labels of the elec structure and freqAll are in capital letters.
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">And now I get a different error (although still within the function beamformer_dics):</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Error using svd</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Input to SVD must not contain NaN or Inf.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Error in beamformer_dics>pinv (line 650)</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> [U,S,V] = svd(A,0);</span><u></u><u></u></p>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Error in beamformer_dics (line 339)</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> filt = pinv(lf' * invCf * lf) * lf' * invCf; % Gross eqn. 3, use PINV/SVD to
cover rank</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> deficient leadfield</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Error in ft_sourceanalysis (line 567)</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> dip(i) = beamformer_dics(grid, sens, vol, [], squeeze(Cf(i,:,:)), optarg{:});</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">What could it be?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Best regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Laura</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a> [mailto:<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a>]
<b>On Behalf Of </b>kousik sarathy<br>
<b>Sent:</b> woensdag 28 mei 2014 17:10</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>To:</b> FieldTrip discussion list<br>
<b>Subject:</b> Re: [FieldTrip] Error in ft_sourceanalysis: DICS<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<div>
<p class="MsoNormal">Hey Laura,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I too had the same suggestion as Johanna's. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Another thing to check would be if the labels that you used for the leadfield estimation are the same as the freq data. I guess FT at some point would also check this to extract
the indices. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="color:black">--</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">Regards,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black;background:white">Kousik Sarathy, S</span><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Wed, May 28, 2014 at 4:51 PM, Laura Rueda Delgado <<a href="mailto:Laura.Rueda@faber.kuleuven.be" target="_blank">Laura.Rueda@faber.kuleuven.be</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Dear Johanna,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thank you for your suggestion.
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">On step 2 in the code, I select from the elec structure the channels that are included
in the frequency data. So the elec structure used for preparing the leadfield has 128 electrodes, the same as the data (data_rs, data 4, and therefore freqAll). I checked this precisely because I read a previous thread discussing that issue.
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Best regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Laura Rueda Delgado</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a> [mailto:<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a>]
<b>On Behalf Of </b>Johanna Zumer<br>
<b>Sent:</b> woensdag 28 mei 2014 16:42<br>
<b>To:</b> FieldTrip discussion list<br>
<b>Subject:</b> Re: [FieldTrip] Error in ft_sourceanalysis: DICS</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Hi Laura,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Does your data have the same channels as the leadfield (as the electrodes that went in to compute the leadfield)? I often see that error when there is a mismatch of channels in
that way.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Best,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Johanna<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> <u></u><u></u></p>
<div>
<p class="MsoNormal">2014-05-28 15:29 GMT+01:00 Laura Rueda Delgado <<a href="mailto:Laura.Rueda@faber.kuleuven.be" target="_blank">Laura.Rueda@faber.kuleuven.be</a>>:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Dear Fieldtrip users,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">I’m following the tutorial of beamformers (<a href="http://fieldtrip.fcdonders.nl/tutorial/beamformer" target="_blank">Source Analysis: Contrast activity to another
interval</a>) to estimate oscillatory sources using DICS. I’ve checked the surface created after segmentation and the grid generated from the electrode positions and the headmodel. That seems to work ok. However, at the step of source analysis, I get the following
error:</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Error using *
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Inner matrix dimensions must agree.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Error in beamformer_dics (line 339)</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> filt = pinv(lf' * invCf * lf) * lf' * invCf; % Gross eqn. 3, use PINV/SVD to cover rank</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> deficient leadfield</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Error in ft_sourceanalysis (line 567)</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> dip(i) = beamformer_dics(grid, sens, vol, [], squeeze(Cf(i,:,:)), optarg{:});</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Does anybody have an idea of what I’m doing wrong?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Thank you in advance for any help or suggestion!</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">-----------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">This is my code:</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">%% 1 - Preparation of MRI- source space</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% Read MRI</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">mrifile =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'Subject01\Subject01.mri'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">mri = ft_read_mri(mrifile);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% Reslice to reorient images</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg = [];
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.dim = [256 256 256];
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black">mri = ft_volumereslice(cfg,mri);
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% Segment compartments</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg = [];</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.output = {</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'brain'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">,</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'skull'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">,</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'scalp'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">};</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">segmentedmri = ft_volumesegment(cfg, mri);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% Prepare mesh</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg=[];</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.tissue={</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'brain'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">,
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'skull'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">,</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'scalp'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">};</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.numvertices = [3000 2000 1000];</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">bnd=ft_prepare_mesh(cfg,segmentedmri);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% Prepare headmodel</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg = [];</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.method =</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'bemcp'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">vol = ft_prepare_headmodel(cfg, bnd);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">%% 2- Prepare leadfield - Creating grid</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">load
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">elec_aligned2</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% Obtained after adjusting electrodes on scalp surface interactively</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% Three fiducial markers were added to the electrode file, and now they're</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% removed so that the electrode structure has the same number of channels as the data</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">elec_aligned2.chanpos = elec_aligned2.chanpos(1:128, :);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">elec_aligned2.elecpos = elec_aligned2.elecpos(1:128, :);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">elec_aligned2.label = elec_aligned2.label(1:128, :);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg =[];</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.vol = vol;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.elec = elec_aligned2;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.grid.resolution = 10;
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.grid.unit =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'mm'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">[grid] = ft_prepare_leadfield(cfg);
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">%% 3- Join rest and task data</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% data_rs: resting state data</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% data4: data during task</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">dataAll = ft_appenddata([], data_rs, data4);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg = [];</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.method =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'mtmfft'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.output =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'powandcsd'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.tapsmofrq = 4;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.foilim = [18 18];</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">freqAll = ft_freqanalysis(cfg, dataAll);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">%----------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">% all seems normal until here</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">%----------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:forestgreen">%% 4- Estimate source of all data</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg = [];</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.method =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'dics'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.frequency = 18;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.grid = grid;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.vol = vol;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.elec = elec_aligned2;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.dics.projectnoise =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'yes'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.dics.lambda =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'5%'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.dics.keepfilter =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'yes'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">cfg.dics.realfilter =
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'yes'</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New";color:black">sourceAll = ft_sourceanalysis(cfg, freqAll);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Cheers,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#888888"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#888888">Laura Rueda Delgado</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#888888"> </span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>