"picks_trace='ecg' leads to error or shows EEG002 channel instead

Greetings,

I am exploring different methods of MNE 1.5.1 for preprocessing of MEG and EEG data. At the moment I am working with SSP for artifact rejection of ECG. i am following the documentation and the code works fine (that means the projectors look accurate according to ecg), until i want to look at a joint plot of the projectors.

the example data has no dedicated ECG Channel, but my data has.

if i use the suggested code of the documentation with picks_trace=‘ecg’ for present ecg channel in the data, i get a “ValueError: picks (‘ecg’) could not be interpreted as channel names (no channel “[‘ecg’]”), channel types (no type “ecg” present), or a generic type (just “all” or “data”).”

In addition i tried ‘ECG’ (the actual name of the ecg-channel), what caused the same error.

fig = mne.viz.plot_projs_joint(ecg_projs, ecg_evoked, picks_trace=‘ecg’)
fig.suptitle(“ECG projectors”)

If i use index of the ecg-channel, the plot gets shown, but it takes the “EEG002” channel instead of the ECG channel.

ecg_channel_index = raw.ch_names.index(‘ECG’)
fig =mne.viz.plot_projs_joint(ecg_projs,ecg_evoked,picks_trace=ecg_channel_index)
fig.suptitle(“ECG projectors”)

I am not sure on which data picks_trace is taking the ecg channel, is it from the raw data or from the ecg_evoked? because in the ecg_evoked there is no ECG-channel present

Maybe someone of the forum can tell me what i am missing or how i can correctly use the ECG-channel for the “plot_projs_joint()” function.

Let me know if more information of code is needed.

Thank you in advance!

1 Like

hello, sorry for the slow reply! in plot_projs_joint, picks_trace must refer to a channel name that is present in the Evoked object that you’re passing into the function (in your case, that is ecg_evoked). The channel is probably getting automatically dropped somewhere along the way; probably because of a default picks="data" in Epochs.average(). Changing this to picks="all" should hopefully fix it (though might introduce problems elsewhere in the tutorial, if the ecg_evoked needs to have only data channels for some reason).

1 Like

hello, no worrys ! i have still so much to explore in MNE in the mean time. Thank you very much for your response.

Adding picks='all' when creating the ecg_evoked gave me the ecg channel i needed. instead of picks_trace='ecg' i then, just needed to use 'ecg' without picks_trace

now the plot shows the real ECG channel with the projections.

greetings

1 Like