Hey guys,
When I use find_bads_ecg() to find which ICs match the ECG pattern, it turns out that the ‘ecg_indices’ was empty no matter I modify the number of independent components as 15, 20, or 30. However, there did exist a component (ICA002) that looked like ecg in the ica components plot produced by ‘ica.plot_sources(raw_notch_filt_cp)’.
yes you can guess ECG in ICA002 but the unmixing is clearly not good enough.
Your ICA002 is still dominated by other artifacts. Maybe try to highpass the data a bit more
before doing ICA. Or just mark manually ICA002 as bad as the topo suggests it’s really ECG
The 1 Hz high-pass filter is a good choice. I’m wondering if you’re trying to squeeze to much info into too few components. Try n_components=0.9 or n_components=0.8. How many components will this produce?
Thanks for your suggestions very much! Because I have many subjects to run, and I hope the processing workflow to be as automatic as possible, so it’s better to recognize the ecg and eog by the script itself, that’s why I choose the way of ’ Using a simulated channel to select ICA components’ in the tutorial
Hi,
first I tried n_components=0.9, it produced 24 components; then I tried n_components=0.8, it produced 14 components. And neither of these two options found the ecg component
When n_components=0.999, it shows that ‘Selecting by explained variance: 66 components’, and there was a warning saying
/anaconda3/envs/mne/lib/python3.7/site-packages/picard/solver.py:216: UserWarning: Picard did not converge. Final gradient norm : 3.031e-05. Requested tolerance : 1e-07. Consider increasing the number of iterations or the tolerance.
% (gradient_norm, tol))
And there still no ecg component being found
# find which ICs match the ECG pattern
ecg_indices, ecg_scores = ica.find_bads_ecg(raw_notch_filt, reject_by_annotation=True,
method='ctps', threshold='auto')
ica.exclude = ecg_indices
The number of components sounds much more sensible to me now, so let’s stick with this value for n_components for now.
The warning you see already suggests a solution When creating your ICA object, set max_iter to a higher value, e.g. max_iter=1000. The warning should hopefully disappear then.
Returns: Reconstructing ECG signal from Magnetometers
and happily, it finally gave me an index 36! But……it’s not 8, which is a little bit odd. Below is what ICA036 looks like and the scores plot:
the raw plot of ICA036 looks less like heartbeats than ICA008:
This doesn’t look like ECG to me at all…
Have you tried not using the notch filter before ICA? Maybe this is causing some crazy things to happen? (It really shouldn’t, but who knows…?)
I tried to use the raw data only with annotations of muscle artifacts, not using notch filtering, the ecg component couldn’t be found again.
I’m considering that whether it’s the problem of the original heartbeats because when I draw the heartbeats evoked plots, it really seems not like heartbeat waves as shown in the tutorial:
I would suggest you try to extract the heartbeat events via find_ecg_events and adjust the qrs_threshold parameter and see what that gets you… you can then use those events to create ECG epochs manually, which you can average and visualize.
Hi Richard,
Thanks a lot for your patient help .
I tried the way you suggested, but no matter how I tried the different options for qrs_threshold, the ecg plots just didn’t get much better. I almost want to give up the way of automatically finding the ecg and eog, and turn to manually select the components to be reject.
Thank you again!
Since you don’t have a proper ECG channel in your data, find_ecg_events() synthesizes one. You can ask the function to return the synthesized signal by passing return_ecg=True (see the docs) I’d do just that and plot the synthesized ECG signal to get an idea whether it even makes sense?