Skip to content

Fix concatenating epochs cropped after baseline correction - #14188

Merged
larsoner merged 2 commits into
mne-tools:mainfrom
kalomak:fix-concatenate-cropped
Aug 23, 2026
Merged

Fix concatenating epochs cropped after baseline correction#14188
larsoner merged 2 commits into
mne-tools:mainfrom
kalomak:fix-concatenate-cropped

Conversation

@kalomak

@kalomak kalomak commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Reference issue (if any)

Fixes #12153.

What does this implement/fix?

Fixes concatenate_epochs failing on epochs cropped after baseline correction.

Before this change, concatenation passed the original baseline to the EpochsArray constructor. The constructor rejected it because the baseline period was outside the cropped time range.

This uses the same approach as _evoked_from_epoch_data(): construct the result without baseline correction, then restore the original baseline metadata.

out = EpochsArray(..., baseline=None)
out.baseline = baseline

This means that mne.concatenate_epochs does not apply baseline correction when creating the new EpochsArray. Pending baseline corrections are already applied when the input epoch data are loaded earlier in the function.

@kalomak
kalomak marked this pull request as ready for review August 22, 2026 11:04

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable, thanks @kalomak !

@larsoner
larsoner merged commit 570df27 into mne-tools:main Aug 23, 2026
28 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot concat epochs if baseline period was cropped off

2 participants