77
88"""
99
10- from __future__ import annotations
11-
1210from pathlib import Path
13- from typing import Union , Optional
1411import warnings
1512from packaging .version import parse
1613import json
8582}
8683
8784
88- def _load_np_probe_features ():
85+ def _load_np_probe_features () -> dict :
8986 # this avoid loading the json several times
9087 global _np_probe_features
9188 if _np_probe_features is None :
@@ -348,7 +345,7 @@ def _build_canonical_contact_id(electrode_id: int, shank_id: int | None = None)
348345 return f"e{ electrode_id } "
349346
350347
351- def _annotate_contacts_from_mux_table (probe : Probe , adc_groups_array : np .array ) :
348+ def _annotate_contacts_from_mux_table (probe : Probe , adc_groups_array : np .ndarray ) -> None :
352349 """
353350 Annotate a Probe object with ADC group and sample order information based on the MUX table.
354351
@@ -399,7 +396,7 @@ def _annotate_contacts_from_mux_table(probe: Probe, adc_groups_array: np.array):
399396 probe .annotate_contacts (adc_sample_order = adc_sample_order )
400397
401398
402- def _annotate_probe_with_adc_sampling_info (probe : Probe , adc_sampling_table : str | None ):
399+ def _annotate_probe_with_adc_sampling_info (probe : Probe , adc_sampling_table : str | None ) -> None :
403400 """
404401 Annotate a Probe object with ADC group and sample order information based on the ADC sampling table.
405402
@@ -502,7 +499,7 @@ def _parse_imro_string(imro_table_string: str, probe_part_number: str) -> dict:
502499 return imro_per_channel
503500
504501
505- def write_imro (file : str | Path , probe : Probe ):
502+ def write_imro (file : str | Path , probe : Probe ) -> None :
506503 """
507504 save imro file (`.imrc`, imec readout) in a file.
508505 https://github.com/open-ephys-plugins/neuropixels-pxi/blob/master/Source/Formats/IMRO.h
@@ -706,7 +703,7 @@ def bank(ch, bankA, bankB):
706703 imro_per_channel ["channel" ] = list (range (384 ))
707704
708705
709- def read_imro (file_path : Union [ str , Path ] ) -> Probe :
706+ def read_imro (file_path : str | Path ) -> Probe :
710707 """
711708 Read a Neuropixels probe from an IMRO (Imec ReadOut) table file.
712709
@@ -717,7 +714,7 @@ def read_imro(file_path: Union[str, Path]) -> Probe:
717714
718715 Parameters
719716 ----------
720- file_path : Path or str
717+ file_path : str | Path
721718 The .imro file path
722719
723720 Returns
@@ -907,7 +904,7 @@ def parse_spikeglx_meta(meta_file: str | Path) -> dict:
907904 return meta
908905
909906
910- def parse_spikeglx_snsGeomMap (meta ) :
907+ def parse_spikeglx_snsGeomMap (meta : dict ) -> tuple [ int , float , float , np . ndarray , np . ndarray , np . ndarray , np . ndarray ] :
911908 """
912909 For some meta recent file.
913910 There is a field 'snsGeomMap' that can be used for gettiing geometry of contacts.
@@ -944,7 +941,7 @@ def parse_spikeglx_snsGeomMap(meta):
944941 return num_shank , shank_width , shank_pitch , shank_ids , x_pos , y_pos , activated
945942
946943
947- def get_saved_channel_indices_from_spikeglx_meta (meta_file : str | Path ) -> np .array :
944+ def get_saved_channel_indices_from_spikeglx_meta (meta_file : str | Path ) -> np .ndarray :
948945 """
949946 Utils function to get the saved channels.
950947
@@ -984,7 +981,7 @@ def _parse_openephys_settings(
984981 settings_file : str | Path ,
985982 fix_x_position_for_oe_5 : bool = True ,
986983 raise_error : bool = True ,
987- ) -> Optional [ list [dict ]] :
984+ ) -> list [dict ] | None :
988985 """
989986 Parse an Open Ephys settings.xml and extract per-probe metadata.
990987
@@ -1021,7 +1018,6 @@ def _parse_openephys_settings(
10211018 onebox_processor = None
10221019 onix_processor = None
10231020 channel_map = None
1024- record_node = None
10251021 channel_map_position = None
10261022 record_node_position = None
10271023 proc_counter = 0
@@ -1040,7 +1036,6 @@ def _parse_openephys_settings(
10401036 channel_map = processor
10411037 channel_map_position = proc_counter
10421038 if "Record Node" in name :
1043- record_node = processor
10441039 record_node_position = proc_counter
10451040 proc_counter += 1
10461041
@@ -1311,11 +1306,11 @@ def _parse_openephys_settings(
13111306
13121307def _select_openephys_probe_info (
13131308 probes_info : list [dict ],
1314- stream_name : Optional [ str ] = None ,
1315- probe_name : Optional [ str ] = None ,
1316- serial_number : Optional [ str ] = None ,
1309+ stream_name : str | None = None ,
1310+ probe_name : str | None = None ,
1311+ serial_number : str | None = None ,
13171312 raise_error : bool = True ,
1318- ) -> Optional [ dict ] :
1313+ ) -> dict | None :
13191314 """
13201315 Select one probe's info dict from the list returned by `_parse_openephys_settings`.
13211316
@@ -1502,9 +1497,9 @@ def _annotate_openephys_probe(probe: Probe, probe_info: dict) -> None:
15021497
15031498def read_openephys (
15041499 settings_file : str | Path ,
1505- stream_name : Optional [ str ] = None ,
1506- probe_name : Optional [ str ] = None ,
1507- serial_number : Optional [ str ] = None ,
1500+ stream_name : str | None = None ,
1501+ probe_name : str | None = None ,
1502+ serial_number : str | None = None ,
15081503 fix_x_position_for_oe_5 : bool = True ,
15091504 raise_error : bool = True ,
15101505) -> Probe :
@@ -1591,9 +1586,7 @@ def read_openephys(
15911586 return probe
15921587
15931588
1594- def get_saved_channel_indices_from_openephys_settings (
1595- settings_file : str | Path , stream_name : str
1596- ) -> Optional [np .array ]:
1589+ def get_saved_channel_indices_from_openephys_settings (settings_file : str | Path , stream_name : str ) -> np .ndarray | None :
15971590 """
15981591 Returns an array with the subset of saved channels indices (if used)
15991592
0 commit comments