[FieldTrip] using ICA to remove ECG artifacts - but all components seems to be correlated with the ecg signal

Steinmann, Iris iris.steinmann at med.uni-goettingen.de
Tue Sep 15 10:47:53 CEST 2015


Hi at all,
I'm using fieldtrip to analyze my EEG data recorded with a Brainamp
MRplus system and an easycap with 31 eeg-channels plus one separate ecg electrode.

To get rid of the ecg based artifacts in my EEG data I followed the
fieldtrip tutorial 'Use independent component analysis (ICA) to remove
ECG artifacts'. (I followed step by step and posted the code down below)
The problem is, that I dont't get a clear separation of one or two
components which reflect the ecg artifact (like in the example of the tutorial).
All my components show a timelocked correlation with the separated ecg signal... (attached some .jpgs)
So, I wondering if I have done something wrong ...

Would be great if someone could help me to find a solution for this.
Thanks!

Iris



% ======================= code starts here ===============================%
% calculate ICA component for the trialed, downsampled and basic corrected (jumps, muscles) eeg data
% (called basiccorr_data.mat)
cfg4ica = [];
cfg4ica.inputfile = 'C:\mydirectory\basiccorr_data.mat';
cfg4ica.method = 'runica';
cfg4ica.channel = 'eeg';
cfg4ica.trials = 'all';
cfg4ica.numcomponent = 15;
cfg4ica.demean = 'yes';
cfg4ica.updatesens = 'yes';
comp_basiccorr_data = ft_componentanalysis(cfg4ica);
% plot the components (maybe a little overdressed ...)
cfg4plot = [];
cfg4plot.component = 1 : 15;
cfg4plot.layout = 'myEasyCap32MR.lay';
cfg4plot.viewmode = 'component';
cfg4plot.zlim = [];
cfg4plot.marker = 'on';
cfg4plot.markersymbol = 'o';
cfg4plot.markercolor = [0 0 0];
cfg4plot.markersize = 2;
cfg4plot.markerfontsize = 8;
cfg4plot.highlight = [];
cfg4plot.highlightchannel = [];
cfg4plot.highlightsymbol = 'o';
cfg4plot.highlightcolor = [0 0 0];
cfg4plot.highlightsize = 6;
cfg4plot.highlightfontsize = 8;
cfg4plot.colorbar = 'no';
cfg4plot.interplimits = 'head';
cfg4plot.interpolation = 'v4';
cfg4plot.style = 'both';
cfg4plot.gridscale = 67;
cfg4plot.shading = 'flat';
cfg4plot.comment = 'no';
cfg4plot.commentpos = 'leftbottom';
cfg4plot.title = 'auto';
figure
ft_topoplotIC(cfg4plot, comp_basiccorr_data);

% ---------------------------------------------------------------- %
% find the artifacts in the continuous raw data
cfg4find_ecg = [];
cfg4find_ecg.dataset = 'C:\mydirectory\EEGdata_2000023.eeg';
a = load('C:\mydirectory\t_data'); % load the trialed data to get the .trl information
cfg4find_ecg.trl = a.data.cfg.trl;
cfg4find_ecg.continuous = 'yes';
cfg4find_ecg.artfctdef.ecg.pretim = 0.25;
cfg4find_ecg.artfctdef.ecg.psttim = 0.50-1/512;
cfg4find_ecg.channel = {'ECG'};
cfg4find_ecg.artfctdef.ecg.inspect = {'ECG'};
cfg4find_ecg.artfctdef.ecg.cutoff = 0.2;
[cfg_artifact, ecg_artifact] = ft_artifact_ecg(cfg4find_ecg);
% cut the original data around the ecg-artifact
cfg4cut_ecg = [];
cfg4cut_ecg.dataset = 'C:\mydirectory\EEGdata_2000023.eeg';
cfg4cut_ecg.continuous = 'yes';
cfg4cut_ecg.padding = 0.5;
cfg4cut_ecg.dftfilter = 'yes';
cfg4cut_ecg.demean = 'yes';
cfg4cut_ecg.trl = [ecg_artifact zeros(size(ecg_artifact,1),1)];
cfg4cut_ecg.channel = {'eeg'};
data_ecg = ft_preprocessing(cfg4cut_ecg);
cfg4cut_ecg.channel = {'ecg'};
ecg = ft_preprocessing(cfg4cut_ecg);

% resample to speed up
cfg4resample = [];
cfg4resample.resamplefs = 512;
cfg4resample.detrend = 'no';
data_ecg = ft_resampledata(cfg4resample, data_ecg);
ecg = ft_resampledata(cfg4resample, ecg);
% decompose the ECG-locked data segments into components, using the previously found (un)mixing matrix
cfg4ica_ecg = [];
cfg4ica_ecg.unmixing = comp_basiccorr_data.unmixing;
cfg4ica_ecg.topolabel = comp_basiccorr_data.topolabel;

comp_ecg = ft_componentanalysis(cfg4ica_ecg, data_ecg);
% plot the components
figure
ft_topoplotIC(cfg4plot, comp_ecg);

% ---------------------------------------------------------------- %
% append the ecg channel to the data structure;
comp_ecg = ft_appenddata([], ecg, comp_ecg);
% average the components timelocked to the QRS-complex
cfg           = [];
timelock      = ft_timelockanalysis(cfg, comp_ecg);
figure
subplot(2,1,1); plot(timelock.time, timelock.avg(1,:))
subplot(2,1,2); plot(timelock.time, timelock.avg(2:end,:))
title('ecg');
figure
subplot(2,1,1); plot(timelock.time, timelock.avg(1,:))
subplot(2,1,2); imagesc(timelock.avg(2:end,:));
title('ecg');
% ======================= code ends here =================================%


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150915/990d57ee/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecg-and-components.jpg
Type: image/jpeg
Size: 34190 bytes
Desc: ecg-and-components.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150915/990d57ee/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecg-and-spectral-components.jpg
Type: image/jpeg
Size: 34921 bytes
Desc: ecg-and-spectral-components.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150915/990d57ee/attachment-0005.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ica-components-basiccorr_data.jpg
Type: image/jpeg
Size: 54720 bytes
Desc: ica-components-basiccorr_data.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150915/990d57ee/attachment-0006.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ica-components-ecg.jpg
Type: image/jpeg
Size: 54720 bytes
Desc: ica-components-ecg.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150915/990d57ee/attachment-0007.jpg>


More information about the fieldtrip mailing list