<div dir="ltr">Hi Simon,<div><br></div><div>Then it might be something else. As I said, I checked yesterday in the latest SPM and it looks OK but there might be some code differences. We don't update our bemcp version every time we update the core FT. The approach Robert used and he might still have the script for it is to make a mesh for a single sphere and compare the bemcp solution for it with the analytical one. </div><div><br></div><div>Vladimir</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 17, 2016 at 9:34 AM, Simon Van Eyndhoven <span dir="ltr"><<a href="mailto:Simon.VanEyndhoven@esat.kuleuven.be" target="_blank">Simon.VanEyndhoven@esat.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 style="font-size:10pt;font-family:Verdana,Geneva,sans-serif">
<p>Hello Vladimir,</p>
<p>Thank you for the swift response. I made sure to place the source at varying distances from the skull, to preclude any effect because of this. More precisely, I tried the following approach:</p>
<p>--<span class=""><br>elec = ft_read_sens('standard_1020.<wbr>elc')<br></span>chan_name = 'F8';<br>chan_index = find(strcmp(elec.label,chan_<wbr>name));<br>chan_pos = elec.elecpos(chan_index,:);</p>
<p>[...]</p>
<p><br>cfg.dip.pos = 0.3*chan_pos;   % I tried distances ranging from 0.3*chan_pos to 0.9*chan_pos<br>--</p>
<p>For any distance from the skull the model yielded a nonsensical output as described earlier. This leads me to believe that this distance is not the determining factor here...</p><span class="">
<p>Best regards,</p>
<p>-- </p>
<div class="m_8651762221180979001pre" style="margin:0;padding:0;font-family:monospace">Simon Van Eyndhoven</div>
<div class="m_8651762221180979001pre" style="margin:0;padding:0;font-family:monospace"><br> PhD researcher<br> Stadius Center for Dynamical Systems, Signal Processing and Data Analytics<br> KU Leuven, Dept. Electrical Engineering (ESAT)<br> <br> email: <a href="mailto:simon.vaneyndhoven@esat.kuleuven.be" target="_blank">simon.vaneyndhoven@esat.<wbr>kuleuven.be</a><br><br></div>
</span><div><div class="h5"><p>On 2016-11-16 16:14, Vladimir Litvak wrote:</p>
<blockquote type="cite" style="padding:0 0.4em;border-left:#1010ff 2px solid;margin:0">
<div dir="ltr">Dear Simon,
<div> </div>
<div>I tested this before and now re-tested again using the versions of FT and BEMCP which come with SPM and should be quite recent. For SPM cortical mesh where we take special measures to make sure that it's far enough from the boundary the correlation coefficients between BEMCP and 3-spheres model are all above 0.9.  You say you varied the depth but have you varied it enough? What 'enough' is depends on the density of your head meshes. For SPM meshes it was more than 6mm from the boundary. The difference between different BEM methods is how close you can get to the boundary without breaking. BEMCP is the simplest method which is not very good in this respect. dipoli or OpenMEEG will also break but closer to the surface.</div>
<div> </div>
<div>Best,</div>
<div> </div>
<div>Vladimir</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Nov 16, 2016 at 1:07 PM, Simon Van Eyndhoven <span><<a href="mailto:Simon.VanEyndhoven@esat.kuleuven.be" target="_blank">Simon.VanEyndhoven@esat.<wbr>kuleuven.be</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br> <br> I recently started using FieldTrip in order to simulate pseudo-realistic EEG recordings from e.g. a set of dipoles located in the brain.<br> Therefore, I tried to follow the tutorial on the construction of a BEM head model based on an anatomical MRI scan and an electrode set: <a href="http://www.fieldtriptoolbox.org/tutorial/headmodel_eeg_bem" target="_blank">http://www.fieldtriptoolbox.or<wbr>g/tutorial/headmodel_eeg_bem</a> .<br> <br> The problem is that I don't succeed to reproduce the head model that is distributed as a template in the FieldTrip toolbox: '/template/headmodel/standard_<wbr>bem.mat'. I start from the template MRI scan in FieldTrip ('standard_mri.mat') and use the following code (taken from the tutorial).<br> <br> ---<br> % Load MRI data and electrode setup<br> mri = importdata('standard_mri.mat')<wbr>;<br> elec = ft_read_sens('standard_1020.el<wbr>c')<br> <br> % Segment the MRI volume<br> cfg = [];<br> cfg.output = {'brain','skull','scalp'};<br> segmentedmri  = ft_volumesegment(cfg, mri);<br> <br> % Create a mesh<br> cfg = [];<br> cfg.tissue = {'brain','skull','scalp'};<br> cfg.numvertices = [1500 1000 500];<br> bnd = ft_prepare_mesh(cfg,segmentedm<wbr>ri);<br> <br> % Construct the headmodel<br> cfg = [];<br> cfg.conductivity = [0.3300 0.0041 0.3300];<br> cfg.method = 'dipoli';<br> vol = ft_prepare_headmodel(cfg, bnd);<br> ---<br> <br> The following error is thrown:<br> <br> "Fatal error in dipoli: during computation of B-matrix;<br>  vertex 916 of /tmp/tp39371164882184732_1.tri touches triangle 811 of /tmp/tp39371164882184732_2.tri<wbr>"<br> <br> I've tried to create meshes with different numbers of vertices (e.g. the combination from the website tutorial 'numvertices = [3000 2000 1000]' produces the same error): for some combinations this problem does not occur, luckily. However, I wonder how the template model (that used the aforementioned number of vertices) got created successfully; I want to make sure that I work in the correct way and don't forget something.<br> <br> Can anyone shed some light on this issue, or hint what might be wrong/missing in the implementation above, compared to the template results that are provided in the FieldTrip distribution?<br> <br> Moreover, I've tried to create the head model using the 'bemcp' method as well. As a test, I placed a dipole close to the scalp surface, near a particular electrode. It is hence expected that the recorded amplitudes are highest for electrodes in the vicinity of this electrode. This effect is correctly reproduced when performing the computation of the forward problem using the 'standard_bem.mat' head model mentioned above (using the 'dipoli' method). By contrast, the output of the forward problem using the bemcp-based head model shows a topographic distribution with many positive 'peaks' and negative 'troughs', spread kind of randomly over the scalp surface. Since neither the segmentation step nor meshing step changed (only the final step, namely the creation of the volume conduction model), I have no clue why this problem occurs. I've looked around in the discussion list's archives for possible causes:<br> - it is reported that the bemcp method does not behave well if the dipole is located (very) close to the skull: I ruled this out for my problem by varying this distance<br> - one user (Debora Desideri) reported a problem with the bemcp-method that appears to be very similar to mine, but there was no reply to her problem...<br> - another user (John Richards) calls for caution when using the bemcp-method, stating that it behaves poorly sometimes<br> <br> Has anyone experienced similar issues when using the 'becmp' method and maybe found an explanation for this?<br> <br> Thanks in advance for any help!<br> <br> Best regards,<br> <br> -- <br> Simon Van Eyndhoven<br> <br> PhD researcher<br> Stadius Center for Dynamical Systems, Signal Processing and Data Analytics<br> KU Leuven, Dept. Electrical Engineering (ESAT)<br> <br> email: <a href="mailto:simon.vaneyndhoven@esat.kuleuven.be" target="_blank">simon.vaneyndhoven@esat.kuleuv<wbr>en.be</a><br> <br> ______________________________<wbr>_________________<br> fieldtrip mailing list<br> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br> <a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a></blockquote>
</div>
</div>
<br>
<div class="m_8651762221180979001pre" style="margin:0;padding:0;font-family:monospace">______________________________<wbr>_________________<br> fieldtrip mailing list<br> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br> <a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a></div>
</blockquote>
<div> </div>
</div></div></div>
<br>______________________________<wbr>_________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>