<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">this error occurs if the transformation from voxel to patient space that comes with your segmentation flips the mesh along one dimension.</div><div class=""><br class=""></div><div class="">One thing you could do is to make sure that your image is properly oriented, I assume ft_volumereslice could do that. If you just want your mesh in voxel-space, you could also remove the transformation from your segmentation/replace it by an identity matrix.</div><div class=""><br class=""></div><div class="">Best,</div><div class=""> Johannes</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">Am 04.04.2019 um 12:37 schrieb Yuranny Cabral-Calderin <<a href="mailto:cabral-calderin@med.uni-frankfurt.de" class="">cabral-calderin@med.uni-frankfurt.de</a>>:</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: 12px; 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: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-family: Arial, sans-serif;" class="">Hello everybody,<o:p class=""></o:p></span></div><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">I am using Fieldtrip to generate FEM head models. I segment my MRI data outside of MATLAB (using the Simnibs pipeline + manual corrections in SEG3D). I import my segmentation in MATLAB and use ft_prepare_mesh to generate the hexahedral mesh. This seems to work fine. However, when I pass the resulting mesh to the ft_prepare_headmodel function, I get the following error:<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif; color: red;" class="">Error using sb_calc_stiff (line 80)<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif; color: red;" class="">Elements have wrong orientation or are degenerated<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif; color: red;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif; color: red;" class="">Error in ft_headmodel_simbio (line 90)<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif; color: red;" class="">headmodel.stiff = sb_calc_stiff(headmodel);<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif; color: red;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif; color: red;" class="">Error in ft_prepare_headmodel (line 426)<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif; color: red;" class=""> headmodel = ft_headmodel_simbio(geometry, 'conductivity', cfg.conductivity);<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">Below is the code I am using to generate the mesh and the FEM model:<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">cfg = [];<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">cfg.shift = 0.3;<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">cfg.tissue = {'gray','white','csf','skull','scalp'};<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">cfg.method = 'hexahedral';<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">mesh = ft_prepare_mesh(cfg,segmentedmri);<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">cfg = [];<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">cfg.method ='simbio';<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">cfg.conductivity = [0.33 0.14 1.79 0.01 0.43]; <o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt 35.4pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">FEMModel = ft_prepare_headmodel(cfg, mesh); <o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""> <o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">Has anyone experienced the same problem and know how to fix it?<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Arial, sans-serif;" class="">Thanks a lot,<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New";" class=""><span style="font-size: 11pt; font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></pre><div style="margin: 0cm 0cm 0.0001pt; 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: 12px; 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: 12px; 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: 12px; 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: 12px; 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: 12px; 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: 12px; 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: 12px; 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>