Hello,
I am trying to calculate correlations between ICA components and external electrodes placed on the upper and lower lip of a participant.
Thus far, I have extracted the components as an array, and the raw data reduced to the electrodes with which I want to calculate the correlation. I am rather stuck with how to proceed, however.
My thinking here is to use either np.correlate
or np.corrcoef
, though I don’t know which, if either, is appropriate. The end goal is to find those ICA components which most highly correlate with activity in these external electrodes so that they might be excluded from the raw signal. I wonder if what I’m hoping to achieve is similar to the EOG, ECG, or EMG detection procedures outlined in the examples given online.
I haven’t worked out how to adapt Annotate muscle artifacts — MNE 1.8.0 documentation or Removing muscle ICA components — MNE 1.8.0 documentation to my problem, and perhaps there is something there I’ve overlooked.
The code snippet below is a rough overview of what I have attempted.
import mne
import numpy as np
raw = mne.io.read_raw_fif(subjects[0])
ica = mne.preprocessing.read_ica(ica_fits[0])
lip_electrodes = raw.copy().pick(["upper_lip", "lower_lip"])
lip_data = lip_electrodes.get_data()
ica_data = ica.get_components()
upper_lip_data = lip_data[0]
lower_lip_data = lip_data[1]
ica_data_flat = ica_data.flatten()
np.correlate(upper_lip_data, ica_data_flat)
MNE version: 1.8.0
OS: macOS 15.1.1