Skip to content

Commit

Permalink
MAINT: Future compatibility with MNE 1.6 (#120)
Browse files Browse the repository at this point in the history
* compatibility for meas_info

* compatibility for fiff.py and ch_data.py

* compatibility for test_meas_info

* fix missed for _picks_to_idx

* fix missed

* fix style

* trigger cis

* fix cis MNE-main which should install the dependencies required by main instead of stable

* trigger cis

* install pre-release binaries for numpy and scipy when running MNE-main tests

* try again to install pre-release binaries

* try again

* trigger cis

* Update azure-pipelines.yml

* increase timeout, upgrade instead of force-reinstall, and add matplotlib

* fix numpy 1.25 deprecation

* sort alphabetically

* rm duplicate junitxml and use the set coverage config
  • Loading branch information
mscheltienne authored Sep 14, 2023
1 parent d39ad93 commit a8416cc
Show file tree
Hide file tree
Showing 18 changed files with 182 additions and 88 deletions.
40 changes: 20 additions & 20 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,67 +48,67 @@ stages:
linux 3.8:
VM_IMAGE: 'ubuntu-latest'
PYTHON_VERSION: '3.8'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_LINUX)
linux 3.9:
VM_IMAGE: 'ubuntu-latest'
PYTHON_VERSION: '3.9'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_LINUX)
linux 3.10:
VM_IMAGE: 'ubuntu-latest'
PYTHON_VERSION: '3.10'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_LINUX)
linux 3.11:
VM_IMAGE: 'ubuntu-latest'
PYTHON_VERSION: '3.11'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_LINUX)
linux 3.10 MNE-dev:
VM_IMAGE: 'ubuntu-latest'
PYTHON_VERSION: '3.10'
MNE_DEV: true
PRE: true
CACHE_MNE_PATH: $(CACHE_PATH_MNE_LINUX)
macOS 3.8:
VM_IMAGE: 'macOS-latest'
PYTHON_VERSION: '3.8'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_MACOS)
macOS 3.9:
VM_IMAGE: 'macOS-latest'
PYTHON_VERSION: '3.9'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_MACOS)
macOS 3.10:
VM_IMAGE: 'macOS-latest'
PYTHON_VERSION: '3.10'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_MACOS)
macOS 3.11:
VM_IMAGE: 'macOS-latest'
PYTHON_VERSION: '3.11'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_MACOS)
windows 3.8:
VM_IMAGE: 'windows-latest'
PYTHON_VERSION: '3.8'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_WINDOWS)
windows 3.9:
VM_IMAGE: 'windows-latest'
PYTHON_VERSION: '3.9'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_WINDOWS)
windows 3.10:
VM_IMAGE: 'windows-latest'
PYTHON_VERSION: '3.10'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_WINDOWS)
windows 3.11:
VM_IMAGE: 'windows-latest'
PYTHON_VERSION: '3.11'
MNE_DEV: false
PRE: false
CACHE_MNE_PATH: $(CACHE_PATH_MNE_WINDOWS)
pool:
vmImage: $(VM_IMAGE)
Expand All @@ -121,13 +121,13 @@ stages:
displayName: 'Setup Python $(PYTHON_VERSION)'
- script: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off .[test]
displayName: 'Install dependencies and MNE (stable)'
python -m pip install --progress-bar off --upgrade .[test]
displayName: 'Install package'
- script: |
python -m pip uninstall -y mne
python -m pip install --progress-bar off --no-deps git+https://github.com/mne-tools/mne-python
condition: eq(variables.MNE_DEV, 'true')
displayName: 'Install MNE (main)'
python -m pip install --progress-bar off --force-reinstall git+https://github.com/mne-tools/mne-python
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 scikit-learn matplotlib
condition: eq(variables.PRE, 'true')
displayName: 'Install pre-release dependencies'
- script: mne sys_info -pd
displayName: 'Display MNE config'
- script: |
Expand All @@ -142,7 +142,7 @@ stages:
- script: python -c "import mne; mne.datasets.testing.data_path(verbose=True)"
displayName: 'Get MNE testing datataset'
condition: ne(variables.CACHE_MNE_RESTORED, 'true')
- script: pytest pycrostates --junitxml=junit/test-results.xml --cov=pycrostates --cov-report=xml
- script: pytest pycrostates --cov=pycrostates --cov-report=xml --cov-config=pyproject.toml
displayName: 'Run unit tests'
- task: PublishCodeCoverageResults@1
inputs:
Expand Down
7 changes: 6 additions & 1 deletion pycrostates/cluster/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
from mne import BaseEpochs, pick_info
from mne.annotations import _annotations_starts_stops
from mne.io import BaseRaw
from mne.io.pick import _picks_to_idx
from mne.utils import check_version
from numpy.typing import NDArray
from scipy.signal import convolve2d

