<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Hi Erin,
<div><br>
</div>
<div>It could be that you don’t have the proper compiled version of the function on your platform. It seems bem_Cii_lin is a mex file, and yours should be called bem_Cii_lin.mexmaci64 or bem_Cii_lin.mexmaca64. Probably you need the latter one. This version
 does not to be part of fieldtrip (yet). You can try and compile it yourself (see ft_compile_mex, related documentation about this on the fieldtrip website, and ‘help mex’ in matlab).</div>
<div><br>
</div>
<div>Best wishes,</div>
<div>Jan-Mathijs</div>
<div> <br id="lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On 22 Jan 2026, at 13:52, Erin Noelle Mahan via fieldtrip <fieldtrip@science.ru.nl> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
Dear Fieldtrip community, </div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
My name is Erin Mahan and I am a PhD student in the Lundqvist Multimodal Brain Imaging lab at Karolinska Institutet in Stockholm, Sweden. My PhD project will be on imaging the brain of epilepsy patients using MEG and coregistered quantum sensors. Currently,
 I am working through the tutorials of a class on M/EEG to learn Matlab and Fieldtrip (<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnatmegsweden%2Fmeeg_course%2Fblob%2Fmaster%2Ftutorial_03_prepare_mri.md&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Ca657175d2f5741d5bf9e08de6a309e51%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954190567078%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=dRTsN9aBcD%2BjC9XJmrODGDZNqY0aN7pDoOOPCoSWPLE%3D&reserved=0" originalsrc="https://github.com/natmegsweden/meeg_course/blob/master/tutorial_03_prepare_mri.md" originalsrc="https://github.com/natmegsweden/meeg_course/blob/master/tutorial_03_prepare_mri.md" data-outlook-id="a2c0e192-1b21-4ec1-a574-9e99a3669fcf">https://github.com/natmegsweden/meeg_course/blob/master/tutorial_03_prepare_mri.md</a>)</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
In the tutorial section integrating the participant’s MRI with EEG, I call ft_prepare_headmodel(cfg, meshes) with the cfg.method “bemcp”.  The meshes “are closed and properly nested” before the error occurs. It throws an error that traces to line 177 in ft_headmodel_bemcp:</div>
<div class="rtcContent" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; direction: ltr; text-align: left; padding: 30px; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; color: rgb(225, 27, 20);">
<span style="line-height: 16.718px;">C11st = bem_Cii_lin(headmodel.bnd(1).tri,headmodel.bnd(1).pos, weight,defl(1),headmodel.bnd(1).pnt4);</span></div>
<div class="rtcContent" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; direction: ltr; text-align: left; padding: 30px;">
<span style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">The error is "</span><span style="font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; color: rgb(225, 27, 20); line-height: 16.718px;">Undefined function
 'bem_Cii_lin' for input arguments of type 'double’."</span></div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
I have verified the function’s MEX file integrity and presence in the fieldtrip folder, confirmed it’s in the Matlab path, corroborated the cfg and inputs with a colleague, and had the colleague run the script himself with no problems. When attempting to run
 the internal call for bem_Cii_lin, this is the error:</div>
<div class="rtcContent" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; direction: ltr; text-align: left; padding: 30px;">
<span style="font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; line-height: 16.718px;">bem_Cii_lin(headmodel.bnd(1).tri,headmodel.bnd(1).pos, weight,defl(1),headmodel.bnd(1).pnt4);</span><span style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;"><br>
</span><span style="font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; color: rgb(225, 27, 20); line-height: 16.718px;">Unrecognized function or variable 'bem_Cii_lin'.</span></div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
Both myself and the colleague have Macs, but his was able to run with no problems. I’m unsure of what to try next. The cfg is below if helpful.</div>
<div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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; padding: 30px;">
<div class="S81B99EAF0" style="text-align: left; text-indent: 0px; line-height: 16.718px; text-transform: none; margin: 0px; min-height: 0px; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px;">
cfg =<br>
<br>
<b><a href="matlab:helpPopup('struct')" data-outlook-id="1cfcc66e-5972-4831-953c-dfcaef743089">struct</a></b> with fields:<br>
<br>
method: 'bemcp'<br>
conductivity: [0.3333 0.0167 0.3333]</div>
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
Any suggestions would be appreciated!</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
Thank you, </div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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; direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;">
Erin </div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 14px; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;">
<span class="s1" style="font-kerning: none;"></span><br>
</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 14px; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;">
<span class="s1" style="font-kerning: none;"></span><br>
</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;">
<span class="s1" style="font-kerning: none;"><i>När du skickar e-post till Karolinska Institutet (KI) innebär detta att KI kommer att behandla dina personuppgifter.<span class="Apple-converted-space"> </span></i><a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fki.se%2Fom-ki%2Fintegritetsskyddspolicy&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Ca657175d2f5741d5bf9e08de6a309e51%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954190594519%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=kIyQPh8%2F3nMZPu5kPlXltY5qIpMuWqrlPw8DjfP%2Fa2I%3D&reserved=0" originalsrc="https://ki.se/om-ki/integritetsskyddspolicy" originalsrc="https://ki.se/om-ki/integritetsskyddspolicy"><span class="s2" style="text-decoration: underline; font-kerning: none; color: rgb(0, 0, 238); -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 238);">Här
 finns information om hur KI behandlar personuppgifter</span></a>.<span class="Apple-converted-space"> </span></span></div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 14px; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;">
<span class="s1" style="font-kerning: none;"></span><br>
</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;">
<span class="s1" style="font-kerning: none;"><i>Sending email to Karolinska Institutet (KI) will result in KI processing your personal data.</i><span class="Apple-converted-space"> </span><a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstaff.ki.se%2Fdata-protection-policy&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Ca657175d2f5741d5bf9e08de6a309e51%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954190614703%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=3T0WSyTfGyfFzvHrKJnZ5fBuSfqQyNUEct%2FPjfGZC34%3D&reserved=0" originalsrc="https://staff.ki.se/data-protection-policy" originalsrc="https://staff.ki.se/data-protection-policy"><span class="s2" style="text-decoration: underline; font-kerning: none; color: rgb(0, 0, 238); -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 238);">You
 can read more about KI’s processing of personal data here</span></a>.<span class="Apple-converted-space"> </span></span></div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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;">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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;">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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;">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: 400; 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;">
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Ca657175d2f5741d5bf9e08de6a309e51%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954190634539%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=jXeYVCGVEuLiu70s7u6TeZLRn%2FNzOZfAm0MEO4FcT7M%3D&reserved=0" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">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: 400; 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;">
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Ca657175d2f5741d5bf9e08de6a309e51%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954190653212%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=0V7Bzp7ONMCOWINUikjFTFyz%2FFjNdBgwLcL1plF%2BZvw%3D&reserved=0" originalsrc="https://doi.org/10.1371/journal.pcbi.1002202" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">https://doi.org/10.1371/journal.pcbi.1002202</a></div>
</blockquote>
</div>
<br>
</div>
</body>
</html>