From dedf1b7d60fcd9a434a37ddfcd02091dcc8adf23 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Thu, 26 Mar 2026 17:31:30 +0530 Subject: [PATCH 01/10] ENH: improve error message when FreeSurfer executable not found Closes #12917 Improved error message when FreeSurfer executable (e.g., mri_watershed) cannot be found. - Clarifies need for proper FreeSurfer setup - Mentions adding $FREESURFER_HOME/bin to PATH - Notes that Python/Jupyter should be started from configured shell This helps users diagnose common setup issues more easily. --- mne/bem.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mne/bem.py b/mne/bem.py index bb73544f763..6f71a68094f 100644 --- a/mne/bem.py +++ b/mne/bem.py @@ -1313,7 +1313,18 @@ def make_watershed_bem( f"\nResults dir = {ws_dir}\nCommand = {' '.join(cmd)}\n" ) os.makedirs(op.join(ws_dir)) - run_subprocess_env(cmd) + try: + run_subprocess_env(cmd) + except FileNotFoundError: + raise RuntimeError( + "FreeSurfer executable 'mri_watershed' not found.\n\n" + "This usually means FreeSurfer is not properly configured.\n" + "Make sure:\n" + "- FREESURFER_HOME is set\n" + "- $FREESURFER_HOME/bin is in your PATH\n" + "- You started Python/Jupyter from a terminal where FreeSurfer is sourced\n\n" + "See MNE installation documentation for details." + ) del tempdir # clean up directory if op.isfile(T1_mgz): new_info = _extract_volume_info(T1_mgz) From 33e88e934eb18a492a9423cedd216886fce88bd9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2026 12:13:59 +0000 Subject: [PATCH 02/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/bem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mne/bem.py b/mne/bem.py index 6f71a68094f..f3b655ab872 100644 --- a/mne/bem.py +++ b/mne/bem.py @@ -1316,7 +1316,7 @@ def make_watershed_bem( try: run_subprocess_env(cmd) except FileNotFoundError: - raise RuntimeError( + raise RuntimeError( "FreeSurfer executable 'mri_watershed' not found.\n\n" "This usually means FreeSurfer is not properly configured.\n" "Make sure:\n" @@ -1324,7 +1324,7 @@ def make_watershed_bem( "- $FREESURFER_HOME/bin is in your PATH\n" "- You started Python/Jupyter from a terminal where FreeSurfer is sourced\n\n" "See MNE installation documentation for details." - ) + ) del tempdir # clean up directory if op.isfile(T1_mgz): new_info = _extract_volume_info(T1_mgz) From 23a7271c36f1aa9631a961d9377c5174f2f36d06 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Mon, 30 Mar 2026 12:13:08 +0530 Subject: [PATCH 03/10] Update mne/bem.py ENH: refine FreeSurfer setup error message Co-authored-by: Marijn van Vliet --- mne/bem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne/bem.py b/mne/bem.py index f3b655ab872..221569ee817 100644 --- a/mne/bem.py +++ b/mne/bem.py @@ -1322,7 +1322,7 @@ def make_watershed_bem( "Make sure:\n" "- FREESURFER_HOME is set\n" "- $FREESURFER_HOME/bin is in your PATH\n" - "- You started Python/Jupyter from a terminal where FreeSurfer is sourced\n\n" + "- You started Python/Jupyter from a terminal where SetupFreeSurfer.sh is sourced\n\n" "See MNE installation documentation for details." ) del tempdir # clean up directory From 60534688cdbc9a5ec5c174200938ee84ddfcd222 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Sun, 12 Apr 2026 11:24:35 +0530 Subject: [PATCH 04/10] Apply suggestions from code review ENH: preserve original exception using "from e" Co-authored-by: Marijn van Vliet --- mne/bem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mne/bem.py b/mne/bem.py index 221569ee817..b5b5df84498 100644 --- a/mne/bem.py +++ b/mne/bem.py @@ -1315,7 +1315,7 @@ def make_watershed_bem( os.makedirs(op.join(ws_dir)) try: run_subprocess_env(cmd) - except FileNotFoundError: + except FileNotFoundError as e: raise RuntimeError( "FreeSurfer executable 'mri_watershed' not found.\n\n" "This usually means FreeSurfer is not properly configured.\n" @@ -1324,7 +1324,7 @@ def make_watershed_bem( "- $FREESURFER_HOME/bin is in your PATH\n" "- You started Python/Jupyter from a terminal where SetupFreeSurfer.sh is sourced\n\n" "See MNE installation documentation for details." - ) + ) from e del tempdir # clean up directory if op.isfile(T1_mgz): new_info = _extract_volume_info(T1_mgz) From e54c691096ad6f5a0de1695675c4e0536d32e4a0 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Sun, 12 Apr 2026 12:52:54 +0530 Subject: [PATCH 05/10] Add changelog entry for FreeSurfer error message improvement Added changelog entry for PR #13790 describing the improved error message when FreeSurfer executable is not found. --- doc/changes/dev/13790.enhancement.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/dev/13790.enhancement.rst diff --git a/doc/changes/dev/13790.enhancement.rst b/doc/changes/dev/13790.enhancement.rst new file mode 100644 index 00000000000..90846b96bee --- /dev/null +++ b/doc/changes/dev/13790.enhancement.rst @@ -0,0 +1 @@ +Improved error message when FreeSurfer executable is not found. From 5d9f7fc7b945b39748c1bd75029e23721a846007 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Mon, 13 Apr 2026 09:47:42 +0530 Subject: [PATCH 06/10] Fix line length formatting --- mne/bem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mne/bem.py b/mne/bem.py index b5b5df84498..8b9e3942891 100644 --- a/mne/bem.py +++ b/mne/bem.py @@ -1322,7 +1322,8 @@ def make_watershed_bem( "Make sure:\n" "- FREESURFER_HOME is set\n" "- $FREESURFER_HOME/bin is in your PATH\n" - "- You started Python/Jupyter from a terminal where SetupFreeSurfer.sh is sourced\n\n" + "- You started Python/Jupyter from a terminal where " + "SetupFreeSurfer.sh is sourced\n\n" "See MNE installation documentation for details." ) from e del tempdir # clean up directory From 9e546fc519266855694cf26c3ab37e43704274f4 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Mon, 13 Apr 2026 09:55:46 +0530 Subject: [PATCH 07/10] Added author attribution to changelog entry for PR #13790. --- doc/changes/dev/13790.enhancement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/dev/13790.enhancement.rst b/doc/changes/dev/13790.enhancement.rst index 90846b96bee..f3c9cbcaba9 100644 --- a/doc/changes/dev/13790.enhancement.rst +++ b/doc/changes/dev/13790.enhancement.rst @@ -1 +1 @@ -Improved error message when FreeSurfer executable is not found. +Improved error message when FreeSurfer executable is not found, by `Ayushi Satodiya`_. From eba20019e24221ba873edbeeb863ea2c5f863894 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Mon, 13 Apr 2026 10:37:36 +0530 Subject: [PATCH 08/10] Fix changelog type to bugfix --- doc/changes/dev/{13790.enhancement.rst => 13790.bugfix.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/changes/dev/{13790.enhancement.rst => 13790.bugfix.rst} (100%) diff --git a/doc/changes/dev/13790.enhancement.rst b/doc/changes/dev/13790.bugfix.rst similarity index 100% rename from doc/changes/dev/13790.enhancement.rst rename to doc/changes/dev/13790.bugfix.rst From 01563664648e2ce1880b29f917f15ad3fa97dcff Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Fri, 17 Apr 2026 17:52:28 +0530 Subject: [PATCH 09/10] DOC: Add contributor name to names.inc --- doc/changes/names.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/names.inc b/doc/changes/names.inc index d3dbb9c8995..a62d0a531c2 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -34,6 +34,7 @@ .. _Arne Pelzer: https://github.com/aplzr .. _Ashley Drew: https://github.com/ashdrew .. _Asish Panda: https://github.com/kaichogami +.. _Ayushi Satodiya: https://github.com/ayuclan .. _Austin Hurst: https://github.com/a-hurst .. _Beige Jin: https://github.com/BeiGeJin .. _Ben Beasley: https://github.com/musicinmybrain From 97a34ef7841ce4bd352adacaaccfb7b428ddf639 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 12:22:47 +0000 Subject: [PATCH 10/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/changes/names.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/names.inc b/doc/changes/names.inc index a62d0a531c2..90e517d2427 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -34,8 +34,8 @@ .. _Arne Pelzer: https://github.com/aplzr .. _Ashley Drew: https://github.com/ashdrew .. _Asish Panda: https://github.com/kaichogami -.. _Ayushi Satodiya: https://github.com/ayuclan .. _Austin Hurst: https://github.com/a-hurst +.. _Ayushi Satodiya: https://github.com/ayuclan .. _Beige Jin: https://github.com/BeiGeJin .. _Ben Beasley: https://github.com/musicinmybrain .. _Benedikt Ehinger: https://www.benediktehinger.de