-
Notifications
You must be signed in to change notification settings - Fork 78
Add the code from PR "Add support for MNE-ICALabel #812" #1018
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
base: main
Are you sure you want to change the base?
Changes from 16 commits
2922224
3338807
4bf3976
8eaf750
8ca9132
5b4d14e
fd304e1
ede148b
7d2a729
f1f196f
4a9f10a
53d743f
0070306
3e55605
c6bc2a3
c2a4b6c
ae5bb9d
ea77558
ec5dd1f
1d8e956
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| DigMontageType, | ||
| FloatArrayLike, | ||
| PathLike, | ||
| UniqueSequence, | ||
| ) | ||
|
|
||
| # %% | ||
|
|
@@ -1430,6 +1431,11 @@ | |
| us so we can discuss. | ||
| """ | ||
|
|
||
| ica_h_freq: float | None = None | ||
| """ | ||
| The cutoff frequency of the low-pass filter to apply before running ICA. | ||
| """ | ||
|
|
||
| ica_max_iterations: int = 500 | ||
| """ | ||
| Maximum number of iterations to decompose the data into independent | ||
|
|
@@ -1476,19 +1482,70 @@ | |
| `1` or `None` to not perform any decimation. | ||
| """ | ||
|
|
||
| ica_use_ecg_detection: bool = True | ||
| """ | ||
| Whether to use the MNE ECG detection on the ICA components. | ||
| """ | ||
|
|
||
| ica_ecg_threshold: float = 0.1 | ||
| """ | ||
| The cross-trial phase statistics (CTPS) threshold parameter used for detecting | ||
| ECG-related ICs. | ||
| """ | ||
|
|
||
| ica_use_eog_detection: bool = True | ||
| """ | ||
| Whether to use the MNE EOG detection on the ICA components. | ||
| """ | ||
|
|
||
| ica_eog_threshold: float = 3.0 | ||
| """ | ||
| The threshold to use during automated EOG classification. Lower values mean | ||
| that more ICs will be identified as EOG-related. If too low, the | ||
| false-alarm rate increases dramatically. | ||
| """ | ||
|
|
||
| ica_use_icalabel: bool = False | ||
| """ | ||
| Whether to use MNE-ICALabel to automatically label ICA components. Only available for | ||
| EEG data. | ||
|
|
||
| !!! info | ||
| Using MNE-ICALabel mandates that you also set: | ||
| ```python | ||
| eeg_reference = "average" | ||
| ica_l_freq = 1 | ||
| ica_h_freq = 100 | ||
| ``` | ||
|
|
||
| !!! info | ||
| Using this requires `mne-icalabel` package, which in turn will require you to | ||
| install a suitable runtime (`onnxruntime` or `pytorch`). | ||
| """ | ||
|
|
||
| ica_icalabel_include: Annotated[ | ||
| UniqueSequence[ | ||
| Literal[ | ||
| "brain", | ||
| "muscle artifact", | ||
| "eye blink", | ||
| "heart beat", | ||
| "line noise", | ||
| "channel noise", | ||
| "other", | ||
| ] | ||
| ], | ||
| Len(1, 7), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are really going for broke on this one, we should use the pydantic/pydantic-core#820 (comment) If you don't want to implement it here maybe add it as a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think I can really follow you there. Maybe something got lost, but what does "going for broke" mean? @jschepers I dont actually see where we really select components to be excluded, but in their tutorial it is also quite confusing. I remember we looked at it, but it was some time ago. E.g. in eeglab you specify "remove muscle if probability >80%" and similar. How is this done here, do you remember? Else I will try to give this another spin in debug mode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry it's just an idiom -- in this case I mean if you want to put forth potentially a lot of effort to try to come up with a more complete/cool solution, you could. What we want here in not just a list with length between 1 and 7 with elements from a set of possible choices, but rather that they are unique elements (i.e., a user shouldn't put in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay I finally came back to this! Things seem to be working at my end. FYI some of the components have a kind of low probability... looked like in testing at one point one of the things labeled as |
||
| ] = ("brain", "other") | ||
| """ | ||
| Which independent components (ICs) to keep based on the labels given by ICLabel. | ||
| Possible labels are: | ||
|
|
||
| ``` | ||
| ["brain", "muscle artifact", "eye blink", "heart beat", "line noise", "channel noise", "other"] | ||
| ``` | ||
| """ # noqa: E501 | ||
|
|
||
| # ### Amplitude-based artifact rejection | ||
| # | ||
| # ???+ info "Good Practice / Advice" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accidentally forgot this in one run and got a reasonable message:
so I think the error message propagated to the end user is working!