Noise in epoch after filter&ICA&epochreject

  • MNE version: e.g. 1.8.0
  • operating system: Windows 11

I used ICLABEL and autoreact to help me automate the segmentation of EEG into epochs and remove noise

  1. The filtering frequency is 0.1-40hz
  2. Remove blink and line noise components with a probability greater than 0.8
    Question:
    Some of my subjects’ evokes showed abnormalities, as shown in the figure

I performed the following actions to investigate the cause of the problem

  1. View the PSD image of epoch

  2. View epoch sequence,as shown blow

There are some oscillations in the epoch, which I have marked with a red box
What could be the reason for this
My processing flow cannot delete these noises, what should I do?
I am a graduate student in psychology, conducting my first research. I have encountered many difficulties, and if I cannot solve them, it seems difficult for me to apply for a PhD. Please help me

# Process each data file
for data_path in file_paths:
    print(f"Processing file: {data_path}")

    # Read the raw data
    raw = mne.io.read_raw_eeglab(data_path, preload=True)
    print(raw.ch_names)

    # Set electrode positions
    montage = mne.channels.make_standard_montage("standard_1020")
    raw.set_montage(montage)
    raw = raw.resample(250)

    # Filter and set average reference for ICA
    raw_filter = raw.copy().filter(l_freq=1.0, h_freq=100.0)
    raw_filter = raw_filter.set_eeg_reference("average")

    # Calculate events and epochs
    events, event_id = mne.events_from_annotations(raw_filter)
    print(f"Event IDs: {event_id}")
    event_ids = {"self": 1, "luxun": 2, "baoyi": 3}

    epochs = mne.Epochs(
        raw_filter, events, event_id=event_ids, tmin=-0.2, tmax=1, baseline=None, detrend=1
    )

    # Train ICA
    ica = ICA(
        n_components=30, max_iter="auto", method="picard",
        random_state=42, fit_params=dict(ortho=False, extended=True)
    )
    ica.fit(epochs)
    epochs.load_data()

    # Automatically label ICA components
    ic_labels = label_components(epochs, ica, method="iclabel")
    print(f"IC Labels: {ic_labels['labels']}, {ic_labels['y_pred_proba']}")
    labels = ic_labels["labels"]
    y_pred_proba = ic_labels["y_pred_proba"]
    exclude_idx = [idx for idx, (label, proba) in enumerate(zip(labels, y_pred_proba)) if
                   label in ["eye blink", "line noise"] and proba > 0.8]
    excluded_components = len(exclude_idx)

    # Apply notch filter at 50Hz and bandpass filter
    raw = raw.notch_filter(freqs=(50))
    raw = raw.filter(l_freq=0.1, h_freq=35.0)
    raw = raw.set_eeg_reference('average')

    # Apply ICA to epochs
    epochs_ICAD = mne.Epochs(
        raw, events, event_id=event_ids, tmin=-0.2, tmax=1,
        baseline=None, preload=True, detrend=1
    )
    epochs_ICAD.load_data()
    ica.apply(epochs_ICAD, exclude=exclude_idx)

    # Apply baseline correction and remove data based on absolute voltage
    epochs_ICAD.apply_baseline(baseline=(-0.2, 0))

    # Perform automatic rejection of epochs post-ICA
    epochs_ICAD.info['bads'] = []
    ar = autoreject.AutoReject(n_interpolate=[1, 2, 4, 6, 8], random_state=42,
                               n_jobs=-1, verbose=True)
    ar.fit(epochs_ICAD)
    epochs_ICAD_ar, reject_ICAD_log = ar.transform(epochs_ICAD, return_log=True)

    # Plot the final processed epochs
    epochs_ICAD_ar.plot(block=True)

anyone there? :smiling_face_with_tear:

These look like alpha oscillations to me. Did (some of) the participants have their eyes closed during the experiment? Normally, given enough epochs these oscillations should cancel out, because they are not phase-locked, but apparently that’s not really the case in your data. I don’t know of any automated method to detect such segments, but you could probably inspect and mark those epochs manually just for the problematic participants and see if this improves the ERP.

1 Like

Thank you!! I think it is alpha wave too, i`m searching way to solve it automated

Hi,

I don’t exactly suggest it, 'cause I think it can easily turn into a big rabbit hole, but maybe bycycle is what you need.

Cheers,

2 Likes

Thanks!Are you suggesting that I use bycycle to calculate the frequency domain information for each epoch? For example, check if there is signal enhancement in the alpha frequency band.

IF you can tune it to detect only the time segments you are eye-balling (probably a bit more or a bit less of data) as “alpha bursts”, then I guess you can either reject epochs, or exclude/repair specific time windows and/or channels. I have not tried, though, to use it this way - I only assume that with some fiddling you can make it work.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.