diff --git a/doc/changes/dev/13790.bugfix.rst b/doc/changes/dev/13790.bugfix.rst new file mode 100644 index 00000000000..f3c9cbcaba9 --- /dev/null +++ b/doc/changes/dev/13790.bugfix.rst @@ -0,0 +1 @@ +Improved error message when FreeSurfer executable is not found, by `Ayushi Satodiya`_. diff --git a/doc/changes/names.inc b/doc/changes/names.inc index d3dbb9c8995..90e517d2427 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -35,6 +35,7 @@ .. _Ashley Drew: https://github.com/ashdrew .. _Asish Panda: https://github.com/kaichogami .. _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 diff --git a/mne/bem.py b/mne/bem.py index bb73544f763..8b9e3942891 100644 --- a/mne/bem.py +++ b/mne/bem.py @@ -1313,7 +1313,19 @@ 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 as e: + 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 " + "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)