<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="">
Dear John,
<div class=""><br class="">
</div>
<div class="">This all looks like a good change. Normally I’d have asked to send us this code change as a PR to github. </div>
<div class=""><br class="">
</div>
<div class="">But, as a matter of fact, the current version in the code already seems to have this in place (<a href="https://github.com/fieldtrip/fieldtrip/blob/master/private/prepare_mesh_tetrahedral.m" class="">https://github.com/fieldtrip/fieldtrip/blob/master/private/prepare_mesh_tetrahedral.m</a>).
 I’d recommend to upgrade to a more recent version of FieldTrip, and verify whether it works for you.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 3 Nov 2020, at 23:23, RICHARDS, JOHN <<a href="mailto:RICHARDS@mailbox.sc.edu" class="">RICHARDS@mailbox.sc.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Hi all.<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
I have been working on a tetrahedral source model, and head model.  The reason for the source model is that we have infant participants and use the gm segment as the brain part for the source model.  Our GM has “limbs” that are fairly narrow, like 1 to 3 mm.   
 We use a 2mm grid which results in nearly 50K source locations and even then the limbs are poorly covered.  Typical source models are 10mm or greater, and this misses large areas of GM.  So, I used the iso2mesh with cgalsurf (or cgalmesh) to create [node face
 elem}, and create .pos based on the node(s).  I also either create the other parts of the grid by scratch (dim, xvalues yvalues zvaluse inside), or use a grid based on a head mask to get the pos and other, and then change the inside to match the locations
 of the node(s).  This works and gives better coverage.  I can tune the iso2mesh to have 20k to 60k source dipoles.  These are “sort of large” quantities of source models, but we have a linux cluster with very large mem nodes.  I would be glad to share the
 code.<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
I also have worked on the tetrahedral mesh for the head model.  We use FEM models with the simbio external module.  The ft_prepare_headmodel will do “hex” or “tetra” head models for simbio.  The ft_prepare_mesh will use “tetrahedral” as the mesh, but “prepare_mesh_tetrahedral”
 does not add the tissue and tissuelabel members, so the ft_prepare_headmodel crashes.  The “prepare_mesh_hexahedral” includes the following code for these:<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
labels = mesh.labels;<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
mesh = rmfield(mesh, 'labels');<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
mesh.tissue = zeros(size(labels));<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
numlabels = size(unique(labels), 1);<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
mesh.tissuelabel = {};<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
ulabel = sort(unique(labels));<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
for i = 1:numlabels<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
  mesh.tissue(labels == ulabel(i)) = i;<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
  mesh.tissuelabel{i} = tissue{i};<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
end<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
I think these could be added to the prepare_mesh_tetrahedral.  I added the following code to it.  The prepare_mesh_tet..  uses the iso2mesh and node, elem, and face are returned.  The “reorient” is due to simbio complaining to reorient the tetra columns.  I
 might compare this to the code above to see if it works.<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
%JER add this for tissue and tissuelabel<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
[newelem evol]=meshreorient(node(:,1:3),elem(:,1:4));<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
elem(:,1:4)=newelem;<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
mesh.tet = elem(:,1:4);<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
mesh.tissue=elem(:,5);<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
mesh.tissuelabel=cfg.tissue;<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
All of these “work”, e.g., they create reasonable files and the ft_prepare_headmodel gives a reasonable struct and files.   We will try these with some empirical data to compare<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Hex source model and hex head model<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Hex source model and tet head model<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Tet source model and hex head model<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Tet source model and tet head model<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
The motivation for doing the tet head model over the hex model is that the tet is known to work better with small areas nested in other areas, better than the hex.  We use full FEM segmented head models with 10 elements and have a lot of twists and turns, small
 areas with limbs or small encapsulated media areas, etc.  I am pretty sure with our segmented heads that  it could easily be shown the tetra model does better than the hex model.  I suspect this will not have extensive effects on the source reconstruction
 results but use the best method possible.<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
John<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 10pt; font-family: Consolas;" class="">***********************************************<br class="">
John E. Richards<br class="">
Carolina Distinguished Professor<br class="">
Department of Psychology<br class="">
University of South Carolina<br class="">
Columbia, SC  29208<br class="">
Dept Phone: 803 777 2079<br class="">
Fax: 803 777 9558<br class="">
Email: </span><a href="mailto:richards-john@sc.edu" class=""><span style="font-size: 10pt; font-family: Consolas; color: rgb(5, 99, 193);" class="">richards-john@sc.edu</span></a><u class=""><span style="font-size: 10pt; font-family: Consolas; color: blue;" class=""><br class="">
</span></u><span style="font-size: 10pt; font-family: Consolas;" class=""><a href="https://jerlab.sc.edu/" class="">https://jerlab.sc.edu</a><br class="">
*************************************************<br class="">
<br class="">
</span><o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://doi.org/10.1371/journal.pcbi.1002202</a></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>