Skip to content

mne.channels.combine_channels(epochs) drops metadata #10499

Closed

Description

@cbrnr

I think mne.channels.combine_channels(epochs) drops metadata (i.e. there is no epochs.metadata attribute in the resulting Epochs objects). I wanted to make sure that this is not intended – if it is a bug I'm happy to submit a PR.

Activity

  1. cbrnr commented on Apr 7, 2022

    @cbrnr
    ContributorAuthor

    Reprex:

    import mne
    
    root = mne.datasets.sample.data_path() / 'MEG' / 'sample'
    raw = mne.io.read_raw_fif(root / 'sample_audvis_filt-0-40_raw.fif', preload=False)
    events = mne.read_events(root / 'sample_audvis_filt-0-40_raw-eve.fif')
    raw.crop(tmax=90)
    raw.pick(['eeg', 'eog']).load_data()
    raw.rename_channels({name: name.replace(' 0', '').lower() for name in raw.ch_names})
    
    event_dict = {
        'auditory/left': 1,
        'auditory/right': 2,
        'visual/left': 3,
        'visual/right': 4,
        'face': 5,
        'buttonpress': 32
    }
    
    metadata, events, event_id = mne.epochs.make_metadata(
        events=events,
        event_id=event_dict,
        tmin=-0.3,
        tmax=0.7,
        sfreq=raw.info['sfreq']
    )
    
    epochs = mne.Epochs(
        raw,
        events,
        event_id=event_dict,
        tmin=-0.3,
        tmax=0.7,
        metadata=metadata,
        preload=True
    )
    
    print(epochs.metadata)  # metadata is still there
    print(
        mne.channels.combine_channels(
            epochs,
            {"ROI1": mne.pick_channels(epochs.ch_names, include=["eeg01", "eeg02", "eeg03"])}
        ).metadata  # metadata is gone
    )
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