Skip to content

Repairing artifacts with regression - Using the wrong regression coefficients #12977

Closed

Description

@JacPhe

Proposed documentation enhancement

In the aforementioned tutorial, under "Subtract the evoked response from the epoch data before regression":

I think that
epochs_clean_sub = model_plain.apply(epochs)
is incorrect, as this applies the regression coefficients from model_plain, which was trained on the default epochs, rather than epochs.subtract_evoked().

I think it should be
epochs_clean_sub = model_sub.apply(epochs)
instead. Otherwise, model_sub appears to be redundant.

Activity

  1. welcome commented on Nov 20, 2024

    @welcome

    Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

  2. scott-huberty commented on Nov 20, 2024

    @scott-huberty
    Contributor

    Huh, I think you are right @JacPhe . Would you be up for a PR to fix this?

    Also just to be safe, CC'ing @wmvanvliet as the author of that tutorial... On line 152 shouldn't model_plan.apply(...) actually be model_sub.apply(...)?

    # create epochs with the evoked subtracted out
    epochs_sub = epochs.copy().subtract_evoked()
    # perform regression
    model_sub = EOGRegression(picks="eeg", picks_artifact="eog").fit(epochs_sub)
    fig = model_sub.plot(vlim=(None, 0.4))
    fig.set_size_inches(3, 2)
    # apply the regression coefficients to the original epochs
    epochs_clean_sub = model_plain.apply(epochs).apply_baseline()
    fig = epochs_clean_sub.average("all").plot(**plot_kwargs)
    fig.set_size_inches(6, 6)

  3. JacPhe commented on Nov 20, 2024

    @JacPhe
    ContributorAuthor

    I've sent a pull request just in case, hopefully that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions