Skip to content

Commit a57bfe6

Browse files
committed
Fix annotations
1 parent 62934bf commit a57bfe6

7 files changed

Lines changed: 61 additions & 63 deletions

File tree

src/probeinterface/generator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77

8-
from typing import Optional
8+
from typing import Literal
99

1010
from .probe import Probe
1111
from .probegroup import ProbeGroup
@@ -14,7 +14,7 @@
1414
_default_shape_to_params = {"circle": "radius", "square": "width", "rect": "height"}
1515

1616

17-
def generate_dummy_probe(elec_shapes: "circle" | "square" | "rect" = "circle") -> Probe:
17+
def generate_dummy_probe(elec_shapes: Literal["circle", "square", "rect"] = "circle") -> Probe:
1818
"""
1919
Generate a dummy probe with 3 columns and 32 contacts.
2020
Mainly used for testing and examples.
@@ -102,8 +102,8 @@ def generate_multi_columns_probe(
102102
num_contact_per_column: int | list[int] = 10,
103103
xpitch: float = 20,
104104
ypitch: float = 20,
105-
y_shift_per_column: Optional[np.array | list] = None,
106-
contact_shapes: "circle" | "rect" | "square" = "circle",
105+
y_shift_per_column: np.ndarray | list | None = None,
106+
contact_shapes: Literal["circle", "rect", "square"] = "circle",
107107
contact_shape_params: dict = {"radius": 6},
108108
) -> Probe:
109109
"""Generate a Probe with several columns.
@@ -118,7 +118,7 @@ def generate_multi_columns_probe(
118118
Pitch in x direction
119119
ypitch : float, default: 20
120120
Pitch in y direction
121-
y_shift_per_column : Optional[array-like], default: None
121+
y_shift_per_column : array-like | None, default: None
122122
Shift in y direction per column. It needs to have the same length as num_columns, by default None
123123
contact_shapes : "circle" | "rect" | "square", default: "circle"
124124
Shape of the contacts
@@ -166,7 +166,7 @@ def generate_multi_columns_probe(
166166
def generate_linear_probe(
167167
num_elec: int = 16,
168168
ypitch: float = 20,
169-
contact_shapes: "circle" | "rect" | "square" = "circle",
169+
contact_shapes: Literal["circle", "rect", "square"] = "circle",
170170
contact_shape_params: dict = {"radius": 6},
171171
) -> Probe:
172172
"""Generate a one-column linear probe.

src/probeinterface/io.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"""
1111

1212
from pathlib import Path
13-
from typing import Union, Optional
1413
import re
1514
import warnings
1615
import json
@@ -107,7 +106,7 @@ def write_probeinterface(file: str | Path, probe_or_probegroup: Probe | ProbeGro
107106
tsv_label_map_to_probeinterface = {v: k for k, v in tsv_label_map_to_BIDS.items()}
108107

109108

110-
def read_BIDS_probe(folder: str | Path, prefix: Optional[str] = None) -> ProbeGroup:
109+
def read_BIDS_probe(folder: str | Path, prefix: str | None = None) -> ProbeGroup:
111110
"""
112111
Read to BIDS probe format.
113112
@@ -635,8 +634,8 @@ def read_3brain(file: str | Path, mea_pitch: float = None, electrode_width: floa
635634
def write_prb(
636635
file: str,
637636
probegroup: ProbeGroup,
638-
total_nb_channels: Optional[int] = None,
639-
radius: Optional[float] = None,
637+
total_nb_channels: int | None = None,
638+
radius: float | None = None,
640639
group_mode: str = "by_probe",
641640
):
642641
"""
@@ -663,9 +662,9 @@ def write_prb(
663662
The name of the file to be written
664663
probegroup: ProbeGroup
665664
The Probegroup to be used for writing
666-
total_nb_channels: Optional[int], default None
665+
total_nb_channels: int | None, default None
667666
***to do
668-
radius: Optional[float], default None
667+
radius: float | None, default None
669668
*** to do
670669
group_mode: str
671670
One of "by_probe" or "by_shank

src/probeinterface/library.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
from pathlib import Path
1515
from urllib.request import urlopen
1616
import requests
17-
from typing import Optional
1817

1918
from .io import read_probeinterface
19+
from .probe import Probe
2020

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

3838

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

6666

67-
def get_from_cache(manufacturer: str, probe_name: str, tag: Optional[str] = None) -> Optional["Probe"]:
67+
def get_from_cache(manufacturer: str, probe_name: str, tag: str | None = None) -> Probe | None:
6868
"""
6969
Get Probe from local cache
7070
@@ -104,8 +104,8 @@ def get_from_cache(manufacturer: str, probe_name: str, tag: Optional[str] = None
104104
def get_probe(
105105
manufacturer: str,
106106
probe_name: str,
107-
name: Optional[str] = None,
108-
tag: Optional[str] = None,
107+
name: str | None = None,
108+
tag: str | None = None,
109109
force_download: bool = False,
110110
) -> "Probe":
111111
"""

src/probeinterface/neuropixels_tools.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"""
99

1010
from pathlib import Path
11-
from typing import Union, Optional
1211
import warnings
1312
from packaging.version import parse
1413
import json
@@ -113,7 +112,7 @@ def get_probe_length(probe_part_number: str) -> int:
113112
return 10_000
114113

115114

116-
def make_mux_table_array(mux_information) -> np.array:
115+
def make_mux_table_array(mux_information) -> np.ndarray:
117116
"""
118117
Function to parse the mux_table from ProbeTable.
119118
@@ -209,7 +208,7 @@ def get_probe_contour_vertices(shank_width, tip_length, probe_length) -> list:
209208
return polygon_vertices
210209

211210

212-
def read_imro(file_path: Union[str, Path]) -> Probe:
211+
def read_imro(file_path: str | Path) -> Probe:
213212
"""
214213
Read probe position from the imro file used in input of SpikeGlx and Open-Ephys for neuropixels probes.
215214
@@ -570,7 +569,7 @@ def _annotate_probe_with_adc_sampling_info(probe: Probe, adc_sampling_table: str
570569
_annotate_contacts_from_mux_table(probe, adc_groups_array)
571570

572571

573-
def _read_imro_string(imro_str: str, imDatPrb_pn: Optional[str] = None) -> Probe:
572+
def _read_imro_string(imro_str: str, imDatPrb_pn: str | None = None) -> Probe:
574573
"""
575574
Parse the IMRO table when presented as a string and create a Probe object.
576575
@@ -1026,7 +1025,7 @@ def parse_spikeglx_snsGeomMap(meta):
10261025
# parse_spikeglx_snsGeomMap(meta)
10271026

10281027

1029-
def get_saved_channel_indices_from_spikeglx_meta(meta_file: str | Path) -> np.array:
1028+
def get_saved_channel_indices_from_spikeglx_meta(meta_file: str | Path) -> np.ndarray:
10301029
"""
10311030
Utils function to get the saved channels.
10321031
@@ -1066,7 +1065,7 @@ def _parse_openephys_settings(
10661065
settings_file: str | Path,
10671066
fix_x_position_for_oe_5: bool = True,
10681067
raise_error: bool = True,
1069-
) -> Optional[list[dict]]:
1068+
) -> list[dict] | None:
10701069
"""
10711070
Parse an Open Ephys settings.xml and extract per-probe metadata.
10721071
@@ -1395,11 +1394,11 @@ def _parse_openephys_settings(
13951394

13961395
def _select_openephys_probe_info(
13971396
probes_info: list[dict],
1398-
stream_name: Optional[str] = None,
1399-
probe_name: Optional[str] = None,
1400-
serial_number: Optional[str] = None,
1397+
stream_name: str | None = None,
1398+
probe_name: str | None = None,
1399+
serial_number: str | None = None,
14011400
raise_error: bool = True,
1402-
) -> Optional[dict]:
1401+
) -> dict | None:
14031402
"""
14041403
Select one probe's info dict from the list returned by `_parse_openephys_settings`.
14051404
@@ -1586,9 +1585,9 @@ def _annotate_openephys_probe(probe: Probe, probe_info: dict) -> None:
15861585

15871586
def read_openephys(
15881587
settings_file: str | Path,
1589-
stream_name: Optional[str] = None,
1590-
probe_name: Optional[str] = None,
1591-
serial_number: Optional[str] = None,
1588+
stream_name: str | None = None,
1589+
probe_name: str | None = None,
1590+
serial_number: str | None = None,
15921591
fix_x_position_for_oe_5: bool = True,
15931592
raise_error: bool = True,
15941593
) -> Probe:
@@ -1675,9 +1674,7 @@ def read_openephys(
16751674
return probe
16761675

16771676

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

0 commit comments

Comments
 (0)