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
2 changes: 1 addition & 1 deletion .github/workflows/full_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.14"] # Lower and higher versions we support
python-version: ["3.10", "3.14"] # Lower and higher versions we support
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Install Tools
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_12_plot_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

fig, ax = plt.subplots()
poly, poly_contour = plot_probe(probe, contacts_values=values,
cmap='jet', ax=ax, contacts_kargs={'alpha' : 1}, title=False)
cmap='jet', ax=ax, contact_kwargs={'alpha' : 1}, title=False)
poly.set_clim(-2, 2)
fig.colorbar(poly)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [

description = "Python package to handle probe layout, geometry and wiring to device."
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down
13 changes: 6 additions & 7 deletions src/probeinterface/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

"""

from __future__ import annotations
import numpy as np

from typing import Optional
from typing import Literal

from .probe import Probe
from .probegroup import ProbeGroup
Expand All @@ -15,7 +14,7 @@
_default_shape_to_params = {"circle": "radius", "square": "width", "rect": "height"}


def generate_dummy_probe(elec_shapes: "circle" | "square" | "rect" = "circle") -> Probe:
Copy link
Member Author

Choose a reason for hiding this comment

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

This actually means union! So it doesn't make any sense!

def generate_dummy_probe(elec_shapes: Literal["circle", "square", "rect"] = "circle") -> Probe:
"""
Generate a dummy probe with 3 columns and 32 contacts.
Mainly used for testing and examples.
Expand Down Expand Up @@ -103,8 +102,8 @@ def generate_multi_columns_probe(
num_contact_per_column: int | list[int] = 10,
xpitch: float = 20,
ypitch: float = 20,
y_shift_per_column: Optional[np.array | list] = None,
contact_shapes: "circle" | "rect" | "square" = "circle",
y_shift_per_column: np.ndarray | list | None = None,
contact_shapes: Literal["circle", "rect", "square"] = "circle",
contact_shape_params: dict = {"radius": 6},
) -> Probe:
"""Generate a Probe with several columns.
Expand All @@ -119,7 +118,7 @@ def generate_multi_columns_probe(
Pitch in x direction
ypitch : float, default: 20
Pitch in y direction
y_shift_per_column : Optional[array-like], default: None
y_shift_per_column : array-like | None, default: None
Shift in y direction per column. It needs to have the same length as num_columns, by default None
contact_shapes : "circle" | "rect" | "square", default: "circle"
Shape of the contacts
Expand Down Expand Up @@ -167,7 +166,7 @@ def generate_multi_columns_probe(
def generate_linear_probe(
num_elec: int = 16,
ypitch: float = 20,
contact_shapes: "circle" | "rect" | "square" = "circle",
contact_shapes: Literal["circle", "rect", "square"] = "circle",
contact_shape_params: dict = {"radius": 6},
) -> Probe:
"""Generate a one-column linear probe.
Expand Down
12 changes: 5 additions & 7 deletions src/probeinterface/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

"""

from __future__ import annotations
from pathlib import Path
from typing import Union, Optional
import re
import warnings
import json
Expand Down Expand Up @@ -108,7 +106,7 @@ def write_probeinterface(file: str | Path, probe_or_probegroup: Probe | ProbeGro
tsv_label_map_to_probeinterface = {v: k for k, v in tsv_label_map_to_BIDS.items()}


def read_BIDS_probe(folder: str | Path, prefix: Optional[str] = None) -> ProbeGroup:
def read_BIDS_probe(folder: str | Path, prefix: str | None = None) -> ProbeGroup:
"""
Read to BIDS probe format.

Expand Down Expand Up @@ -636,8 +634,8 @@ def read_3brain(file: str | Path, mea_pitch: float = None, electrode_width: floa
def write_prb(
file: str,
probegroup: ProbeGroup,
total_nb_channels: Optional[int] = None,
radius: Optional[float] = None,
total_nb_channels: int | None = None,
radius: float | None = None,
group_mode: str = "by_probe",
):
"""
Expand All @@ -664,9 +662,9 @@ def write_prb(
The name of the file to be written
probegroup: ProbeGroup
The Probegroup to be used for writing
total_nb_channels: Optional[int], default None
total_nb_channels: int | None, default None
***to do
radius: Optional[float], default None
radius: float | None, default None
*** to do
group_mode: str
One of "by_probe" or "by_shank
Expand Down
11 changes: 5 additions & 6 deletions src/probeinterface/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@

"""

from __future__ import annotations
import os
import warnings
from pathlib import Path
from urllib.request import urlopen
import requests
from typing import Optional

from .io import read_probeinterface
from .probe import Probe

# OLD URL on gin
# public_url = "https://web.gin.g-node.org/spikeinterface/probeinterface_library/raw/master/"
Expand All @@ -37,7 +36,7 @@ def get_cache_folder() -> Path:
return Path(os.path.expanduser("~")) / ".config" / "probeinterface" / "library"


def download_probeinterface_file(manufacturer: str, probe_name: str, tag: Optional[str] = None) -> None:
def download_probeinterface_file(manufacturer: str, probe_name: str, tag: str | None = None) -> None:
"""Download the probeinterface file to the cache directory.
Note that the file is itself a ProbeGroup but on the repo each file
represents one probe.
Expand Down Expand Up @@ -65,7 +64,7 @@ def download_probeinterface_file(manufacturer: str, probe_name: str, tag: Option
f.write(rem.read())


def get_from_cache(manufacturer: str, probe_name: str, tag: Optional[str] = None) -> Optional["Probe"]:
def get_from_cache(manufacturer: str, probe_name: str, tag: str | None = None) -> Probe | None:
"""
Get Probe from local cache

Expand Down Expand Up @@ -105,8 +104,8 @@ def get_from_cache(manufacturer: str, probe_name: str, tag: Optional[str] = None
def get_probe(
manufacturer: str,
probe_name: str,
name: Optional[str] = None,
tag: Optional[str] = None,
name: str | None = None,
tag: str | None = None,
force_download: bool = False,
) -> "Probe":
"""
Expand Down
30 changes: 13 additions & 17 deletions src/probeinterface/neuropixels_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

"""

from __future__ import annotations
from pathlib import Path
from typing import Union, Optional
import warnings
from packaging.version import parse
import json
Expand Down Expand Up @@ -114,7 +112,7 @@ def get_probe_length(probe_part_number: str) -> int:
return 10_000


def make_mux_table_array(mux_information) -> np.array:
def make_mux_table_array(mux_information) -> np.ndarray:
"""
Function to parse the mux_table from ProbeTable.

Expand Down Expand Up @@ -210,7 +208,7 @@ def get_probe_contour_vertices(shank_width, tip_length, probe_length) -> list:
return polygon_vertices


def read_imro(file_path: Union[str, Path]) -> Probe:
def read_imro(file_path: str | Path) -> Probe:
"""
Read probe position from the imro file used in input of SpikeGlx and Open-Ephys for neuropixels probes.

Expand Down Expand Up @@ -571,7 +569,7 @@ def _annotate_probe_with_adc_sampling_info(probe: Probe, adc_sampling_table: str
_annotate_contacts_from_mux_table(probe, adc_groups_array)


def _read_imro_string(imro_str: str, imDatPrb_pn: Optional[str] = None) -> Probe:
def _read_imro_string(imro_str: str, imDatPrb_pn: str | None = None) -> Probe:
"""
Parse the IMRO table when presented as a string and create a Probe object.

Expand Down Expand Up @@ -1027,7 +1025,7 @@ def parse_spikeglx_snsGeomMap(meta):
# parse_spikeglx_snsGeomMap(meta)


def get_saved_channel_indices_from_spikeglx_meta(meta_file: str | Path) -> np.array:
def get_saved_channel_indices_from_spikeglx_meta(meta_file: str | Path) -> np.ndarray:
"""
Utils function to get the saved channels.

Expand Down Expand Up @@ -1067,7 +1065,7 @@ def _parse_openephys_settings(
settings_file: str | Path,
fix_x_position_for_oe_5: bool = True,
raise_error: bool = True,
) -> Optional[list[dict]]:
) -> list[dict] | None:
"""
Parse an Open Ephys settings.xml and extract per-probe metadata.

Expand Down Expand Up @@ -1396,11 +1394,11 @@ def _parse_openephys_settings(

def _select_openephys_probe_info(
probes_info: list[dict],
stream_name: Optional[str] = None,
probe_name: Optional[str] = None,
serial_number: Optional[str] = None,
stream_name: str | None = None,
probe_name: str | None = None,
serial_number: str | None = None,
raise_error: bool = True,
) -> Optional[dict]:
) -> dict | None:
"""
Select one probe's info dict from the list returned by `_parse_openephys_settings`.

Expand Down Expand Up @@ -1587,9 +1585,9 @@ def _annotate_openephys_probe(probe: Probe, probe_info: dict) -> None:

def read_openephys(
settings_file: str | Path,
stream_name: Optional[str] = None,
probe_name: Optional[str] = None,
serial_number: Optional[str] = None,
stream_name: str | None = None,
probe_name: str | None = None,
serial_number: str | None = None,
fix_x_position_for_oe_5: bool = True,
raise_error: bool = True,
) -> Probe:
Expand Down Expand Up @@ -1676,9 +1674,7 @@ def read_openephys(
return probe


def get_saved_channel_indices_from_openephys_settings(
settings_file: str | Path, stream_name: str
) -> Optional[np.array]:
def get_saved_channel_indices_from_openephys_settings(settings_file: str | Path, stream_name: str) -> np.ndarray | None:
"""
Returns an array with the subset of saved channels indices (if used)

Expand Down
23 changes: 16 additions & 7 deletions src/probeinterface/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Depending on Probe.ndim, the plotting is done in 2D or 3D
"""

from __future__ import annotations
import warnings
import numpy as np
from matplotlib import path as mpl_path

Expand Down Expand Up @@ -46,8 +46,6 @@ def create_probe_polygons(
The polygon collection for the probe shape
"""
if contacts_kargs is not None:
import warnings

warnings.warn(
"contacts_kargs is deprecated and will be removed in 0.3.4. Please use `contacts_kwargs` instead.",
category=DeprecationWarning,
Expand Down Expand Up @@ -107,13 +105,14 @@ def plot_probe(
contacts_values: list | np.ndarray | None = None,
cmap: str = "viridis",
title: bool = True,
contacts_kargs: dict = {},
contact_kwargs: dict = {},
probe_shape_kwargs: dict = {},
xlims: tuple | None = None,
ylims: tuple | None = None,
zlims: tuple | None = None,
show_channel_on_click: bool = False,
side=None,
side: str | None = None,
contacts_kargs: dict | None = None,
):
"""Plot a Probe object.
Generates a 2D or 3D axis, depending on Probe.ndim
Expand All @@ -138,7 +137,7 @@ def plot_probe(
A colormap color
title : bool, default: True
If True, the axis title is set to the probe name
contacts_kargs : dict, default: {}
contact_kwargs : dict, default: {}
Dict with kwargs for contacts (e.g. alpha, edgecolor, lw)
probe_shape_kwargs : dict, default: {}
Dict with kwargs for probe shape (e.g. alpha, edgecolor, lw)
Expand All @@ -152,6 +151,8 @@ def plot_probe(
If True, the channel information is shown upon click
side : None | "front" | "back"
If the probe is two side, then the side must be given otherwise this raises an error.
contacts_kargs : dict | None, default: None
DEPRECATED, use contact_kwargs instead. Dict with kwargs for contacts (e.g. alpha, edgecolor, lw)

Returns
-------
Expand All @@ -162,6 +163,14 @@ def plot_probe(
"""
import matplotlib.pyplot as plt

if contacts_kargs is not None:
warnings.warn(
"contacts_kwargs is deprecated and will be removed in 0.3.4. Please use `contact_kwargs` instead.",
category=DeprecationWarning,
stacklevel=2,
)
contact_kwargs = contacts_kargs

if probe.contact_sides is not None:
if side is None or side not in ("front", "back"):
raise ValueError(
Expand All @@ -187,7 +196,7 @@ def plot_probe(
contacts_colors=contacts_colors,
contacts_values=contacts_values,
cmap=cmap,
contacts_kargs=contacts_kargs,
contact_kwargs=contact_kwargs,
probe_shape_kwargs=probe_shape_kwargs,
)

Expand Down
Loading
Loading