Skip to content

Commit

Permalink
deploy stub files [ci skip] (#175)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and github-actions[bot] authored Mar 20, 2024
1 parent aad5415 commit 12d598c
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 44 deletions.
5 changes: 2 additions & 3 deletions mne_icalabel/annotation/bids.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from pathlib import Path as Path
from typing import Union

from mne.preprocessing import ICA

from ..config import ICA_LABELS_TO_MNE as ICA_LABELS_TO_MNE
from ..iclabel._config import ICLABEL_STRING_TO_NUMERICAL as ICLABEL_STRING_TO_NUMERICAL
from ..utils._imports import import_optional_dependency as import_optional_dependency

def write_components_tsv(ica: ICA, fname: Union[str, Path]):
def write_components_tsv(ica: ICA, fname: str | Path):
"""Write channels tsv file for ICA components.
Will create an accompanying JSON sidecar to explain the
Expand Down Expand Up @@ -35,7 +34,7 @@ def write_components_tsv(ica: ICA, fname: Union[str, Path]):

def mark_component(
component: int,
fname: Union[str, Path],
fname: str | Path,
method: str,
label: str,
author: str,
Expand Down
4 changes: 2 additions & 2 deletions mne_icalabel/config.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Callable, Optional
from typing import Callable

from .iclabel import iclabel_label_components as iclabel_label_components

ICALABEL_METHODS: dict[str, Optional[Callable]]
ICALABEL_METHODS: dict[str, Callable | None]
ICA_LABELS_TO_MNE: dict[str, str]
3 changes: 1 addition & 2 deletions mne_icalabel/datasets/icalabel/icalabel.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from pathlib import Path
from typing import Optional

from _typeshed import Incomplete

has_icalabel_testing_data: Incomplete

def data_path(
path: Optional[str] = None,
path: str | None = None,
force_update: bool = False,
update_path: bool = True,
download: bool = True,
Expand Down
6 changes: 2 additions & 4 deletions mne_icalabel/features/topomap.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Union

from _typeshed import Incomplete
from mne import Info
from mne.preprocessing import ICA
Expand All @@ -13,7 +11,7 @@ def get_topomaps(
picks: Incomplete | None = None,
res: int = 64,
image_interp: str = ...,
border: Union[float, str] = ...,
border: float | str = ...,
extrapolate: str = ...,
) -> dict[str, NDArray[float]]:
"""Generate an array of scalp topographies for the picked components.
Expand Down Expand Up @@ -64,7 +62,7 @@ def _get_topomap_array(
info: Info,
res: int = 64,
image_interp: str = ...,
border: Union[float, str] = ...,
border: float | str = ...,
extrapolate: str = ...,
) -> NDArray[float]:
"""Generate a scalp topographic map (n_pixels, n_pixels).
Expand Down
8 changes: 3 additions & 5 deletions mne_icalabel/gui/_label_components.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Union

from _typeshed import Incomplete
from mne import BaseEpochs
from mne.io import BaseRaw
Expand All @@ -25,7 +23,7 @@ class ICAComponentLabeler(QMainWindow):
_selected_component: int

def __init__(
self, inst: Union[BaseRaw, BaseEpochs], ica: ICA, show: bool = True
self, inst: BaseRaw | BaseEpochs, ica: ICA, show: bool = True
) -> None: ...
def _save_labels(self) -> None:
"""Save the selected labels to the ICA instance."""
Expand Down Expand Up @@ -56,11 +54,11 @@ class ICAComponentLabeler(QMainWindow):
"""

@staticmethod
def _check_inst_ica(inst: Union[BaseRaw, BaseEpochs], ica: ICA) -> None:
def _check_inst_ica(inst: BaseRaw | BaseEpochs, ica: ICA) -> None:
"""Check if the ICA was fitted."""

@property
def inst(self) -> Union[BaseRaw, BaseEpochs]:
def inst(self) -> BaseRaw | BaseEpochs:
"""Instance on which the ICA has been fitted."""

@property
Expand Down
18 changes: 7 additions & 11 deletions mne_icalabel/iclabel/features.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Union

from mne import BaseEpochs
from mne.io import BaseRaw
from mne.preprocessing import ICA
Expand All @@ -11,7 +9,7 @@ from ._utils import _mne_to_eeglab_locs as _mne_to_eeglab_locs
from ._utils import _next_power_of_2 as _next_power_of_2
from ._utils import _pol2cart as _pol2cart

def get_iclabel_features(inst: Union[BaseRaw, BaseEpochs], ica: ICA):
def get_iclabel_features(inst: BaseRaw | BaseEpochs, ica: ICA):
"""Generate the features for ICLabel neural network.
Parameters
Expand Down Expand Up @@ -52,9 +50,7 @@ def _retrieve_eeglab_icawinv(ica: ICA) -> tuple[NDArray[float], NDArray[float]]:
weights : array
"""

def _compute_ica_activations(
inst: Union[BaseRaw, BaseEpochs], ica: ICA
) -> NDArray[float]:
def _compute_ica_activations(inst: BaseRaw | BaseEpochs, ica: ICA) -> NDArray[float]:
"""Compute the ICA activations 'icaact' variable from an MNE ICA instance.
Parameters
Expand Down Expand Up @@ -86,7 +82,7 @@ def _compute_ica_activations(
"""

def _eeg_topoplot(
inst: Union[BaseRaw, BaseEpochs], icawinv: NDArray[float], picks: list[str]
inst: BaseRaw | BaseEpochs, icawinv: NDArray[float], picks: list[str]
) -> NDArray[float]:
"""Topoplot feature."""

Expand All @@ -96,17 +92,17 @@ def _topoplotFast(
"""Implement topoplotFast.m from MATLAB. Each topographic map is a 32x32 images."""

def _eeg_rpsd(
inst: Union[BaseRaw, BaseEpochs], ica: ICA, icaact: NDArray[float]
inst: BaseRaw | BaseEpochs, ica: ICA, icaact: NDArray[float]
) -> NDArray[float]:
"""PSD feature."""

def _eeg_rpsd_constants(
inst: Union[BaseRaw, BaseEpochs], ica: ICA
inst: BaseRaw | BaseEpochs, ica: ICA
) -> tuple[int, int, int, int, NDArray[int], NDArray[float], NDArray[int]]:
"""Compute the constants before ``randperm`` is used to compute the subset."""

def _eeg_rpsd_compute_psdmed(
inst: Union[BaseRaw, BaseEpochs],
inst: BaseRaw | BaseEpochs,
icaact: NDArray[float],
ncomp: int,
nfreqs: int,
Expand Down Expand Up @@ -143,7 +139,7 @@ def _eeg_autocorr_fftw(
MATLAB: 'eeg_autocorr_fftw.m'.
"""

def _resample(ac: NDArray[float], fs: Union[int, float]) -> NDArray[float]:
def _resample(ac: NDArray[float], fs: int | float) -> NDArray[float]:
"""Resample the autocorrelation feature.
The comment in EEGLAB is:
Expand Down
6 changes: 2 additions & 4 deletions mne_icalabel/iclabel/label_components.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional, Union

from mne import BaseEpochs as BaseEpochs
from mne.io import BaseRaw as BaseRaw
from mne.preprocessing import ICA
Expand All @@ -8,10 +6,10 @@ from .features import get_iclabel_features as get_iclabel_features
from .network import run_iclabel as run_iclabel

def iclabel_label_components(
inst: Union[BaseRaw, BaseEpochs],
inst: BaseRaw | BaseEpochs,
ica: ICA,
inplace: bool = True,
backend: Optional[str] = None,
backend: str | None = None,
):
"""Label the provided ICA components with the ICLabel neural network.
Expand Down
4 changes: 1 addition & 3 deletions mne_icalabel/iclabel/network/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from typing import Optional

from numpy.typing import ArrayLike, NDArray

def run_iclabel(
images: ArrayLike,
psds: ArrayLike,
autocorr: ArrayLike,
backend: Optional[str] = "pytorch",
backend: str | None = "pytorch",
) -> NDArray:
"""Run the ICLabel network on the provided set of features.
Expand Down
4 changes: 1 addition & 3 deletions mne_icalabel/label_components.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Union

from mne import BaseEpochs as BaseEpochs
from mne.io import BaseRaw as BaseRaw
from mne.preprocessing import ICA
Expand All @@ -8,7 +6,7 @@ from .config import ICALABEL_METHODS as ICALABEL_METHODS
from .iclabel._config import ICLABEL_NUMERICAL_TO_STRING as ICLABEL_NUMERICAL_TO_STRING
from .utils._checks import _validate_inst_and_ica as _validate_inst_and_ica

def label_components(inst: Union[BaseRaw, BaseEpochs], ica: ICA, method: str):
def label_components(inst: BaseRaw | BaseEpochs, ica: ICA, method: str):
"""Automatically label the ICA components with the selected method.
Parameters
Expand Down
4 changes: 1 addition & 3 deletions mne_icalabel/utils/_checks.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from typing import Union

from mne import BaseEpochs
from mne.io import BaseRaw
from mne.preprocessing import ICA

def _validate_inst_and_ica(inst: Union[BaseRaw, BaseEpochs], ica: ICA):
def _validate_inst_and_ica(inst: BaseRaw | BaseEpochs, ica: ICA):
"""Make sure that the provided instance and ICA are valid."""

def _validate_ica(ica: ICA):
Expand Down
3 changes: 1 addition & 2 deletions mne_icalabel/utils/_imports.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from types import ModuleType as ModuleType
from typing import Optional

_INSTALL_MAPPING: dict[str, str]

def import_optional_dependency(
name: str, extra: str = "", raise_error: bool = True
) -> Optional[ModuleType]:
) -> ModuleType | None:
"""Import an optional dependency.
By default, if a dependency is missing an ImportError with a nice message will be
Expand Down
4 changes: 2 additions & 2 deletions mne_icalabel/utils/config.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import IO, Callable, Optional
from typing import IO, Callable

from packaging.requirements import Requirement

def sys_info(fid: Optional[IO] = None, developer: bool = False):
def sys_info(fid: IO | None = None, developer: bool = False):
"""Print the system information for debugging.
Parameters
Expand Down

0 comments on commit 12d598c

Please sign in to comment.