GithubHelp home page GithubHelp logo

sccn / iclabel Goto Github PK

View Code? Open in Web Editor NEW
52.0 7.0 19.0 33.79 MB

Automatic EEG IC classification plugin for EEGLAB

Home Page: https://iclabel.ucsd.edu/tutorial

MATLAB 100.00%
eeglab matconvnet ica classification matlab eeg

iclabel's Introduction

ICLabel

An automatic EEG independent component classifer plugin for EEGLAB. For more information, see the ICLabel website tutorial.

Installation

The easiest way to get the ICLabel plugin is through the EEGLAB plugin manager.

If you plan to install the plugin through GitHub rather than the EEGLAB plugin manager, be aware that matconvnet is included as submodule. This means that it will no be included in the zip-file download. You will have to download my fork (version) of matconvnet and extract that zip into the ICLabel folder. Alternatively, if you are cloning this repository through the command line, be sure to include the "--recusive" flag to clone submodules as well. Once you are in the desired directory, the correct command is:

git clone --recursive https://github.com/lucapton/ICLabel.git

Usage

Graphical Usage

menu Once you finish installing ICLabel, of if you already have it installed, you need to load your EEG dataset. To run ICLabel, your dataset must already have been decomposed using independent component analysis.

With your dataset loaded, start ICLabel using the EEGLAB window by clicking on "Tools"->"ICLabel". You will see progress notes displayed on MATLAB's command window as ICLabel's pipeline progresses. When ICLabel finishes, it will display "Done" on MATLAB's command window and the Viewprops plug-in will open if available. If you do not have "Viewprops" installed, then nothing else will appear on the screen.

Command-line Usage

Assuming you have stored your ICA-decomposed EEG dataset in the variable EEG, you can use ICLabel by entering the following into MATLAB's command window:

EEG = iclabel(EEG)

Finding Results

Either way you use ICLabel, from the EEGLAB window or MATLAB's command window, the IC classification information is saved to the EEG structure in the matrix:

EEG.etc.ic_classification.ICLabel.classifications

The labels are stored as a matrix in which each row is a label vector for the corresponding IC. A label vector is a row of seven numbers, summing to one, which represent the probabilities that an IC being in any of the seven ICLabel IC categories. For example, to find the label vector for the fifth IC, reference the fifth row of the matrix:

EEG.etc.ic_classification.ICLabel.classifications(5, :)

You can also find the class labels in the cell array of strings:

EEG.etc.ic_classification.ICLabel.classes

Each element of the cell array of strings indicates the category of the corresponding element in the label vectors. For example, to find the category of the third element in the label vector:

EEG.etc.ic_classification.ICLabel.classes{3}

You will find the category is "eye."

Viewprops plug-in

The ICLabel plugin offers no built-in plotting or visualization; therefore, it is highly suggested that you also install the Viewprops plug-in. It will produce figures like the one shown at the top of this article. See the Installation section for directions on how to acquire the Viewprops plug-in and see its wiki page for information on how to use it.

Run ICLabel in Fieldtrip

First install EEGLAB (it includes the ICLabel plugin by default). Then use the script below.

cfg = [];
cfg.datafile = '~/data/matlab/eeglab/sample_data/eeglab_data.set';
cfg.headerfile = '~/data/matlab/eeglab/sample_data/eeglab_data.set';
my_ft_data = ft_preprocessing(cfg);

eeglab; close; % add paths to EEGLAB
EEG = fieldtrip2eeglab(my_ft_data, my_ft_data.trial);
EEG = eeg_checkset(EEG);
EEG = pop_runica(EEG, 'icatype', 'runica');
EEG = pop_icflag(EEG, [0 0;0 0; 0.001 1; 0 0; 0 0; 0 0; 0 0]); % see function help message
rejected_comps = find(EEG.reject.gcompreject > 0);
EEG = pop_subcomp(EEG, rejected_comps);
EEG = eeg_checkset(EEG);

curPath = pwd;
p = fileparts(which('ft_read_header'));
cd(fullfile(p, 'private'));
hdr = read_eeglabheader( EEG );
data = read_eeglabdata( EEG, 'header', hdr );
event = read_eeglabevent( EEG, 'header', hdr );
cd(curPath);

Version history

Pending - new message if signal processing toolbox is absent (we judged a new release was not necessary for such a small change)

1.6 - fix issue with electrode orientation introduced in version 1.5 one month prior

