From 4290d9ac1182afa09a7d16733f732450434badbb Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 11 Sep 2024 14:43:42 -0400 Subject: [PATCH] FIX: Dim --- mne_nirs/tests/test_examples.py | 2 ++ mne_nirs/utils/_io.py | 6 +++++- mne_nirs/visualisation/_plot_GLM_topo.py | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mne_nirs/tests/test_examples.py b/mne_nirs/tests/test_examples.py index 17b00916c..5f1e20a05 100644 --- a/mne_nirs/tests/test_examples.py +++ b/mne_nirs/tests/test_examples.py @@ -44,6 +44,8 @@ def examples_path(): ) +# TODO: Change ax= to axes= once nilearn 0.11 is out +@pytest.mark.filterwarnings('ignore:The parameter "ax" will be removed.*:') @pytest.mark.filterwarnings("ignore:No bad channels to interpolate.*:") @pytest.mark.filterwarnings("ignore:divide by zero encountered.*:") @pytest.mark.filterwarnings("ignore:invalid value encountered.*:") diff --git a/mne_nirs/utils/_io.py b/mne_nirs/utils/_io.py index 9b89be144..34b3ff319 100644 --- a/mne_nirs/utils/_io.py +++ b/mne_nirs/utils/_io.py @@ -70,6 +70,10 @@ def _tidy_Contrast(data, glm_est, design_matrix): contrast_type = glm_est.stat_type else: # nilearn < 0.10 contrast_type = glm_est.contrast_type + effect = glm_est.effect + if effect.ndim == 2: # old nilearn + assert effect.shape[0] == 1 + effect = effect[0] for idx, ch in enumerate(data.ch_names): df = pd.concat( [ @@ -79,7 +83,7 @@ def _tidy_Contrast(data, glm_est, design_matrix): "ch_name": ch, "ContrastType": contrast_type, "variable": "effect", - "value": glm_est.effect[0][idx], + "value": effect[idx], }, index=[0], ), diff --git a/mne_nirs/visualisation/_plot_GLM_topo.py b/mne_nirs/visualisation/_plot_GLM_topo.py index 2018c4757..a6709220c 100644 --- a/mne_nirs/visualisation/_plot_GLM_topo.py +++ b/mne_nirs/visualisation/_plot_GLM_topo.py @@ -118,7 +118,10 @@ def _plot_glm_contrast_topo(inst, contrast, figsize=(12, 7), sphere=None): types = np.unique(info.get_channel_types()) # Extract values to plot and rescale to uM - estimates = contrast.effect[0] + estimates = contrast.effect + if estimates.ndim == 2: # old nilearn + assert estimates.shape[0] == 1 + estimates = estimates[0] estimates = estimates * 1e6 # Create subplots for figures