Hello,
Here is a piece of code to get you started:
from mne.io import read_raw
from mne.preprocessing import ICA
fname = "PN00-1.edf"
raw = read_raw(fname, preload=True)
# remove flat channels
raw.drop_channels(["SPO2", "MK", "HR"])
# fix auxiliary channels names/types
raw.rename_channels({"EKG EKG": "ECG1", "2": "ECG2", "1": "EOG"})
raw.set_channel_types({"ECG1": "ecg", "ECG2": "ecg", "EOG": "eog"})
# fix EEG channels names
raw.rename_channels(
{ch: ch.split(" ")[1] for ch in raw.ch_names if "EEG" in ch}
)
# fix EEG channels for the template montage
# set a template montage
raw.rename_channels(
{"Fc1": "FC1", "Fc5": "FC5", "Cp1": "CP1",
"Cp5": "CP5", "Fc2": "FC2", "Fc6": "FC6",
"Cp2": "CP2", "Cp6": "CP6"}
)
raw.set_montage("standard_1020")
# ICA
ica = ICA(n_components=None, method="picard")
raw = raw.filter(l_freq=1., h_freq=40.)
# (optional) fixing the highpass and lowpass values in raw.info that are
# incorrect from loading, it's bothering me
with raw.info._unlock():
raw.info["highpass"] = 1.
raw.info["lowpass"] = 40.
ica.fit(raw, picks="eeg")
Note that I don’t know how this dataset is filtered, read_raw
loads (1.6 - 30) Hz, but that’s definitely false judging by the PSD and by filtering at 1 Hz for the ICA.
You also have some sharp large amplitude events, which I would tend to annotate as ‘bads_segments’. Please have a look at this tutorial for annotations. For instance:
I did not annotate them as ‘bad_segments’ when I ran the ICA below, because of ‘Epilepsy’ keyword in the title. Maybe those correspond to some epileptic activity, although I doubt it, and it looks to me like the epileptic activity is around the ‘middle’ of the recording here:
But I don’t have any experience with epileptic dataset, so please take this information with a grain of salt.
Anyway, with this filtering and with an ICA fitted on the EEG channels, I do get some coherent (although not that great) ICs:
You can probably improve the IC fit by annotating as ‘bad_segment’ the noisy segments, and by fitting independently the ‘normal’ and epileptic activities.
Mathieu