if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_to_idx
else:
from mne.io.pick import _picks_to_idx

from .._typing import CHData, Cluster, Picks
from ..segmentation import EpochsSegmentation, RawSegmentation
from ..utils import _corr_vectors
Expand Down
7 changes: 6 additions & 1 deletion pycrostates/cluster/tests/test_aahc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
from mne.channels import DigMontage
from mne.datasets import testing
from mne.io import RawArray, read_raw_fif
from mne.io.pick import _picks_to_idx
from mne.utils import check_version
from numpy.testing import assert_allclose

if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_to_idx
else:
from mne.io.pick import _picks_to_idx

from pycrostates import __version__
from pycrostates.cluster import AAHCluster
from pycrostates.io import ChData, ChInfo, read_cluster
Expand Down
7 changes: 6 additions & 1 deletion pycrostates/cluster/tests/test_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
from mne.channels import DigMontage
from mne.datasets import testing
from mne.io import RawArray, read_raw_fif
from mne.io.pick import _picks_to_idx
from mne.utils import check_version
from numpy.testing import assert_allclose

if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_to_idx
else:
from mne.io.pick import _picks_to_idx

from pycrostates import __version__
from pycrostates.cluster import ModKMeans
from pycrostates.io import ChData, ChInfo, read_cluster
Expand Down
9 changes: 7 additions & 2 deletions pycrostates/io/ch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
from typing import Any, Union

import numpy as np
from mne.io import Info
from mne.io.pick import _picks_to_idx, pick_info
from mne import Info, pick_info
from mne.utils import check_version
from numpy.typing import NDArray

if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_to_idx
else:
from mne.io.pick import _picks_to_idx

from .._typing import CHData, CHInfo
from ..utils._checks import _check_type
from ..utils._docs import fill_doc
Expand Down
69 changes: 46 additions & 23 deletions pycrostates/io/fiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,53 @@
from typing import List, Union

import numpy as np
from mne.io import Info
from mne.io._digitization import _format_dig_points, _read_dig_fif
from mne import Info, Transform
from mne.io.constants import FIFF
from mne.io.ctf_comp import _read_ctf_comp, write_ctf_comp
from mne.io.meas_info import _read_bad_channels, _write_ch_infos
from mne.io.open import fiff_open
from mne.io.proj import _read_proj, _write_proj
from mne.io.tag import read_tag
from mne.io.tree import dir_tree_find
from mne.io.write import (
end_block,
start_and_end_file,
start_block,
write_coord_trans,
write_dig_points,
write_double_matrix,
write_id,
write_int,
write_name_list,
write_string,
)
from mne.transforms import Transform, invert_transform
from mne.transforms import invert_transform
from mne.utils import check_version
from numpy.typing import NDArray

if check_version("mne", "1.6"):
from mne._fiff._digitization import _format_dig_points, _read_dig_fif
from mne._fiff.ctf_comp import _read_ctf_comp, write_ctf_comp
from mne._fiff.meas_info import _read_bad_channels, _write_ch_infos
from mne._fiff.open import fiff_open
from mne._fiff.proj import _read_proj, _write_proj
from mne._fiff.tag import read_tag
from mne._fiff.tree import dir_tree_find
from mne._fiff.write import (
end_block,
start_and_end_file,
start_block,
write_coord_trans,
write_dig_points,
write_double_matrix,
write_id,
write_int,
write_name_list,
write_string,
)
else:
from mne.io._digitization import _format_dig_points, _read_dig_fif
from mne.io.ctf_comp import _read_ctf_comp, write_ctf_comp
from mne.io.meas_info import _read_bad_channels, _write_ch_infos
from mne.io.open import fiff_open
from mne.io.proj import _read_proj, _write_proj
from mne.io.tag import read_tag
from mne.io.tree import dir_tree_find
from mne.io.write import (
end_block,
start_and_end_file,
start_block,
write_coord_trans,
write_dig_points,
write_double_matrix,
write_id,
write_int,
write_name_list,
write_string,
)

