Skip to content
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
39 changes: 11 additions & 28 deletions .github/workflows/doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,28 @@ jobs:
build:
timeout-minutes: 30
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
path: ./main
- name: Setup Python 3.9
uses: actions/setup-python@v5
- uses: actions/setup-python@v5
with:
python-version: 3.9
architecture: 'x64'
python-version: 3.13
- name: Install linux dependencies
run: |
sudo apt update
sudo apt install optipng
- name: Setup headless display
uses: pyvista/setup-headless-display-action@main
- uses: pyvista/setup-headless-display-action@main
with:
qt: true
- name: Install package
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off main/.[doc]
- name: Display system information
run: mne_icalabel-sys_info --developer
- name: Build doc
run: sphinx-build ./main/doc ./doc-build/dev -W --keep-going
- name: Prune sphinx environment
run: sudo rm -R ./doc-build/dev/.doctrees
- name: Upload documentation
uses: actions/upload-artifact@v4
- run: mne_icalabel-sys_info --developer
- run: sphinx-build ./main/doc ./doc-build/dev -W --keep-going
- run: sudo rm -R ./doc-build/dev/.doctrees
- uses: actions/upload-artifact@v4
with:
name: doc-dev
path: ./doc-build/dev
Expand All @@ -56,19 +45,13 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download documentation
uses: actions/download-artifact@v4
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: doc-dev
path: ./doc-dev
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./doc-dev
target-folder: ./dev
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@ jobs:
runs-on: ubuntu-latest
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
- uses: actions/checkout@v4
- uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper/paper.md
- name: Upload
uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v4
with:
name: paper
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: paper/paper.pdf
18 changes: 6 additions & 12 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,19 @@ jobs:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python 3.9
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
architecture: 'x64'
- name: Setup headless display
uses: pyvista/setup-headless-display-action@main
python-version: '3.13'
- uses: pyvista/setup-headless-display-action@main
with:
qt: true
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off -e .[build,stubs]
- name: Display system information
run: mne_icalabel-sys_info --developer
- name: Generate stub files
run: python tools/stubgen.py
- run: mne_icalabel-sys_info --developer
- run: python tools/stubgen.py
- name: Build and publish
env:
TWINE_USERNAME: __token__
Expand Down
41 changes: 13 additions & 28 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,27 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.9, "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
name: ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup headless display
uses: pyvista/setup-headless-display-action@main
- uses: pyvista/setup-headless-display-action@main
with:
qt: true
- name: Install package
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off .[test]
- name: Display system information
run: mne_icalabel-sys_info --developer
- name: Run pytest
run: pytest mne_icalabel --cov=mne_icalabel --cov-report=xml --cov-config=pyproject.toml
- name: Upload to codecov
uses: codecov/codecov-action@v5
- run: mne_icalabel-sys_info --developer
- run: pytest mne_icalabel --cov=mne_icalabel --cov-report=xml --cov-config=pyproject.toml
- uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
flags: unittests # optional
Expand All @@ -59,18 +53,12 @@ jobs:
python-version: ["3.11"]
name: pip pre-release - py${{ matrix.python-version }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup headless display
uses: pyvista/setup-headless-display-action@main
- uses: pyvista/setup-headless-display-action@main
with:
qt: true
- name: Install dependencies
Expand All @@ -80,12 +68,9 @@ jobs:
python -m pip install --progress-bar off --upgrade git+https://github.com/mne-tools/mne-python
python -m pip install --progress-bar off --upgrade git+https://github.com/mne-tools/mne-bids
python -m pip install --progress-bar off --upgrade --pre --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --timeout=180 numpy scipy matplotlib
- name: Display system information
run: mne_icalabel-sys_info --developer
- name: Run pytest
run: pytest mne_icalabel --cov=mne_icalabel --cov-report=xml --cov-config=pyproject.toml
- name: Upload to codecov
uses: codecov/codecov-action@v5
- run: mne_icalabel-sys_info --developer
- run: pytest mne_icalabel --cov=mne_icalabel --cov-report=xml --cov-config=pyproject.toml
- uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
flags: unittests # optional
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/stubs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,20 @@ jobs:
generate:
timeout-minutes: 10
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python 3.9
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
architecture: 'x64'
- name: Setup headless display
uses: pyvista/setup-headless-display-action@main
python-version: 3.13
- uses: pyvista/setup-headless-display-action@main
with:
qt: true
- name: Install package
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off -e .[stubs]
- name: Display system information
run: mne_icalabel-sys_info --developer
- name: Generate stub files
run: python tools/stubgen.py
- run: mne_icalabel-sys_info --developer
- run: python tools/stubgen.py
- name: Push stub files
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
env:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.13
rev: v0.12.0
hooks:
- id: ruff
name: ruff linter
Expand Down
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import sys
from datetime import date
from importlib import import_module
from typing import Optional

import mne
from sphinx_gallery.sorting import FileNameSortKey
Expand Down Expand Up @@ -260,7 +259,7 @@
# https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html


def linkcode_resolve(domain: str, info: dict[str, str]) -> Optional[str]:
def linkcode_resolve(domain: str, info: dict[str, str]) -> str | None:
"""Determine the URL corresponding to a Python object.

Parameters
Expand Down
5 changes: 2 additions & 3 deletions mne_icalabel/annotation/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

if TYPE_CHECKING:
from pathlib import Path
from typing import Union

from mne.preprocessing import ICA


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 @@ -102,7 +101,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.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from .iclabel import iclabel_label_components

if TYPE_CHECKING:
from typing import Callable, Optional
from collections.abc import Callable

ICALABEL_METHODS: dict[str, Optional[Callable]] = {
ICALABEL_METHODS: dict[str, Callable | None] = {
"iclabel": iclabel_label_components,
"manual": None,
}
Expand Down
2 changes: 1 addition & 1 deletion mne_icalabel/config.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable
from collections.abc import Callable

from .iclabel import iclabel_label_components as iclabel_label_components

Expand Down
3 changes: 1 addition & 2 deletions mne_icalabel/datasets/icalabel/icalabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

if TYPE_CHECKING:
from pathlib import Path
from typing import Optional

has_icalabel_testing_data = partial(has_dataset, name="icalabel-testing")


@verbose
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.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from ..utils._docs import fill_doc

if TYPE_CHECKING:
from typing import Union

from mne import Info
from mne.preprocessing import ICA
from numpy.typing import NDArray
Expand All @@ -31,7 +29,7 @@ def get_topomaps(
picks=None,
res: int = 64,
image_interp: str = _INTERPOLATION_DEFAULT, # 'cubic'
border: Union[float, str] = _BORDER_DEFAULT, # 'mean'
border: float | str = _BORDER_DEFAULT, # 'mean'
extrapolate: str = _EXTRAPOLATE_DEFAULT, # 'auto' -> 'head' (EEG), 'local' (MEG)
) -> dict[str, NDArray[float]]:
"""Generate an array of scalp topographies for the picked components.
Expand Down Expand Up @@ -100,7 +98,7 @@ def _get_topomap_array(
info: Info,
res: int = 64,
image_interp: str = _INTERPOLATION_DEFAULT, # 'cubic'
border: Union[float, str] = _BORDER_DEFAULT, # 'mean'
border: float | str = _BORDER_DEFAULT, # 'mean'
extrapolate: str = _EXTRAPOLATE_DEFAULT, # 'auto' -> 'head' (EEG), 'local' (MEG)
) -> NDArray[float]:
"""Generate a scalp topographic map (n_pixels, n_pixels).
Expand Down
10 changes: 4 additions & 6 deletions mne_icalabel/gui/_label_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from mne_icalabel.config import ICA_LABELS_TO_MNE

if TYPE_CHECKING:
from typing import Union
pass


class ICAComponentLabeler(QMainWindow):
Expand All @@ -37,9 +37,7 @@ class ICAComponentLabeler(QMainWindow):
show : bool
"""

def __init__(
self, inst: Union[BaseRaw, BaseEpochs], ica: ICA, show: bool = True
) -> None:
def __init__(self, inst: BaseRaw | BaseEpochs, ica: ICA, show: bool = True) -> None:
ICAComponentLabeler._check_inst_ica(inst, ica)
super().__init__() # initialize the QMainwindow
set_browser_backend("qt") # force MNE to use the QT Browser
Expand Down Expand Up @@ -164,7 +162,7 @@ def _load_ui(self) -> None:

# - Checkers --------------------------------------------------------------
@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."""
_validate_type(inst, (BaseRaw, BaseEpochs), "inst", "raw or epochs")
_validate_type(ica, ICA, "ica", "ICA")
Expand All @@ -176,7 +174,7 @@ def _check_inst_ica(inst: Union[BaseRaw, BaseEpochs], ica: ICA) -> None:

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

Expand Down
Loading