Skip to content

Commit

Permalink
MRG, BUG: Fix config (mne-tools#6991)
Browse files Browse the repository at this point in the history
* BUG: Fix config

* FIX: Overwrite [ci skip]
  • Loading branch information
larsoner authored Oct 28, 2019
1 parent e58b72f commit 799c2ec
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mne/bem.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
_fast_cross_nd_sum, _get_solids)
from .transforms import _ensure_trans, apply_trans, Transform
from .utils import (verbose, logger, run_subprocess, get_subjects_dir, warn,
_pl, _validate_type, _TempDir)
_pl, _validate_type, _TempDir, get_config)
from .fixes import einsum


Expand Down Expand Up @@ -1153,7 +1153,8 @@ def make_watershed_bem(subject, subjects_dir=None, overwrite=False,
read_metadata=True)
volume_info.update(new_info) # replace volume info, 'head' stays

write_surface(s, rr, tris, volume_info=volume_info)
write_surface(s, rr, tris, volume_info=volume_info,
overwrite=overwrite)
# Create symbolic links
surf_out = op.join(bem_dir, '%s.surf' % s)
if not overwrite and op.exists(surf_out):
Expand Down Expand Up @@ -1563,7 +1564,8 @@ def write_bem_solution(fname, bem):
def _prepare_env(subject, subjects_dir, requires_freesurfer):
"""Prepare an env object for subprocess calls."""
env = os.environ.copy()
if requires_freesurfer and not os.environ.get('FREESURFER_HOME'):
fs_home = get_config('FREESURFER_HOME')
if fs_home is None:
raise RuntimeError('I cannot find freesurfer. The FREESURFER_HOME '
'environment variable is not set.')

Expand All @@ -1577,8 +1579,8 @@ def _prepare_env(subject, subjects_dir, requires_freesurfer):
if not op.isdir(subject_dir):
raise RuntimeError('Could not find the subject data directory "%s"'
% (subject_dir,))
env['SUBJECT'] = subject
env['SUBJECTS_DIR'] = subjects_dir
env.update(SUBJECT=subject, SUBJECTS_DIR=subjects_dir,
FREESURFER_HOME=fs_home)
mri_dir = op.join(subject_dir, 'mri')
bem_dir = op.join(subject_dir, 'bem')
return env, mri_dir, bem_dir
Expand Down

0 comments on commit 799c2ec

Please sign in to comment.