from .. import __version__
from .._typing import CHInfo
from ..cluster import AAHCluster, ModKMeans
Expand Down Expand Up @@ -521,13 +544,13 @@ def _read_meas_info(fid, tree):
pos = meas_info["directory"][k].pos
if kind == FIFF.FIFF_NCHAN:
tag = read_tag(fid, pos)
nchan = int(tag.data)
nchan = int(tag.data.item())
elif kind == FIFF.FIFF_CH_INFO:
tag = read_tag(fid, pos)
chs.append(tag.data)
elif kind == FIFF.FIFF_MNE_CUSTOM_REF:
tag = read_tag(fid, pos)
custom_ref_applied = int(tag.data)
custom_ref_applied = int(tag.data.item())
elif kind == FIFF.FIFF_COORD_TRANS:
tag = read_tag(fid, pos)
cand = tag.data
Expand Down
31 changes: 20 additions & 11 deletions pycrostates/io/meas_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,29 @@
from typing import List, Optional, Tuple, Union

import numpy as np
from mne.io import Info
from mne import Info, Projection, Transform
from mne.io.constants import FIFF
from mne.io.meas_info import (
_check_bads,
_check_ch_keys,
_check_dev_head_t,
_unique_channel_names,
)
from mne.io.pick import get_channel_type_constants
from mne.io.proj import Projection
from mne.io.tag import _ch_coord_dict
from mne.transforms import Transform
from mne.utils import check_version

if check_version("mne", "1.6"):
from mne._fiff.meas_info import (
_check_bads,
_check_ch_keys,
_check_dev_head_t,
_unique_channel_names,
)
from mne._fiff.pick import get_channel_type_constants
from mne._fiff.tag import _ch_coord_dict
else:
from mne.io.meas_info import (
_check_bads,
_check_ch_keys,
_check_dev_head_t,
_unique_channel_names,
)
from mne.io.pick import get_channel_type_constants
from mne.io.tag import _ch_coord_dict

from .._typing import CHInfo
from ..utils._checks import _check_type, _IntLike
from ..utils._logs import logger
Expand Down
3 changes: 1 addition & 2 deletions pycrostates/io/tests/test_meas_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

import numpy as np
import pytest
from mne import create_info
from mne import Transform, create_info
from mne.channels import DigMontage
from mne.datasets import testing
from mne.io import read_raw_fif
from mne.io.constants import FIFF
from mne.transforms import Transform
from mne.utils import check_version
from numpy.testing import assert_allclose

Expand Down
7 changes: 6 additions & 1 deletion pycrostates/preprocessing/extract_gfp_peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
import numpy as np
from mne import BaseEpochs, pick_info
from mne.io import BaseRaw
from mne.io.pick import _picks_to_idx
from mne.utils import check_version
from numpy.typing import NDArray
from scipy.signal import find_peaks

if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_to_idx
else:
from mne.io.pick import _picks_to_idx

from .._typing import CHData, Picks
from ..utils._checks import (
_check_picks_uniqueness,
Expand Down
7 changes: 6 additions & 1 deletion pycrostates/preprocessing/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import numpy as np
from mne import BaseEpochs, pick_info
from mne.io import BaseRaw
from mne.io.pick import _picks_to_idx
from mne.utils import check_version

if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_to_idx
else:
from mne.io.pick import _picks_to_idx

from .._typing import CHData, Picks, RANDomState
from ..utils._checks import (
Expand Down
7 changes: 6 additions & 1 deletion pycrostates/preprocessing/spatial_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
from mne.channels import find_ch_adjacency
from mne.channels.interpolation import _make_interpolation_matrix
from mne.io import BaseRaw
from mne.io.pick import _picks_by_type
from mne.parallel import parallel_func
from mne.utils import check_version
from mne.utils.check import _check_preload
from numpy.typing import NDArray
from scipy.sparse import csr_matrix

if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_by_type
else:
from mne.io.pick import _picks_by_type

from .._typing import CHData
from ..utils._checks import _check_n_jobs, _check_type, _check_value
from ..utils._docs import fill_doc
Expand Down
7 changes: 6 additions & 1 deletion pycrostates/preprocessing/tests/test_extract_gfp_peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
import pytest
from mne import pick_info
from mne.datasets import testing
from mne.io.pick import _picks_to_idx
from mne.utils import check_version

if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_to_idx
else:
from mne.io.pick import _picks_to_idx

from pycrostates.io import ChData
from pycrostates.preprocessing import extract_gfp_peaks
Expand Down
Loading

0 comments on commit a8416cc

Please sign in to comment.