Skip to content

Commit 71c294a

Browse files
sappelhofflarsoner
andauthored
FIX: do not print dev_head_t if not available (#13741)
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent c3db378 commit 71c294a

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

mne/dipole.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,11 @@ def fit_dipole(
15691569
safe_false = _verbose_safe_false()
15701570
bem = _setup_bem(bem, bem_extra, neeg, mri_head_t, verbose=safe_false)
15711571
if not bem["is_sphere"]:
1572+
if trans == "identity": # = trans was passed as None
1573+
raise ValueError(
1574+
"`trans` is ``None``, but bem model is not spherical. "
1575+
"You must pass a valid `trans` in this case."
1576+
)
15721577
# Find the best-fitting sphere
15731578
inner_skull = _bem_find_surface(bem, "inner_skull")
15741579
inner_skull = inner_skull.copy()
@@ -1652,7 +1657,8 @@ def fit_dipole(
16521657
logger.info("")
16531658

16541659
_print_coord_trans(mri_head_t)
1655-
_print_coord_trans(info["dev_head_t"])
1660+
if info["dev_head_t"]:
1661+
_print_coord_trans(info["dev_head_t"])
16561662
logger.info(f"{len(info['bads'])} bad channels total")
16571663

16581664
# Forward model setup (setup_forward_model from setup.c)

mne/tests/test_dipole.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ def test_min_distance_fit_dipole():
365365

366366
with pytest.raises(ValueError, match="min_dist should be positive"):
367367
fit_dipole(evoked, cov, fname_bem, fname_trans, -1.0)
368+
with pytest.raises(ValueError, match="not spherical"):
369+
fit_dipole(evoked, cov, bem, trans=None)
368370

369371

370372
def _compute_depth(dip, fname_bem, fname_trans, subject, subjects_dir):

tools/install_pre_requirements.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ python -m pip install $STD_ARGS --only-binary ":all:" --default-timeout=60 \
3232
"tables>=3.10.3.dev0" \
3333
"pyarrow>=22.0.0.dev0" \
3434
"matplotlib>=3.11.0.dev0" \
35+
"statsmodels>=0.15.0.dev0" \
3536
"h5py>=3.13.0"
36-
# "statsmodels>=0.15.0.dev697"
3737
echo "::endgroup::"
38-
# No statsmodels because of https://github.com/MacPython/statsmodels-wheels/issues/202
3938
# No Numba because it forces an old NumPy version
4039

4140
echo "::group::VTK"

0 commit comments

Comments
 (0)