[FieldTrip] Source reconstruction of combined EEG-MEG data

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Wed Jan 15 08:57:52 CET 2025


Hi Kenneth,

Given the lack of additional information there is not much to go on.

Few points/recommendations:

- given what I said before, with respect to the limited backward compatibility of example scripts, I would recommend you to start with the tutorial material.
-specifically, you said that you want to combine EEG and MEG forward models, so I would start by getting familiar with the procedures to build a forward (and inverse) model for EEG, and MEG separately. There’s an abundance of tutorials in the tutorial section of the website, detailing the specifics of MEG and EEG forward model creation, and beyond.
-once you know how to create a forward model for EEG and MEG separately, it should not be too difficult to combine the two. For this, I would not recommend the ft_prepare_vol_sens function, which is a relatively low-level function, and which has not been designed for ease-of-use by the end user (unless said end user knows what they ar doing). In theory, combining forward models may be as easy as concatenating the ‘leadfields’, and could perhaps even done by hand (i.e. after creating a forward model for a set of (the same) predefined dipole positions, the combined leadfield is just cat(1, eeg.leadfield{i}, meg.leadfield{i}).

Good luck,

Jan-Mathijs


On 14 Jan 2025, at 13:56, Kenneth Shinozuka <kennethshinozuka at gmail.com> wrote:

Dear Jan-Mathijs,

The leadfield code for the combined EEG-MEG data is now causing an error in one of my subjects' data. Specifically, the following line:

[combined_headmodel{1}, combined_sens{1}] = ft_prepare_vol_sens(combined_headmodel{1}, combined_sens{1});

is triggering the error:

Warning: electrodes do not lie on skin surface -> using radial projection
undoing the reject balancing for the gradiometer definition
Error using ft_scalingfactor
cannot convert V to unknown

Error in ft_scalingfactor (line 94)
  factor = cellfun(@ft_scalingfactor, old(:), new(:));

Error in ft_apply_montage (line 337)
  scale = ft_scalingfactor(input.chanunit, montage.chanunitold);

Error in undobalancing (line 37)
    sens = ft_apply_montage(sens, sens.balance.(sens.balance.current), 'inverse', 'yes', 'keepunused', 'yes', 'warning', 'no');

Error in channelposition (line 34)
  sens = undobalancing(sens);

Error in ft_prepare_vol_sens (line 628)
  [pos, ori, lab] = channelposition(sens);

Do you know what the cause of this error could be? I explicitly set the chanunit of elec, which is combined_sens{1}, to 'V', and the chantype of elec to 'eeg', but the error still persists.

Best regards,
Kenneth


On Tue, Jan 14, 2025 at 6:59 AM Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:
For reference:

Hello Jan-Mathijs,

Thank you very much for your reply. My apologies for not referring to the example code correctly. When I searched for the page on Google, Google indicated that the date of the page was December 4, 2024, hence I thought that it was published last month.

I am able to get my own code running with ft_prepare_vol_sens, so I think you are right.

Best regards,
Kenneth

On Mon, Jan 13, 2025 at 7:03 PM Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:
Hi Kenneth,

Please note that the documentation on the category ‘examples’ consist of a collection of code/procedural descriptions that worked once-upon-a-time. They are not guaranteed to be backward compatible with a further evolved codebase.

So, your statement ‘FieldTrip recently released some new documentation’  is not fully appropriate. The example you refer to, is actually already quite old; what may have changed is the name of the page (which may make it look new), the content hasn’t changed. We are in the process of making some important changes to the website (basically aimed at improving the browsing experience), and for that reason we needed to refactor a bit the names of the webpages under the hood.

Regarding your question: I think that something has gone wrong at some point when we executed some housekeeping operations on the content-text-files that contain the information on the website. I believe the proper function call should be ft_prepare_vol_sens, rather than ft_prepare_headmodel_sens.

Best wishes,
Jan-Mathijs


On 13 Jan 2025, at 12:51, Kenneth Shinozuka via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hello,

I am analyzing some simultaneously acquired EEG-MEG data. I saw that FieldTrip recently released some new documentation about this:

https://www.fieldtriptoolbox.org/example/sourcerecon_meeg/<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.fieldtriptoolbox.org%2Fexample%2Fsourcerecon_meeg%2F&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Ce69ff4806d8e4eeede0708dd353a4fed%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638725246731235040%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=5SWxqUidX1FJOj5gwrxsRkelqPJi%2BYdzxA%2FD9GEzFqA%3D&reserved=0>

The provided code uses a function called “ft_prepare_headmodel_sens,” which does not appear to exist. I get the error: “Unrecognized function or variable ‘ft_prepare_headmodel_sens.’” Is there another function that you intended to use?

Best regards,
Kenneth
_______________________________________________
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%7Ce69ff4806d8e4eeede0708dd353a4fed%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638725246731251990%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=sTavp1g71YlfQSL8fFjFNjS3aWT%2BLE4kV%2F9pNWS54S0%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%7Ce69ff4806d8e4eeede0708dd353a4fed%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638725246731262676%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=jWQYLtGG4uSCS8Ey7DNSZaHTcY%2FwCk9uM29G4E3XfOg%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%7Ce69ff4806d8e4eeede0708dd353a4fed%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638725246731273841%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=IedRzKu2Rd2879ss%2BsH3UbCcS2bX1WZZonjsS8c8xoE%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%7Ce69ff4806d8e4eeede0708dd353a4fed%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638725246731285516%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=8TKD9fF333bh9Vl0GMj9q%2BpjkUg2vQD4sp7xpcW2XjI%3D&reserved=0>


--
Kenneth Shinozuka
Harvard College '20 | BA in Neuroscience
Oxford University '24 | PhD in Psychiatry
+1 9493028589 (US, WhatsApp)
+44 07572876618 (UK)

_______________________________________________
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%7Ce69ff4806d8e4eeede0708dd353a4fed%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638725246731296659%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=6qUM%2BgolzZ4XNm1BlF0qtT5FmVpmaipfz8k%2FJn3%2FF3E%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%7Ce69ff4806d8e4eeede0708dd353a4fed%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638725246731306986%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=WuXwStHa8MatCvh92Y6FUqSXIqpMvDZO%2B%2FBqCt%2Ba3IU%3D&reserved=0>


--
Kenneth Shinozuka
Harvard College '20 | BA in Neuroscience
Oxford University '24 | PhD in Psychiatry
+1 9493028589 (US, WhatsApp)
+44 07572876618 (UK)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20250115/0e3652ef/attachment.htm>


More information about the fieldtrip mailing list