From 87d6be9047bbd5b234e22eafd79ab7695814fb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20H=C3=B6chenberger?= Date: Fri, 3 Nov 2023 14:05:04 +0100 Subject: [PATCH] Try to fix ICA Report (#12167) --- doc/changes/devel.rst | 2 +- mne/report/report.py | 8 +++++--- mne/report/tests/test_report.py | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/changes/devel.rst b/doc/changes/devel.rst index 57a9b1fcb41..fce4656104a 100644 --- a/doc/changes/devel.rst +++ b/doc/changes/devel.rst @@ -64,7 +64,7 @@ Bugs - Fix bug with :meth:`mne.viz.Brain.get_view` where calling :meth:`~mne.viz.Brain.show_view` with returned parameters would change the view (:gh:`12000` by `Eric Larson`_) - Fix bug with :meth:`mne.viz.Brain.show_view` where ``distance=None`` would change the view distance (:gh:`12000` by `Eric Larson`_) - Fix bug with :meth:`~mne.viz.Brain.add_annotation` when reading an annotation from a file with both hemispheres shown (:gh:`11946` by `Marijn van Vliet`_) -- Fix bug with reported component number and errant reporting of PCA explained variance as ICA explained variance in :meth:`mne.Report.add_ica` (:gh:`12155` by `Eric Larson`_) +- Fix bug with reported component number and errant reporting of PCA explained variance as ICA explained variance in :meth:`mne.Report.add_ica` (:gh:`12155`, :gh:`12167` by `Eric Larson`_ and `Richard Höchenberger`_) - Fix bug with axis clip box boundaries in :func:`mne.viz.plot_evoked_topo` and related functions (:gh:`11999` by `Eric Larson`_) - Fix bug with ``subject_info`` when loading data from and exporting to EDF file (:gh:`11952` by `Paul Roujansky`_) - Fix bug where :class:`mne.Info` HTML representations listed all channel counts instead of good channel counts under the heading "Good channels" (:gh:`12145` by `Eric Larson`_) diff --git a/mne/report/report.py b/mne/report/report.py index a99414697d9..18ca4be3768 100644 --- a/mne/report/report.py +++ b/mne/report/report.py @@ -587,9 +587,6 @@ def _plot_ica_properties_as_arrays(*, ica, inst, picks, n_jobs): """ import matplotlib.pyplot as plt - if picks is None: - picks = list(range(ica.n_components_)) - def _plot_one_ica_property(*, ica, inst, pick): figs = ica.plot_properties(inst=inst, picks=pick, show=False) assert len(figs) == 1 @@ -1666,9 +1663,14 @@ def _add_ica_properties( ) return + if picks is None: + picks = list(range(ica.n_components_)) + figs = _plot_ica_properties_as_arrays( ica=ica, inst=inst, picks=picks, n_jobs=n_jobs ) + assert len(figs) == len(picks) + captions = [] for idx in range(len(figs)): caption = f"ICA component {picks[idx]}." diff --git a/mne/report/tests/test_report.py b/mne/report/tests/test_report.py index 9f8760dfbb6..67b065ad4fe 100644 --- a/mne/report/tests/test_report.py +++ b/mne/report/tests/test_report.py @@ -984,6 +984,7 @@ def test_manual_report_2d(tmp_path, invisible_fig): inst=epochs_baseline, picks=[0], ) + r.add_ica(ica=ica, title="my ica with picks=None", inst=epochs_baseline, picks=None) r.add_covariance(cov=cov, info=raw_fname, title="my cov") r.add_forward( forward=fwd_fname,