Repository navigation
|
Hi My .edf files contain recordings from multiple modalities. I extract only EEG channels of interest, EOG and EMG. However, due to the naming EMG channel is by default recognised as EEG. That is why I change its type with the code line: data.set_channel_types({'EMG1-EMG2': 'emg'}). Here is the part of the code: During printing data.get_channel_types(), I can see that EMG1-EMG2 now is recognised as emg. However, I was thinking that the problem occurs because I had changed the channel type manually. If so, I need to change the name of the EMG channel in .edf file before I read it, so it would be recognised automatically by the algo. Best, |
Replies: 1 comment
|
Hi, here's a few thoughts. YASA doesn't really care about the MNE channel types. When you specify the channels during the initialization of a I used the YASA sample data file from the Quickstart page (or direct link here) to show 2 things: (1) YASA doesn't care about MNE channel types, and (2) YASA is generating EMG features, at least in my setup. import mne
import yasa
# Load and preprocess sample data with 3 channels
channels = ["C3-A2", "EMG1-EMG2", "ROC-A1"]
raw = mne.io.read_raw_edf("yasa_example_night_young.edf", include=channels, preload=True, verbose=False)
raw.resample(100)
raw.filter(0.3, 45, verbose=False)
# Get a list of default MNE channel types
ch_types = raw.get_channel_types()
# Run YASA sleep staging with default MNE channel types
sls = yasa.SleepStaging(raw, eeg_name="C3-A2", emg_name="EMG1-EMG2", eog_name="ROC-A1")
features = sls.get_features()
emg_columns = features.filter(like="emg").columns.tolist()
n_emg_columns = len(emg_columns)
# Modify the MNE channel types
raw.set_channel_types({"EMG1-EMG2": "emg", "ROC-A1": "eog"})
modified_ch_types = raw.get_channel_types()
# Rerun YASA sleep staging with modified MNE channel types
modified_sls = yasa.SleepStaging(raw, eeg_name="C3-A2", eog_name="ROC-A1", emg_name="EMG1-EMG2")
modified_features = modified_sls.get_features()
modified_emg_columns = modified_features.filter(like="emg").columns.tolist()
modified_n_emg_columns = len(modified_emg_columns)
# Check if the results are identical no matter what the MNE channel types are
equal_features = features.equals(modified_features)
# Print results
print("====== Sleep Staging with Default MNE Channel Types ".ljust(75, "="))
print("Default channel types:", ch_types)
print("Number of YASA EMG features:", n_emg_columns)
print("First 3 YASA EMG columns:", emg_columns[:3])
print("====== Sleep Staging with Modified MNE Channel Types ".ljust(75, "="))
print("Modified channel types:", modified_ch_types)
print("Number of YASA EMG features:", modified_n_emg_columns)
print("First 3 YASA EMG columns:", modified_emg_columns[:3])
print("====== Verifying that YASA is Agnostic to MNE Channel Types ".ljust(75, "="))
print("Are the two features DataFrames equal?", equal_features)My output from that is: Could you take the following steps?
|
Hi, here's a few thoughts.
YASA doesn't really care about the MNE channel types. When you specify the channels during the initialization of a
SleepStagingclass (e.g.,yasa.SleepStaging(raw, emg_name="EMG1-EMG2")), that will override whatever the MNE channel types are. So if you are not getting EMG features, the issue probably lies somewhere else.I used the YASA sample data file from the Quickstart page (or direct link here) to show 2 things: (1) YASA doesn't care about MNE channel types, and (2) YASA is generating EMG features, at least in my setup.