Cannot find ecg artifacts during ica

Hi Richard,
I’m considering epoch my raw data first and then do the ica to see whether the ecg scalp map and the ecg evoked plot will get any better since there actually still many artifacts and noise in my raw data which although had been high-pass filtered and annotated muscle artifacts and removed power line noise (for example, the figure below). In fact, the very beginning and the end of the raw data contained no information on the experiment task, they’re just the preparation and the rest periods of my task.


I would really suggest to take a step back and figure out why the generation of ECG evokeds doesn’t seem to work properly. As long as we cannot figure that out, automated ECG rejection via ICA will most likely not work either

Okay, I follow your suggestions,

ecg_events, ch_ecg, average_pulse, ecg = mne.preprocessing.find_ecg_events(raw_perception, return_ecg=True, verbose=True)
ecg_epoch = mne.Epochs(raw_perception, ecg_events)
ecg_evoked = ecg_epoch.average()
ecg_evoked.apply_baseline(baseline=(None, -0.2))
ecg_evoked.plot_joint()

Returns:
It said that Reconstructing ECG signal from “Magnetometers”, is that right?

Reconstructing ECG signal from Magnetometers
Setting up band-pass filter from 5 - 35 Hz

FIR filter parameters
---------------------
Designing a two-pass forward and reverse, zero-phase, non-causal bandpass filter:
- Windowed frequency-domain design (firwin2) method
- Hann window
- Lower passband edge: 5.00
- Lower transition bandwidth: 0.50 Hz (-12 dB cutoff frequency: 4.75 Hz)
- Upper passband edge: 35.00 Hz
- Upper transition bandwidth: 0.50 Hz (-12 dB cutoff frequency: 35.25 Hz)
- Filter length: 10000 samples (10.000 sec)

Number of ECG events detected : 680 (average pulse 100 / min.)

I don’t know if I was doing right, but the figures not look like so:

That’s quite a high heart rate, did you expect this?

Plot the detected events onto the raw data to see if they even make sense.

raw_perception.plot(events=ecg_events)




it seems unsual, the intervals between two adjacent ecg events have varying lengths, but how can this happen?

Obviously the automated ECG peak detection is not working, or the participant in question has some sort of cardiovascular condition
? What you can try is find a channel that appears to have a relatively clear ECG artifact and pass its ch_name to find_ecg_events(), and see if that produces any better results?

Hi Richard,
I checked another subject, same thing happened in him, so it’s not the problem of subjects. Then I tried to find the ecg artifacts in raw data plot according to the ecg pattern shown in the tutorial(the figure below):

But unfortunally, I didn’t found one in my data, here is what the pattern look like in my data in some similar channels as the tutorial used:



Yeah there doesn’t seem to be much of an ECG artifact, so the peak finder will fail.

Since there doesn’t seem to be a clear ECG signal in your data anyway, why do you still want to remove it? Seems like it doesn’t affect the recordings too much


hhhh

 :joy: you’re absolutely right! Why should I, bother myself so much :joy: :joy: :joy: :joy:
I just thought everybody has heartbeats, so the ecg must exist, which turns out it’s a wrong idea?

That’s what I’m hoping too! :sweat_smile:

I’m not sure why there’s no strong ECG artifact in the magnetometer data. Maybe it has been pre-processed already? No idea


Okay, anyway, thank you verrrrrry much! :heart: :heart: Your support is greatly appreciated. It’s my first time dealing with MEG data, glad you’re here :blush: :blush: :blush:

1 Like

I have another question, it’s better to do ica after epoch, right? So maybe after removing power line noise, annotate muscle artifacts, I should run epoch, then do ica?

If you want to work with epoched data eventually anyway, then it makes sense to run ICA on epochs, yes. And annotating muscle artifacts and filtering out power line noise – or simply cutting it away by applying a low-pass filter – can also be a good idea. Most importantly, run a high-pass filter on your data before running ICA. Good luck!

Okay, got it! Thanks a million

ECG detection does not work properly after the MEG signal has been processed with maxfilter, since maxfilter removes a lot of the heartbeat signal (but not all of it). What I usually do is run find_ecg_events on the raw, non-maxfiltered data and use those events later to make ECG epochs on the maxfiltered version.

2 Likes

Hi,
Thanks for your replay! I did use the fif file end with _tsss.fif, I didn’t know what the process was done to the raw fif file at first, but after you mentioned, I guess that would be maxfilter. By the way, since you talked about how to make ECG epochs, will you remove ECG from your data, or just ignore it when the independent component source plot produced from _tsss data didn’t show one?

If I didn’t have access to the non-maxfiltered data and the heartbeat detection was not working for me, I think I would just ignore ECG artifacts. This scenario is unlikely however, usually the raw data has been available to me. It also depends on what you are trying to prove with your study: are heartbeats going to interfere with whatever you are trying to show/prove?

1 Like

My concentration is on visual perception (the ventral visual pathway) and memory, I’m not sure whether the ECG will interfere with the effect I want, but it seems like the ECG rejection is a “normal routine/operation” everyone follows.Since I will do the ICA using the epoched data, so using raw data to fit ica seems impracticable to me. What I’m decide to do is if there is an obvious ECG component shown in the ICs source plot while the scalp map might look odd like what I mentioned above, I would consider to exclude it, but if there is not an ECG component shown in the ICs source plot, I might just ignore it.

A post was split to a new topic: question about cardiac artifacts & ICA