[FieldTrip] ICA - problem with ft_rejectcomponent

Lei, A. (Anqi) anqi.lei at ru.nl
Tue Mar 29 08:06:58 CEST 2022


Sorry about not being specific in my message!

I got this error message when visualizing my original data after using ft_rejectcomponent, but not before ft_rejectcomponent:

"Error using ft_fetch_data (line 168)
some of the requested samples occur twice in the data and have conflicting values"

The version of the code that gives me problem:
%% ICA
%Decomposition of EEG data
    cfg            = [];
    cfg.resamplefs = 150;
    cfg.detrend    = 'no';
    data           = ft_resampledata(cfg, data_all);

    cfg        = [];
    cfg.method = 'runica'; % this is the default and uses the implementation from EEGLAB
    comp = ft_componentanalysis(cfg, data);

    %Identify components reflecting eye artifacts
    % plot the components for visual inspection
    figure
    cfg = [];
    cfg.component = 1:20;       % specify the component(s) that should be plotted
    cfg.layout    = 'acticap-64ch-standard2_XZ.mat'; % specify the layout file that should be used for plotting
    cfg.comment   = 'no';
    ft_topoplotIC(cfg, comp)

    %Removing bad artifacts and backprojecting data
    cfg = [];
    cfg.component = [1 2]; % e.g. to be removed component(s)
data_all = ft_rejectcomponent(cfg, comp, data_all);

    %Display data (this is where the error message occurs)
    cfg = [];
    cfg.layout = 'acticap-64ch-standard2_XZ.mat'; % specify the layout file that should be used for plotting
    cfg.viewmode = 'vertical';
    ft_databrowser(cfg, data_all);


The version that does not give me problem:
%% ICA
%Decomposition of EEG data
    cfg            = [];
    cfg.resamplefs = 150;
    cfg.detrend    = 'no';
    data           = ft_resampledata(cfg, data_all);

    cfg        = [];
    cfg.method = 'runica'; % this is the default and uses the implementation from EEGLAB
    comp = ft_componentanalysis(cfg, data);

    %Identify components reflecting eye artifacts
    % plot the components for visual inspection
    figure
    cfg = [];
    cfg.component = 1:20;       % specify the component(s) that should be plotted
    cfg.layout    = 'acticap-64ch-standard2_XZ.mat'; % specify the layout file that should be used for plotting
    cfg.comment   = 'no';
    ft_topoplotIC(cfg, comp)

    %Display data (this is where the error message occurs)
    cfg = [];
    cfg.layout = 'acticap-64ch-standard2_XZ.mat'; % specify the layout file that should be used for plotting
    cfg.viewmode = 'vertical';
    ft_databrowser(cfg, data_all);

I think the segmentation/trial length is alright, but something went wrong in the ft_rejectcomponent step specifically, but I'm not sure.

Thank you for your help!

Best,
Anqi

From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of "Schoffelen, J.M. (Jan Mathijs) via fieldtrip" <fieldtrip at science.ru.nl>
Reply-To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Date: Monday, March 28, 2022 at 6:06 PM
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Cc: "Schoffelen, J.M. (Jan Mathijs)" <janmathijs.schoffelen at donders.ru.nl>
Subject: Re: [FieldTrip] ICA - problem with ft_rejectcomponent

Hi Anqi,

in order for the readership of this list to be able to help you solve your problem, it might be useful if you provide us at least with the following information:

- the error message(s) you get.
- which version of the code is giving you problems.
- which version of the code does not give you problems.

Best wishes,
Jan-Mathijs



On 27 Mar 2022, at 23:38, Lei, A. (Anqi) via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hello,

I'm new to Fieldtrip and I encountered a problem in ICA – after rejecting bad components with ft_rejectcomponent I noticed my data can't be plotted by databrowser anymore, but before this step it can be visualized just fine. This is how I am perform ICA – is there something wrong in the ft_rejectcomponent part? Thank you for your help!


    %% ICA
    % perform the independent component analysis (i.e., decompose the data), downsampling first
    cfg            = [];
    cfg.resamplefs = 150;
    cfg.detrend    = 'no';
    data           = ft_resampledata(cfg, data_all);

    cfg        = [];
    cfg.method = 'runica'; % this is the default and uses the implementation from EEGLAB
    comp = ft_componentanalysis(cfg, data);

    %Identify components reflecting eye artifacts
    % plot the components for visual inspection
    figure
    cfg = [];
    cfg.component = 1:20;       % specify the component(s) that should be plotted
    cfg.layout    = 'acticap-64ch-standard2_XZ.mat'; % specify the layout file that should be used for plotting
    cfg.comment   = 'no';
    ft_topoplotIC(cfg, comp)

    %Further inspection of time course of component
    cfg = [];
    cfg.layout = 'acticap-64ch-standard2_XZ.mat'; % specify the layout file that should be used for plotting
    cfg.viewmode = 'component';
    ft_databrowser(cfg, comp)

    %Removing bad artifacts and backprojecting data
    cfg = [];
    cfg.component = 1; % to be removed component(s)
    data_all = ft_rejectcomponent(cfg, comp, data_all);

Best,
Anqi

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!9pPZAj-orxSMLThTWLYj_EoBsS-_sfR6omH4Ea-iYCjE-hYVG6WkOfFdstgOBILrmb4OxZ1HYfCgpHispeJkrWvRJA3pRgxyOntpbA$<https://urldefense.com/v3/__https:/doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!9pPZAj-orxSMLThTWLYj_EoBsS-_sfR6omH4Ea-iYCjE-hYVG6WkOfFdstgOBILrmb4OxZ1HYfCgpHispeJkrWvRJA3pRgxyOntpbA$>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220329/97b32156/attachment.htm>


More information about the fieldtrip mailing list