diff --git a/doc/changes/devel/12436.bugfix.rst b/doc/changes/devel/12436.bugfix.rst new file mode 100644 index 00000000000..7ddbd9f5d21 --- /dev/null +++ b/doc/changes/devel/12436.bugfix.rst @@ -0,0 +1 @@ +Fix :ref:`tut-working-with-seeg` use of :func:`mne.stc_near_sensors` to use the :class:`mne.VolSourceEstimate` positions and not the pial surface, by `Alex Rockhill`_ diff --git a/mne/source_estimate.py b/mne/source_estimate.py index 7994aab519b..2bd1ef48dee 100644 --- a/mne/source_estimate.py +++ b/mne/source_estimate.py @@ -3879,8 +3879,11 @@ def stc_near_sensors( if surface == "auto": if src is not None: pial_fname = op.join(subjects_dir, subject, "surf", "lh.pial") - src_surf_is_pial = op.isfile(pial_fname) and np.allclose( - src[0]["rr"], read_surface(pial_fname)[0] + pial_rr = read_surface(pial_fname)[0] + src_surf_is_pial = ( + op.isfile(pial_fname) + and src[0]["rr"].shape == pial_rr.shape + and np.allclose(src[0]["rr"], pial_rr) ) if not src_surf_is_pial: warn( @@ -3890,7 +3893,7 @@ def stc_near_sensors( "or ``surface=None`` to suppress this warning", DeprecationWarning, ) - surface = "pial" + surface = "pial" if src is None or src.kind == "surface" else None # create a copy of Evoked using ecog, seeg and dbs if picks is None: diff --git a/tutorials/clinical/20_seeg.py b/tutorials/clinical/20_seeg.py index dac5739110d..6166001c075 100644 --- a/tutorials/clinical/20_seeg.py +++ b/tutorials/clinical/20_seeg.py @@ -212,8 +212,14 @@ evoked = epochs.average() stc = mne.stc_near_sensors( - evoked, trans, "fsaverage", subjects_dir=subjects_dir, src=vol_src, verbose="error" -) # ignore missing electrode warnings + evoked, + trans, + "fsaverage", + subjects_dir=subjects_dir, + src=vol_src, + surface=None, + verbose="error", +) stc = abs(stc) # just look at magnitude clim = dict(kind="value", lims=np.percentile(abs(evoked.data), [10, 50, 75]))