[FieldTrip] Unrecognized function or variable 'bem_Cii_lin' in ft_headmodel_bemcp

Erin Noelle Mahan erin.noelle.mahan at ki.se
Thu Jan 22 13:52:43 CET 2026


Dear Fieldtrip community,

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 (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%7Cbf798709914641d539fc08de59b52bd3%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639046831803376823%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=unpxBXCFUmhdMpPxnOGLqRw1wjFWVq33gi4e7EDydNQ%3D&reserved=0)

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:
C11st = bem_Cii_lin(headmodel.bnd(1).tri,headmodel.bnd(1).pos, weight,defl(1),headmodel.bnd(1).pnt4);
The error is "Undefined function 'bem_Cii_lin' for input arguments of type 'double’."
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:
bem_Cii_lin(headmodel.bnd(1).tri,headmodel.bnd(1).pos, weight,defl(1),headmodel.bnd(1).pnt4);
Unrecognized function or variable 'bem_Cii_lin'.
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.
cfg =

struct<matlab:helpPopup('struct')> with fields:

method: 'bemcp'
conductivity: [0.3333 0.0167 0.3333]
Any suggestions would be appreciated!

Thank you,

Erin



När du skickar e-post till Karolinska Institutet (KI) innebär detta att KI kommer att behandla dina personuppgifter. Här finns information om hur KI behandlar personuppgifter<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fki.se%2Fom-ki%2Fintegritetsskyddspolicy&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cbf798709914641d539fc08de59b52bd3%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639046831803405873%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=qeymU1%2FzaM4R18xT0rSb%2BzBxhVlvHRRUC6CY%2Btu6NOs%3D&reserved=0>.


Sending email to Karolinska Institutet (KI) will result in KI processing your personal data. You can read more about KI’s processing of personal data here<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstaff.ki.se%2Fdata-protection-policy&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cbf798709914641d539fc08de59b52bd3%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639046831803425240%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=5uOHQdXLHQluXQCYx1G%2BXGmYqFBbNU0TLWxDRWFEidQ%3D&reserved=0>.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20260122/80397fe6/attachment.htm>


More information about the fieldtrip mailing list