From 43935079d9ee7f299ffe097984304942678ae921 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Thu, 26 Mar 2026 17:31:30 +0530 Subject: [PATCH 1/3] 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 bcb87713a90b0eb80bc7fbdf5ec6e41c1c76d9ff 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 2/3] [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 2ae67dbebe3e1a19145a0cb8850878bef84da443 Mon Sep 17 00:00:00 2001 From: Ayushi Satodiya Date: Mon, 30 Mar 2026 12:13:08 +0530 Subject: [PATCH 3/3] 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