I would like to discuss a bit what the API would look like, both on the mne_icalabel side and on the mne side. Here is my point of view:
mne_icalabel
As described in the readme, this package is not only a port of the popular ICLabel network for EEG but could host other models for EEG, MEG, and iEEG. Thus, I would structure the package as:
mne_icalabel
└─ iclabel
└─ assets
└─ tests
└─ network.py
└─ features.py
└─ model2
└─ model3
└─ ...
└─ icalabel.py
The main entry point from a user perspective would be in mne_icalabel/icalabel.py through a function that takes as input a raw or epochs instance, an ICA decomposition, and a method (str). The method argument would have a couple of accepted values: the name of the models, e.g. 'iclabel'; and would be responsible for selecting the model used.
Based on the model used, the number of class in which the components are classified may vary. But in any case, the output should be the label (which class) and the probability that each component is in each class (scores).
Additionally to this main entry point, I would keep public a function to retrieve the features of a model, and a function to run a set of features through the model. e.g. for ICLabel, it would be mne_icalabel/iclabel/features.py:get_features and mne_icalabel/iclabel/network.py:run_iclabel. Everything else would become private.
mne
In version 1.1, there are already 4 methods to find bad components in mne.preprocessing.ICA: find_bads_ecg, find_bads_eog, find_bads_muscle and find_bads_ref. Following this pattern, I would go for a find_bads method that would wrap around the entry point in mne_icalabel/icalabel.py, with the 2 parameters inst and method. As for the 4 other methods, the label can be stored in ica.labels_.
I think it would be worth also storing the probability that each component is in each class (scores) in a similar attribute to ica.labels_, for both this new find_bads method and for all others as well.
I brought the idea here a while ago: mne-tools/mne-python#9846 but I didn't follow up on it yet. It does require a new ICA FIFF field for a 2D matrix of floats.
Finally, from an MNE perspective, the API could be simplified a bit further. At term, the find_bads method could be the only one remaining with the 4 others moved to mne_icalabel as models and called through find_bads with the correct method keyword specified.
I would like to discuss a bit what the API would look like, both on the
mne_icalabelside and on themneside. Here is my point of view:mne_icalabelAs described in the readme, this package is not only a port of the popular
ICLabelnetwork for EEG but could host other models for EEG, MEG, and iEEG. Thus, I would structure the package as:The main entry point from a user perspective would be in
mne_icalabel/icalabel.pythrough a function that takes as input araworepochsinstance, an ICA decomposition, and a method (str). Themethodargument would have a couple of accepted values: the name of the models, e.g.'iclabel'; and would be responsible for selecting the model used.Based on the model used, the number of class in which the components are classified may vary. But in any case, the output should be the label (which class) and the probability that each component is in each class (scores).
Additionally to this main entry point, I would keep public a function to retrieve the features of a model, and a function to run a set of features through the model. e.g. for ICLabel, it would be
mne_icalabel/iclabel/features.py:get_featuresandmne_icalabel/iclabel/network.py:run_iclabel. Everything else would become private.mneIn version 1.1, there are already 4 methods to find bad components in
mne.preprocessing.ICA:find_bads_ecg,find_bads_eog,find_bads_muscleandfind_bads_ref. Following this pattern, I would go for afind_badsmethod that would wrap around the entry point inmne_icalabel/icalabel.py, with the 2 parametersinstandmethod. As for the 4 other methods, the label can be stored inica.labels_.I think it would be worth also storing the probability that each component is in each class (scores) in a similar attribute to
ica.labels_, for both this newfind_badsmethod and for all others as well.I brought the idea here a while ago: mne-tools/mne-python#9846 but I didn't follow up on it yet. It does require a new ICA FIFF field for a 2D matrix of floats.
Finally, from an MNE perspective, the API could be simplified a bit further. At term, the
find_badsmethod could be the only one remaining with the 4 others moved tomne_icalabelas models and called throughfind_badswith the correct method keyword specified.