[FieldTrip] Unrecognized function or variable 'bem_Cii_lin' in ft_headmodel_bemcp
Jenson, David Evans
david.jenson at wsu.edu
Thu Feb 12 18:31:57 CET 2026
Hi Erin,
I ran into a similar problem a while ago, although with a different function. The issue wound up being where I had stored the fieldtrip files. I’m also a Mac user, and initially I had synced my Documents folder (containing the fieldtrip files) to OneDrive. That seemed to cause problems, because in the fraction of a second it took to access the relevant function, Matlab would register an error. Once I moved the fieldtrip files to a local folder on the hard drive, the issue resolved. I’m assuming the issue would be similar for any cloud-based storage system, not just OneDrive.
Best,
-Dave Jenson
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl>
Date: Thursday, February 12, 2026 at 4:20 AM
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Cc: Schoffelen, J.M. (Jan Mathijs) <janmathijs.schoffelen at donders.ru.nl>
Subject: Re: [FieldTrip] Unrecognized function or variable 'bem_Cii_lin' in ft_headmodel_bemcp
[EXTERNAL EMAIL]
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://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%7C68db77154df442e5dc5c08de6a5ca724%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639065143363471553%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=da%2BlAkN4QZm6jjkBXfq8a5AotTZ4s7Me3UGZk8NbyJs%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Feur01.safelinks.protection.outlook.com%2F%3Furl%3Dhttps*3A*2F*2Fgithub.com*2Fnatmegsweden*2Fmeeg_course*2Fblob*2Fmaster*2Ftutorial_03_prepare_mri.md%26data%3D05*7C02*7Cfieldtrip*40science.ru.nl*7Ca657175d2f5741d5bf9e08de6a309e51*7C084578d9400d4a5aa7c7e76ca47af400*7C1*7C0*7C639064954190567078*7CUnknown*7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ*3D*3D*7C0*7C*7C*7C%26sdata%3DdRTsN9aBcD*2BjC9XJmrODGDZNqY0aN7pDoOOPCoSWPLE*3D%26reserved%3D0__%3BJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!JmPEgBY0HMszNaDT!s75IbEBvOzkVCFFnhrNJ3z7HgIH3OB9Wv3BY5nk2rdZV-ahlR4c7sxvBgNvPzoBpl8eLf4w3rZmMzKTDHQ2TEskQ9P0%24&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C68db77154df442e5dc5c08de6a5ca724%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639065143363502964%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=mGUytdynIlaPq5TtQwBixPOQa78Vw6ITUuYUa6TJZcw%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 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%2Furldefense.com%2Fv3%2F__https%3A%2F%2Feur01.safelinks.protection.outlook.com%2F%3Furl%3Dhttps*3A*2F*2Fki.se*2Fom-ki*2Fintegritetsskyddspolicy%26data%3D05*7C02*7Cfieldtrip*40science.ru.nl*7Ca657175d2f5741d5bf9e08de6a309e51*7C084578d9400d4a5aa7c7e76ca47af400*7C1*7C0*7C639064954190594519*7CUnknown*7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ*3D*3D*7C0*7C*7C*7C%26sdata%3DkIyQPh8*2F3nMZPu5kPlXltY5qIpMuWqrlPw8DjfP*2Fa2I*3D%26reserved%3D0__%3BJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUl!!JmPEgBY0HMszNaDT!s75IbEBvOzkVCFFnhrNJ3z7HgIH3OB9Wv3BY5nk2rdZV-ahlR4c7sxvBgNvPzoBpl8eLf4w3rZmMzKTDHQ2T19q9JFA%24&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C68db77154df442e5dc5c08de6a5ca724%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639065143363521184%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=RFVT2psGb8efnUMGd5CrE3Pwd1FAzRJhHlgWaVtcLWY%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%2Furldefense.com%2Fv3%2F__https%3A%2F%2Feur01.safelinks.protection.outlook.com%2F%3Furl%3Dhttps*3A*2F*2Fstaff.ki.se*2Fdata-protection-policy%26data%3D05*7C02*7Cfieldtrip*40science.ru.nl*7Ca657175d2f5741d5bf9e08de6a309e51*7C084578d9400d4a5aa7c7e76ca47af400*7C1*7C0*7C639064954190614703*7CUnknown*7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ*3D*3D*7C0*7C*7C*7C%26sdata%3D3T0WSyTfGyfFzvHrKJnZ5fBuSfqQyNUEct*2FPjfGZC34*3D%26reserved%3D0__%3BJSUlJSUlJSUlJSUlJSUlJSUlJSUlJQ!!JmPEgBY0HMszNaDT!s75IbEBvOzkVCFFnhrNJ3z7HgIH3OB9Wv3BY5nk2rdZV-ahlR4c7sxvBgNvPzoBpl8eLf4w3rZmMzKTDHQ2TKKs_LME%24&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C68db77154df442e5dc5c08de6a5ca724%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639065143363539243%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=d5tYKbCrUPIudF%2FtkSOSGY4ZoLRykBvI8s0vF1z8u30%3D&reserved=0>.
_______________________________________________
fieldtrip mailing list
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C68db77154df442e5dc5c08de6a5ca724%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639065143363558517%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Y2fEI9q03YaV7zM9ksVOtWKsmHwz%2FZ0GFyjChrRFYKQ%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Feur01.safelinks.protection.outlook.com%2F%3Furl%3Dhttps*3A*2F*2Fmailman.science.ru.nl*2Fmailman*2Flistinfo*2Ffieldtrip%26data%3D05*7C02*7Cfieldtrip*40science.ru.nl*7Ca657175d2f5741d5bf9e08de6a309e51*7C084578d9400d4a5aa7c7e76ca47af400*7C1*7C0*7C639064954190634539*7CUnknown*7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ*3D*3D*7C0*7C*7C*7C%26sdata%3DjXeYVCGVEuLiu70s7u6TeZLRn*2FNzOZfAm0MEO4FcT7M*3D%26reserved%3D0__%3BJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUl!!JmPEgBY0HMszNaDT!s75IbEBvOzkVCFFnhrNJ3z7HgIH3OB9Wv3BY5nk2rdZV-ahlR4c7sxvBgNvPzoBpl8eLf4w3rZmMzKTDHQ2TDdVeUro%24&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C68db77154df442e5dc5c08de6a5ca724%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639065143363575461%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=VR6Y49DwVznfZNG2IrzSVwVONIN1EPgh3TOy6G3%2Fu10%3D&reserved=0>
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C68db77154df442e5dc5c08de6a5ca724%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639065143363593540%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=tPFggTB1LNbetbyODp0Q6O0DjO2RX1%2FvZPUUvjifYQk%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Feur01.safelinks.protection.outlook.com%2F%3Furl%3Dhttps*3A*2F*2Fdoi.org*2F10.1371*2Fjournal.pcbi.1002202%26data%3D05*7C02*7Cfieldtrip*40science.ru.nl*7Ca657175d2f5741d5bf9e08de6a309e51*7C084578d9400d4a5aa7c7e76ca47af400*7C1*7C0*7C639064954190653212*7CUnknown*7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ*3D*3D*7C0*7C*7C*7C%26sdata%3D0V7Bzp7ONMCOWINUikjFTFyz*2FFjNdBgwLcL1plF*2BZvw*3D%26reserved%3D0__%3BJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUl!!JmPEgBY0HMszNaDT!s75IbEBvOzkVCFFnhrNJ3z7HgIH3OB9Wv3BY5nk2rdZV-ahlR4c7sxvBgNvPzoBpl8eLf4w3rZmMzKTDHQ2TX7U15sQ%24&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C68db77154df442e5dc5c08de6a5ca724%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C639065143363611167%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=5EKKgK1x5%2FuMJ%2BBhMk50pVuVRFZeyvB81lqenNE1L5E%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20260212/430551b4/attachment.htm>
More information about the fieldtrip
mailing list