Skip to content
1 change: 1 addition & 0 deletions doc/changes/dev/13790.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved error message when FreeSurfer executable is not found, by `Ayushi Satodiya`_.
1 change: 1 addition & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion mne/bem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading