Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix probabilities returned by label_components #36

Merged
merged 4 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ Enhancements
Bug
~~~

-
- Fix shape of ``'y_pred_proba'`` output from `mne_icalabel.label_components`

API
~~~

-
-

Authors
~~~~~~~

*
* `Mathieu Scheltienne`_

:doc:`Find out what was new in previous releases <whats_new_previous_releases>`

Expand Down
2 changes: 1 addition & 1 deletion mne_icalabel/label_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def label_components(inst: Union[BaseRaw, BaseEpochs], ica: ICA, method: str):
labels_pred_proba = methods[method](inst, ica)
labels_pred = np.argmax(labels_pred_proba, axis=1)
labels = [ICLABEL_NUMERICAL_TO_STRING[label] for label in labels_pred]
y_pred_proba = labels_pred_proba[:, labels_pred]
y_pred_proba = labels_pred_proba[np.arange(15), labels_pred]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean predictions are always predicting 15 components? Even if ICA produces e.G. 30 components?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my god.. yes..
I was doing too many things at once, I'll fix it when I get home in 20 minutes.


component_dict = {
"y_pred_proba": y_pred_proba,
Expand Down
4 changes: 3 additions & 1 deletion mne_icalabel/tests/test_label_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
def test_label_components():
"""Simple test to check that label_components runs without raising."""
labels = label_components(raw, ica, method="iclabel")
assert labels is not None
assert isinstance(labels, dict)
assert labels["y_pred_proba"].ndim == 1
assert labels["y_pred_proba"].shape[0] == ica.n_components_


def test_label_components_with_wrong_arguments():
Expand Down