1.5 - minor tweaks and better stability (see commit history)

1.4 - adding 'average' to the list of possible reference for EEGLAB compatibility

1.3 - make sure the classification probabilities are identical when processing multiple datasets with the same ICA decompositions

1.2.6 - fix issue in pop_iclabel.m for Matlab prior to 2016, fix rare path issue and issue with autocorrelation length

1.2.5 - fix issue when pressing cancel in pop_iclabel.m

1.2.4 - Forgot to include some dependencies in 1.2.3, adding them back and fix issue to view properties

1.2.3 - Fix bug for single dataset

1.2.2 - Fix STUDY calling format and add new function eeg_icalabelstat

iclabel's People

Contributors

arnodelorme avatar behinger avatar dungscout96 avatar lucapton avatar rgougelet avatar tstenner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

iclabel's Issues

Some errors always occur when running iclabel

My computer OS is Win10, and matlab version 2019b. Recently, errors are always reported when using IClabel plug-in. The error is EEGLAB error in function run_ICL() at line 30: Unable to parse the name: dagnn_be.DagNN.loadobj. I want to know how to solve this problem. Thank you!
微信图片_20211009190627

Possible mis-classification?

Im not very sure but it just cannot make sense to me why this component is tagged as Brain signal dispite Eye with even 69% confidence......
无标题

Original weights for usage with tensorflow?

Hi, this looks pretty cool. Since I typically avoid using MATLAB, I was wondering if iI could use the trained classifier with TensorFlow directly. Since original training was done using Python, I assume the data might already (still?) exists in a TensorFlow-readable format. If this is the case, any way you could share it?

Component Time Serie didn't show the signal

Hello,
After performing the first phase of removing noise, artifacts and bad channels from my EEG recording, I proceeded to perform ICA and then use the latest version of ICLabel (v1.3).
Everything appears to me properly, except for the signal inside the Component Time Series graph, which appears blank and without signal. However, the dataset is recognized as it shows me the labels along the time axis, and I can move along this axis normally.
I tried with other records and the same thing happens to me.
Please, I would appreciate any help to be able to solve and have ICLabel in its best form.

Kinds regards,
Cristian Cortés

Methods from original paper (replicability study)

Hi - Hoping someone could answer some questions about the ICLabel data processing / feature extraction methods that were used to construct the data set. I couldn't find the details in the original paper: https://doi.org/10.1016/j.neuroimage.2019.05.026.

  • Are the original EEGs average referenced?
  • How are the original EEGs pre-processed prior to applying ICA? PCA/standardized?
  • Which ICA algorithm was applied to generate the ICs?
  • From the code it looks like the EEG data was average referenced prior to applying ICA?
  • It seems like the original EEG recordings as well as the ICs are of varying lengths / sampling frequencies?

Also, in this paper (https://sccn.ucsd.edu/~scott/pdf/ICLabel19.pdf), the ICLabel dataset is supposedly available. It notes that "Prior to computing features, each dataset was converted to a common average reference." Assuming here that this means the raw EEG?

Will likely have more questions about the PSD/Autocorr feature extraction when I get there. Thanks for any thoughts!

ICLabel fails badly with data with EEG.srate < 200

It appears that ICLabel creates PSD features with max frequency 100 Hz, and thus needs data with sampling rate >= 200 Hz.

However, ICLabel is written to assume that the only way it could fail is if the model mex has not been compiled properly, and in this case recompiles the mex file, which is the wrong solution. Then it tries again and fails again, incorrectly warning that complication was unsuccessful, while it was in fact successful.

In this case the model input is the problem, not the model. This is very confusing for the user.

Solution: add a check for EEG.state < 200, and error out informatively if so.

Change ms to sec in Scrolling Component Activity

I'm analysing many EEG dataset with 3000-4000 sec per dataset, so I'll prefer to watch de scrolling activity in second (not in milisecond, as is default configuration). I tried edit %number of pint to draw in scrollplot.m line 61... but it didn't works (I'm really new programing). May someone explain to me how to do it? please.

I'm using Matlab R2020b and EEGLAB 2021.

Best wishes,

RodrigoGM

Is there a way to access the raw ICLabel - ICA time series?

Hi ICLabel maintainers,

I found your tool very valuable over my research years to help automate large number of subjects in cleaning their scalp EEG. However, I'm also a heavy user of Python and was interested in getting essentially a copy of the tool working in Python (with credit obviously given to ICLabel).

I think what would be really cool is to also have the tool eventually available in MNE-Python, with MNE also contributing some labeled ICA component data. This can then be a cross-platform effort to scale up automation of scalp EEG preprocessing.

Is there a way to access the raw ICA time series and their downstream labels?

We want to check that we can reproduce the feature set in ICLabel using Python code.

matconvnet DagNN incompatible with MATLAB versions prior to R2012a

Incompatabilites found so far are:

  1. Object property "access" can only be "public", "protected", or "private" but some DagNN methods pass meta-classes which is only supported starting with R2012a.

    • This might be fixed by changing the meta-class accesses to public.
  2. DagNN inherits from matlab.mixin.Copyable which was added in R2011a.

    • This might be fixed by including code to replace the Copyable class. Ideas here.

For now ICLabel is constrained to support only MATLAB R2012a and newer.

error in pop_iclabel when data is average referenced

I have performed an average reference in my data, therefore the field EEG.ref = 'average'. However after runing pop_ica and trying to run pop_iclabel I get an error in ICL_feature_extractor in line 15 because it compares the EEG.ref field to 'avgeref' instead of 'average'.

if ~strcmp(EEG.ref, 'averef')

Could you update this field?
Best,
Cristina Gil

eeg_rpsd() line 38

When trying to run "tools --> classify components using ICLabel --> label components", after pop up menu and selecting default (or lite or beta), I get the following error message

image

Threshold for deleting eye-components

We have been using your amazing tool for a while now in our lab and whenever we are talking about it in a lab meeting, some people argue that if they would manually only delete eye components, they would sometimes delete different ones as well. It's pretty clear to me that this has to do with the threshold we use to delete components once they are flagged. In my case when I am deleting eye components only I am using the following 2 lines to decide what is bad and what is not:

ICA_components = EEG.etc.ic_classification.ICLabel.classifications ;
bad_components = find(ICA_components(:,3)>0.80 & ICA_components(:,1)<0.05);

This made me wonder, is there some sort of threshold you would suggest? I can't seem to find this in the paper or in the readme of this Repo

Thank you so much for your time

Is there a way to download the original dataset?

Hi,

First of all, congratulations on this project! :)

I was wondering if the ICs + labels were also available to download. I have a few ideas for new features and would like to test them, but I would need the original ICs and their corresponding labels. I imagine it might be a huge dataset! Is there any way to access the original dataset?

Thanks!

A proposal of a solution to eeg_rpsd index error

Dear all,
I have eeg files in edf format with different sampling frequencies.
For the EEG.srate = 200 ones, the Automagic runs without a hitch.
However, for the EEG.srate = 1000 ones, although runICA goes smoothly, but the ICLabel give the following error:
(eeg_rpsd.m, line 35, index in position 2 is invalid)
Screen Shot 2023-02-24 at 1 51 32 PM

I found that in the eeg_rpsd.m file, when EEG.srate is 1kHz, the n_points variable becomes 1E3, which is treated as a float rather than an integer, causing the subsequent indexing to fail.
A solution is proposed: add line 17 as shown in the next picture (n_points = round(n_points)
Screen Shot 2023-02-24 at 2 26 11 PM
After that, IClabel runs as intended, but I am curious if this solution breaks anything.

Sincerely yours,
Edward Cheng.

Check if data is referenced to CAR

After some digging following: sccn/eeglab#462
This line checks if the dataset is referenced to a common average. But, the sample EEGLAB dataset field .ref is set to common, which is probably a CAR? And yet this is not captured by ~strcmp(EEG.ref, 'averef').

Same for a dataset outputted after a re-referencing with pop_reref (including the output of ([~, EEG] = evalc('pop_reref(EEG, [], ''exclude'', setdiff(1:EEG.nbchan, EEG.icachansind));');), the field .ref is set to 'average', which is again not captured by ~strcmp(EEG.ref, 'averef').

Is this a mistake and 3 different ways to denote a CAR ref?

[Question] Is the labeled data for this project public?

Hi, I tried to contact you through the ICLabel tutorial site, somehow an error has always appeared, right after I clicked the "send" button.
I would like to know, if the labeled data for this project is public, so that everyone can have access to it e.g. to improve the automation? Thanks!

SASICA_1.3.7 Error

Hello,

I am new to eeglab and trying to pre-process my data set. When I tried to run SASICA, the newest version available, it gave me the following error. I greatly appreciate it if anyone can give me some advice to solve this issue. Or even alternative plugins that do similar function as SASICA.

Thank you,
Yangmi

ERROR. Please send the entire error log below to [email protected]. Thanks for your help!

This is SASICA_1.3.7
This is MATLAB 9.9.0.1467703 (R2020b)
Running on MACI64
MARA:
enable: 0
FASTER:
enable: 0
blinkchanname: No channel
ADJUST:
enable: 0
chancorr:
enable: 0
channames: No channel
corthresh: auto 4
EOGcorr:
enable: 0
Heogchannames: No channel
corthreshH: auto 4
Veogchannames: No channel
corthreshV: auto 4
resvar:
enable: 0
thresh: 15
SNR:
enable: 0
snrcut: 1
snrBL: -Inf 0
snrPOI: 0 Inf
trialfoc:
enable: 0
focaltrialout: auto
focalcomp:
enable: 0
focalICAout: auto
autocorr:
enable: 0
autocorrint: 20
dropautocorr: auto
opts:
noplot: 0
nocompute: 0
FontSize: 14
Index exceeds the number of array elements (1).

Error in pop_selectcomps (line 168)
set( button, 'backgroundcolor', eval(fastif(EEG.reject.gcompreject(ri), COLREJ,COLACC)), 'string', int2str(ri));

Error in eeg_SASICA (line 93)
eval(cfg);

Error in eeg_SASICA (line 742)
eeg_SASICA(EEG,['pop_selectcomps(EEG, [' num2str(cmps) '],' num2str(ncomp) ');']);

Error in SASICA>push_ok_Callback (line 601)
[EEG, cfg] = eeg_SASICA(EEG,cfg);

Error in gui_mainfcn (line 95)
feval(varargin{:});

Error in SASICA (line 110)
gui_mainfcn(gui_State, varargin{:});

Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)SASICA('push_ok_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

rng(0)

Matlab is stopping the process with following error:

        Error using rng (line 96)
        The current random number generator is the legacy generator.  This is because you have executed a command such as rand('state',0), which activates MATLAB's legacy random number behavior.  You may not use RNG to reseed the legacy random number generator.

         Use rng('default') to reinitialize the random number generator to its startup configuration, or call RNG using a specific generator type, such as rng(seed,'twister').

         Error in eeg_rpsd (line 20)
         rng(0)

It did not happen when I first ran ICLabel. But then I ran ICA (pop_runica) on a new dataset, tried to run ICLabel on it, and the error was shown. The same process was reproduced twice.

(Using Matlab R2016b)

Error in topoplotFast - Matrix dimensions must agree

Dear Sir/MAdam

I am facing an error while using IClabel
My code is straightforward

EEG=pop_biosig('edf.file');
EEG=pop_runica(EEG,'chanind',[1:22]);
EEG=icalabel(EEG);

And i receive the following error (probably due to the fact that i do not do ICA in all of the channels?) :

Error using /
Matrix dimensions must agree.

Error in topoplotFast (line 894)
squeezefac = rmax/plotrad;

Error in ICL_feature_extractor (line 33)
topoplotFast(EEG.icawinv(:, it), EEG.chanlocs(EEG.icachansind), ...

Error in iclabel (line 52)
features = ICL_feature_extractor(EEG, flag_autocorr);

Python Implementation

I'm planning to do a python implementation of IClabel , mainly for use in MNE-python. I couldn't see any file referencing the license information. I was wondering if there was a problem with me doing the translation and releasing it; obviously mentioning that it is a mere translation of this project.

Thanks you for your time.

ICLABEL fails: Input signal X must be a double-precision vector

Copied from sccn/eeglab#200

ICLABEL aborts with the message “The input signal X must be a double-precision vector., (Error occurred in function validateinput() at line 101)”. ICLABEL 1.2.6 installed. The EEGLAB preference for single precision is NOT checked. Using a 64-bit PC. SASICA runs without difficulty. Problem seems to be unique to my installation/configuration: When I take the same dataset to a friend’s lab, ICLABEL runs without problems.

EEGLAB extension manager

Anytime I run the extension manager for downloading a plugin I receive "Could not download extension. The host site might be unavailable, too slow, or you do not have permission to write in the EEGLAB plugin Anyone with some advice?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.