Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot concat epochs if baseline period was cropped off #12153

Open
hoechenberger opened this issue Oct 30, 2023 · 6 comments
Open

Cannot concat epochs if baseline period was cropped off #12153

hoechenberger opened this issue Oct 30, 2023 · 6 comments
Labels

Comments

@hoechenberger
Copy link
Member

Description of the problem

concatenate_epochs() refuses to operate on Epochs if their baseline period has been cropped away.

Steps to reproduce

# %%
import mne

sample_dir = mne.datasets.sample.data_path()
sample_fname = sample_dir / "MEG" / "sample" / "sample_audvis_raw.fif"

raw = mne.io.read_raw_fif(sample_fname)
raw.crop(tmax=60)

events = mne.find_events(raw, stim_channel="STI 014")
event_id = {
    "auditory/left": 1,
    "auditory/right": 2,
    "visual/left": 3,
    "visual/right": 4,
    "face": 5,
    "buttonpress": 32,
}

epochs = mne.Epochs(
    raw,
    events=events,
    event_id=event_id,
    tmin=-0.2,
    tmax=0.5,
    baseline=(None, 0),
    preload=True,
)

epochs.crop(0, None)  # crop away baseline period
mne.concatenate_epochs([epochs, epochs])

Link to data

No response

Expected results

Concatenation should work

Actual results

ValueError: Baseline interval [-0.19979521315838786, 0.0] s is outside of epochs data [0.0, 0.49948803289596966] s. Epochs were probably cropped.

Additional information

@agramfort
Copy link
Member

agramfort commented Oct 30, 2023 via email

@hoechenberger
Copy link
Member Author

hoechenberger commented Oct 30, 2023

why cropping the baseline in the first place?

It's something we do in MNE-BIDS-Pipeline during decoding, which we usually start at time point zero (as to omit the baseline). We crop the epochs and then concatenate epochs of different conditions before feeding them to the classifier.

I have now simply changed the order of doing things: first concat, then crop.

It's a viable workaround, but I believe not being able to concat if the baseline has been cropped is unintended behavior, hence a bug

Nothing urgent, but I think we should fix it if / when we have time

The problem started showing up while working on mne-tools/mne-bids-pipeline#796

@agramfort

This comment was marked as resolved.

@hoechenberger

This comment was marked as resolved.

@hoechenberger

This comment was marked as resolved.

@agramfort

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants