Skip to content

Commit d00bc9f

Browse files
committed
FIX: Test explicitly
1 parent 6c10786 commit d00bc9f

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

mne/viz/ica.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,6 @@ def _fast_plot_ica_properties(
590590
inst, ica, reject_by_annotation, reject
591591
)
592592
del reject, inst
593-
if len(epochs_src) == 0:
594-
return [fig]
595593
epochs_src_picked = epochs_src.pick(picks)
596594
del epochs_src
597595
good_indices = np.setdiff1d(np.arange(len(epochs_src_picked)), bad_indices)
@@ -749,6 +747,11 @@ def _prepare_data_ica_properties(inst, ica, reject_by_annotation=True, reject="a
749747
bad_indices = np.where([len(log) for log in epochs.drop_log])[0]
750748
kind = "Segment"
751749
assert len(epochs_src) == len(epochs) + len(bad_indices)
750+
if len(epochs_src) == len(bad_indices):
751+
raise RuntimeError(
752+
f"No clean 2-second segments found out of {len(events)} using "
753+
f"{reject=} and {reject_by_annotation=}."
754+
)
752755
else:
753756
epochs_src = ica.get_sources(inst)
754757
kind = "Epochs"

mne/viz/tests/test_ica.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ def test_plot_ica_properties_reject(kind):
321321
assert min_hist > 0
322322
scatter_x, _ = var_ax.collections[0].get_offsets().data.T
323323
assert_array_equal(scatter_x, np.arange(n_epochs))
324+
with pytest.raises(RuntimeError, match="No clean"):
325+
ica.plot_properties(raw, reject=dict(eeg=1e-6))
324326

325327

326328
def test_plot_ica_sources(raw_orig, browser_backend, monkeypatch):

0 commit comments

Comments
 (0)