Skip to content

check_inside mistakingly assumes spherical BEM model is in MRI space #13370

@wmvanvliet

Description

@wmvanvliet

Description of the problem

When making a forward model, a check is performed to see if all the MEG sensors are outside the last layer of the BEM. To this end, the positions of the MEG sensors are transformed to MRI space. However, when specifying a spherical BEM, its origin (r0) is in head space. This is not a problem for our sample subject, as the check still passes, but it will be a problem with other subjects, or even when using the fsaverage transform with the sample subject as demonstrated below.

Steps to reproduce

import mne

path = mne.datasets.sample.data_path()
subjects_dir = path / "subjects"
meg_dir = path / "MEG" / "sample"
info = mne.io.read_info(meg_dir / "sample_audvis_raw.fif")

# Use fsaverage as template brain to create the forward model.
mne.datasets.fetch_fsaverage(subjects_dir=subjects_dir)
bem = mne.make_sphere_model(r0="auto", head_radius="auto", info=info)
src = mne.read_source_spaces(subjects_dir / "fsaverage/bem/fsaverage-ico-5-src.fif")
fwd = mne.make_forward_solution(info, trans="fsaverage", src=src, bem=bem)

Link to data

No response

Expected results

As all the MEG sensors are outside the spherical BEM, the forward model should be created successfully.

Actual results

Creation of the forward model fails due to mistakenly identifying MEG sensors as being inside the sphere.

Additional information

MNE-Python is at the latest version of main

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions