sccn / ICLabel

Automatic EEG IC classification plugin for EEGLAB
https://iclabel.ucsd.edu/tutorial
53 stars 19 forks source link

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

Closed adam2392 closed 3 years ago

adam2392 commented 3 years ago

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.

yjmantilla commented 3 years ago

Hi, @adam2392 , Im not the maintainer (so take everything I say with a ~grain~ lot of salt) but to my knowledge the ICA time series is saved in EEG.icaact as indicated by these lines:

https://github.com/sccn/ICLabel/blob/a3fcc68ff15ef33e1b6c29cab0cc8a928030ae77/ICL_feature_extractor.m#L19-L26

Do notice that before that an averaging is done that actually affects the weights :

https://github.com/sccn/ICLabel/blob/a3fcc68ff15ef33e1b6c29cab0cc8a928030ae77/ICL_feature_extractor.m#L15-L17

The weights are affected by the called pop_reref function (notice the final assignment in the hyperlinked code).

To my knowledge the features are not saved for outside inspection, they are just assigned a variable:

https://github.com/sccn/ICLabel/blob/a3fcc68ff15ef33e1b6c29cab0cc8a928030ae77/iclabel.m#L50-L52

I dont think there would be any problem with doing this assignment in a modified version of iclabel.m just after getting the features:

EEG.etc.ic_classification.ICLabel.features = features

Not directly related, but @adam2392 maybe the stuff I did for #14 is useful to you. Im advancing really slowly because I almost have no time for side projects and Im by myself. The implementation you guys are doing will be better most probably.

adam2392 commented 3 years ago

Hi, @adam2392 , Im not the maintainer (so take everything I say with a grain of salt) but to my knowledge the ICA time series is saved in EEG.icaact as indicated by these lines:

Thanks for pointing this out! This will be helpful.

I was actually though hoping for the raw ICA time series, if not the raw scalp EEG themselves. Since one is "forced" to use the features stored in ICLabel to do train/test/validation, one would need to faithfully reproduce these features in Python. But in order to do so, it would help to start with either the raw scalp EEG, or raw ICA time traces. In addition, this would facilitate possibly open-source improvements to the pipeline as it is possible that the feature representation chosen could be improved.

Does sccn release these?

Not directly related, but @adam2392 maybe the stuff I did for #14 is useful to you. Im advancing really slowly because I almost have no time for side projects and Im by myself. The implementation you guys are doing will be better most probably.

Sounds good! Thanks!

yjmantilla commented 3 years ago

I was actually though hoping for the raw ICA time series, if not the raw scalp EEG themselves. Since one is "forced" to use the features stored in ICLabel to do train/test/validation, one would need to faithfully reproduce these features in Python. But in order to do so, it would help to start with either the raw scalp EEG, or raw ICA time traces.

Oh I see, you mean the actual data. I dont really know about that. Right now Im just loading the same EEG in matlab and python and trying to match every step as much as I can. The topoplot function was kind of tricky. And well, I have found that is really easy to lose the exact numerical match between both (in an occasion I was doing a icaact = demixing @ eeg operation with the same data in matlab and python and surprisingly they differed, probably because slight changes in the last decimals which propagate in the multiplication).

lucapton commented 3 years ago

The original time series are not available. All that is provided is included in this repository as is. I realize having the original time series would make this dataset much more versatile, but unfortunately that's not possible.

Regarding the python implementation, see #14.