Skip to content

Commit 3455d64

Browse files
ayuclanpre-commit-ci[bot]larsoner
authored
BUG: improve FreeSurfer error message when executable not found (#13874)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent b9b83b8 commit 3455d64

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

doc/changes/dev/13874.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improved error message when FreeSurfer executable is not found, by :newcontrib:`Ayushi Satodiya`.

doc/changes/names.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
.. _Ashley Drew: https://github.com/ashdrew
3636
.. _Asish Panda: https://github.com/kaichogami
3737
.. _Austin Hurst: https://github.com/a-hurst
38+
.. _Ayushi Satodiya: https://github.com/ayuclan
3839
.. _Beige Jin: https://github.com/BeiGeJin
3940
.. _Ben Beasley: https://github.com/musicinmybrain
4041
.. _Benedikt Ehinger: https://www.benediktehinger.de

mne/bem.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,19 @@ def make_watershed_bem(
13131313
f"\nResults dir = {ws_dir}\nCommand = {' '.join(cmd)}\n"
13141314
)
13151315
os.makedirs(op.join(ws_dir))
1316-
run_subprocess_env(cmd)
1316+
try:
1317+
run_subprocess_env(cmd)
1318+
except FileNotFoundError as e:
1319+
raise RuntimeError(
1320+
"FreeSurfer executable 'mri_watershed' not found.\n\n"
1321+
"This usually means FreeSurfer is not properly configured.\n"
1322+
"Make sure:\n"
1323+
"- FREESURFER_HOME is set\n"
1324+
"- $FREESURFER_HOME/bin is in your PATH\n"
1325+
"- You started Python/Jupyter from a terminal where "
1326+
"SetupFreeSurfer.sh is sourced\n\n"
1327+
"See https://mne.tools/stable/install/index.html for details."
1328+
) from e
13171329
del tempdir # clean up directory
13181330
if op.isfile(T1_mgz):
13191331
new_info = _extract_volume_info(T1_mgz)

0 commit comments

Comments
 (0)