Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/dev/14188.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :func:`mne.concatenate_epochs` failing on epochs cropped after baseline correction, by `Kalle Makela`_.
4 changes: 3 additions & 1 deletion mne/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4907,14 +4907,16 @@ def concatenate_epochs(
events=events,
event_id=event_id,
tmin=tmin,
baseline=baseline,
baseline=None,
selection=selection,
drop_log=drop_log,
proj=False,
on_missing="ignore",
metadata=metadata,
raw_sfreq=raw_sfreq,
)
# Don't reapply baseline correction. Restore the original baseline metadata.
out.baseline = baseline
out.drop_bad()
return out

Expand Down
11 changes: 11 additions & 0 deletions mne/tests/test_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3867,6 +3867,17 @@ def test_concatenate_epochs():
concatenate_epochs([epochs, epochs2], add_offset=True)


def test_concatenate_epochs_cropped_baseline():
"""Test concatenating epochs cropped after baseline correction."""
data = np.arange(21.0)[np.newaxis, np.newaxis]
epochs = EpochsArray(data, create_info(["x"], 10, "eeg"), tmin=-1)
epochs.apply_baseline((-1, 0)).crop(0, 1)
expected = epochs.get_data()
epochs_conc = concatenate_epochs([epochs])
assert epochs_conc.baseline == (-1.0, 0.0)
assert_allclose(epochs_conc.get_data(), expected)


@pytest.mark.slowtest
def test_concatenate_epochs_large():
"""Test concatenating epochs on large data."""
Expand Down
Loading