<div dir="ltr">Otherwise, does anyone know if I could compute the leadfield using another program and import it to fieldtrip?<div>Thank you once again,</div><div>Hoping to resolve this issue soon,</div><div>Roey</div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 18, 2014 at 3:16 PM, Roey Schurr <span dir="ltr"><<a href="mailto:roeysc@gmail.com" target="_blank">roeysc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Dear <span style="font-family:arial,sans-serif;font-size:13px">Daniel and all,</span><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">First, thank you very much for your advice and codes. They have proved very helpful, and now I have obtained some very good brain-skull-scalp meshes!</span></div>

<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">I am now having a problem using OPENMEEG to actually compute the leadfield based on these meshes, </span><span style="font-family:arial,sans-serif;font-size:13px">using the following code on frequency domain data:</span></div>

<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">cfg=[];</font></div>

<div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">cfg.method  = 'dics';</font></div><div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">cfg.elec = elec;</font></div>

<div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">cfg.grid = grid;</font></div><div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">cfg.vol = vol;</font></div>

<div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">cfg.frequency = 10; % The mean frequency in the band</font></div><div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">cfg.keepfilter  = 'yes';</font></div>

<div><font face="arial, sans-serif"><br></font></div><div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">sourceCombined = ft_sourceanalysis(cfg, freqCombined);</font></div>

</div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br></font></div><div><span style="font-family:arial,sans-serif;font-size:13px">The problem arises at the function "</span><font face="arial, sans-serif">ft_leadfield_openmeeg" who tries using OPENMEEG installed on my PC (indeed there is a warning "warning('Sorry, Windows is not yet tested');" in this function).</font></div>

<div><font face="arial, sans-serif">To fix onw of the bugs using a PC I changed line 94 to:</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><div>    basefile = tempname;</div>

<div>    [clearme basefile] = fileparts(basefile);</div><div>    clear clearme;</div></font></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">but even so, every line who tries to actually use OPENMEEG, such as line 149:</span></div>

<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif">   </span><span style="font-family:arial,sans-serif"> </span><font face="arial, sans-serif">system([fullfile(OPENMEEG_PATH, 'om_check_geom'), ' -g ', geomFile])</font><br>

</div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">fails to do so.</font></div><div><font face="arial, sans-serif">For instance, I get a Windows error window that says "om_assemble.exe has stopped working" and </font><span style="font-family:arial,sans-serif">"om_minverser.exe has stopped working", and also:</span></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><div>Computing inverse head matrix</div></span><span style="font-family:arial,sans-serif"><div>    187         system([fullfile(OPENMEEG_PATH, 'om_minverser'), ' ', hmFile, ' ', hminvFile]);</div>

</span><span style="font-family:arial,sans-serif"><div>    C:\OpenMEEG\bin\om_minverser version 2.1.0 (799) compiled at Aug 17 2011 19:50:11 </div><div> </div></span><span style="font-family:arial,sans-serif"><div>    | ------ C:\OpenMEEG\bin\om_minverser <br>

</div></span><span style="font-family:arial,sans-serif"><div>    | C:\Users\Roey\AppData\Local\Temp\ft-om\tp2f33a1b9_510f_4d55_805d_7ed6ce3b22e3_hm.bin </div></span><span style="font-family:arial,sans-serif"><div>    | C:\Users\Roey\AppData\Local\Temp\ft-om\tp2f33a1b9_510f_4d55_805d_7ed6ce3b22e3_hminv.bin </div>

</span><span style="font-family:arial,sans-serif"><div>    | ----------------------- </div></span><span style="font-family:arial,sans-serif"><div>    Exception: Unable to open the file C:\Users\Roey\AppData\Local\Temp\ft-om\tp2f33a1b9_510f_4d55_805d_7ed6ce3b22e3_hm.bin for reading Doing my best.... </div>

<div><br></div><div>So it seems like OPENMEEG cannot open the file ending with "_hm.bin". This file indeed does no exist.</div><div><br></div><div><br></div><div>I am using Matlab 2011b, full fieldtrip version of 17022014, Windows 7 64 bit, and OPENMEEG with om_assemble version 2.1.0 (799) compiled at Aug 17 2011 19:50:41.</div>

<div><br></div><div>Must I use a Macintosh or Linux computer to make this work?</div><div><br></div><div>Any ideas would be greatly appreciated!</div><div>Thank you very much in advance,</div><div><br></div><div>Roey</div>

</span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 20, 2014 at 8:10 PM, Daniel Wong <span dir="ltr"><<a href="mailto:dan.wong.c@utoronto.ca" target="_blank">dan.wong.c@utoronto.ca</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You can try using the new iso2mesh meshing option that was recently added by myself, Sarang Dalal, and Robert Oostenveld:<br>


<br>
cfg.method = 'iso2mesh';<br>
cfg.numvertices = 10000;   % We'll decimate later - this gives nicer results<br>
bnd = ft_prepare_mesh(cfg,seg);<br>
<br>
% Decimate to a 1000, 2000, 3000 node mesh (scalp, skull, brain)<br>
[bnd(1).pnt, bnd(1).tri] = meshresample(bnd(1).pnt, bnd(1).tri, 1000/size(bnd(1).pnt,1));<br>
[bnd(2).pnt, bnd(2).tri] = meshresample(bnd(2).pnt, bnd(2).tri, 2000/size(bnd(2).pnt,1));<br>
[bnd(3).pnt, bnd(3).tri] = meshresample(bnd(3).pnt, bnd(3).tri, 3000/size(bnd(3).pnt,1));<br>
<br>
The latest version of OpenMEEG automatically fixes mesh orientations, but if you have an older version of OpenMEEG, you'll need to set bnd(ii).tri = bnd(ii).tri(:,[3 2 1]) to fix the orientation error that you'll get - at least until we hard code that fix into FieldTrip.<br>


<br>
Also, assuming your meshes look like they should (use ft_plot_mesh to check), if you still have a problem with meshes intersecting each other, you will find a subfunction called decouplesurf that is temporarily stashed  at the end of prepare_mesh_segmentation.m.  Copy this function into a new m-file (decouplesurf.m) and use it to fix those intersections as follows:<br>


<br>
bnd = decouplesurf(bnd);<br>
<br>
Note, this will not fix self-intersections. If you're really having a bad day, try using the iso2mesh toolbox meshcheckrepair function:<br>
% Check and repair mesh<br>
[bnd(ii).pnt, bnd(ii).tri] = meshcheckrepair(bnd(ii).pnt, bnd(ii).tri, 'dup');<br>
[bnd(ii).pnt, bnd(ii).tri] = meshcheckrepair(bnd(ii).pnt, bnd(ii).tri, 'isolated');<br>
[bnd(ii).pnt, bnd(ii).tri] = meshcheckrepair(bnd(ii).pnt, bnd(ii).tri, 'deep');<br>
[bnd(ii).pnt, bnd(ii).tri] = meshcheckrepair(bnd(ii).pnt, bnd(ii).tri, 'meshfix');<br>
<br>
This info should eventually find its way onto the FieldTrip tutorial pages...<br>
<br>
<br>
Best Regards,<br>
Daniel Wong<br>
<br>
Daniel Wong, PhD (IBBME, University of Toronto)<br>
Postdoctoral Researcher<br>
Department of Psychology<br>
University of Konstanz<div><div><br>
<br>
<br>
______________________________<u></u>_________________<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/<u></u>mailman/listinfo/fieldtrip</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>