[FieldTrip] Unrecognized function or variable 'bem_Cii_lin' in ft_headmodel_bemcp
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Thu Feb 12 13:16:57 CET 2026
Hi Erin,
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).
Best wishes,
Jan-Mathijs
On 22 Jan 2026, at 13:52, Erin Noelle Mahan via fieldtrip <fieldtrip at science.ru.nl> wrote:
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://github.com/natmegsweden/meeg_course/blob/master/tutorial_03_prepare_mri.md<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%7C944b3197c61545211e8d08de6a309e06%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954188040751%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=%2FpjBOuG78akxDKeNSeNHHIzePeAwOyMEl8Au9ZoiQ0M%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%7C944b3197c61545211e8d08de6a309e06%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954188065080%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=G8CcBTPlbGgsBP9%2Foxtk56l4Ajh8eZXEIbLLMOtiuPk%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%7C944b3197c61545211e8d08de6a309e06%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954188083443%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=QqlaJebPY%2Fevis%2F8z8NrG6zdT3Mrck2wem8fqSxglVc%3D&reserved=0>.
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C944b3197c61545211e8d08de6a309e06%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954188101514%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=0O1z7AB25QNxsN0Ge%2FjSPX7guucYsbuYeIPeg6v1GXA%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C944b3197c61545211e8d08de6a309e06%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639064954188119016%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=9LTI6%2FiuT3EyZhc10EJWHhIXgO452QsAN08b9JBsE7I%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20260212/0eaeca3a/attachment.htm>
More information about the fieldtrip
mailing list