From 9690606940a8ad1e6660a376aefc08f46fe6c182 Mon Sep 17 00:00:00 2001 From: Alex Rockhill Date: Sun, 11 Feb 2024 07:49:58 -0800 Subject: [PATCH 1/4] style --- mne/source_estimate.py | 7 +++++-- tutorials/clinical/20_seeg.py | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mne/source_estimate.py b/mne/source_estimate.py index 7994aab519b..d820d7bcabc 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( diff --git a/tutorials/clinical/20_seeg.py b/tutorials/clinical/20_seeg.py index dac5739110d..2edbd296396 100644 --- a/tutorials/clinical/20_seeg.py +++ b/tutorials/clinical/20_seeg.py @@ -212,7 +212,13 @@ evoked = epochs.average() stc = mne.stc_near_sensors( - evoked, trans, "fsaverage", subjects_dir=subjects_dir, src=vol_src, verbose="error" + evoked, + trans, + "fsaverage", + subjects_dir=subjects_dir, + src=vol_src, + surface=None, + verbose="error", ) # ignore missing electrode warnings stc = abs(stc) # just look at magnitude clim = dict(kind="value", lims=np.percentile(abs(evoked.data), [10, 50, 75])) From a890e69dccd4de8d1196ecbe2af773f0b77cd126 Mon Sep 17 00:00:00 2001 From: Alex Rockhill Date: Sun, 11 Feb 2024 07:57:11 -0800 Subject: [PATCH 2/4] style --- tutorials/clinical/20_seeg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/clinical/20_seeg.py b/tutorials/clinical/20_seeg.py index 2edbd296396..6166001c075 100644 --- a/tutorials/clinical/20_seeg.py +++ b/tutorials/clinical/20_seeg.py @@ -219,7 +219,7 @@ src=vol_src, surface=None, verbose="error", -) # ignore missing electrode warnings +) stc = abs(stc) # just look at magnitude clim = dict(kind="value", lims=np.percentile(abs(evoked.data), [10, 50, 75])) From 074769e1c269b3cd6cd65ecc07f39614a325f5e1 Mon Sep 17 00:00:00 2001 From: Alex Rockhill Date: Sun, 11 Feb 2024 08:01:24 -0800 Subject: [PATCH 3/4] changelog --- doc/changes/devel/12436.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/devel/12436.bugfix.rst 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`_ From 2ec557e9bd19e6b759032407b1b79e8726420a1a Mon Sep 17 00:00:00 2001 From: Alex Rockhill Date: Mon, 12 Feb 2024 07:48:15 -0800 Subject: [PATCH 4/4] only use pial default for surface source estimate --- mne/source_estimate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne/source_estimate.py b/mne/source_estimate.py index d820d7bcabc..2bd1ef48dee 100644 --- a/mne/source_estimate.py +++ b/mne/source_estimate.py @@ -3893,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: