From 0b2ac19982024f61cdcb4dc886e54ea813b962b6 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Tue, 19 Sep 2023 17:04:43 +0200 Subject: [PATCH 1/4] Fix Kilosort Phy reader docstrings --- .../extractors/phykilosortextractors.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/spikeinterface/extractors/phykilosortextractors.py b/src/spikeinterface/extractors/phykilosortextractors.py index c91aed644d..2769e03344 100644 --- a/src/spikeinterface/extractors/phykilosortextractors.py +++ b/src/spikeinterface/extractors/phykilosortextractors.py @@ -17,6 +17,10 @@ class BasePhyKilosortSortingExtractor(BaseSorting): Cluster groups to exclude (e.g. "noise" or ["noise", "mua"]). keep_good_only : bool, default: True Whether to only keep good units. + remove_empty_units : bool, default: True + If True, empty units are removed from the sorting extractor. + load_all_cluster_properties : bool, default: True + If True, all cluster properties are loaded from the tsv/csv files. """ extractor_name = "BasePhyKilosortSorting" @@ -197,18 +201,26 @@ class PhySortingExtractor(BasePhyKilosortSortingExtractor): Path to the output Phy folder (containing the params.py). exclude_cluster_groups: list or str, optional Cluster groups to exclude (e.g. "noise" or ["noise", "mua"]). + load_all_cluster_properties : bool, default: True + If True, all cluster properties are loaded from the tsv/csv files. Returns ------- extractor : PhySortingExtractor - The loaded data. + The loaded Sorting object. """ extractor_name = "PhySorting" name = "phy" - def __init__(self, folder_path, exclude_cluster_groups=None): - BasePhyKilosortSortingExtractor.__init__(self, folder_path, exclude_cluster_groups, keep_good_only=False) + def __init__(self, folder_path, exclude_cluster_groups=None, load_all_cluster_properties=True): + BasePhyKilosortSortingExtractor.__init__( + self, + folder_path, + exclude_cluster_groups, + keep_good_only=False, + load_all_cluster_properties=load_all_cluster_properties, + ) self._kwargs = { "folder_path": str(Path(folder_path).absolute()), @@ -223,8 +235,6 @@ class KiloSortSortingExtractor(BasePhyKilosortSortingExtractor): ---------- folder_path: str or Path Path to the output Phy folder (containing the params.py). - exclude_cluster_groups: list or str, optional - Cluster groups to exclude (e.g. "noise" or ["noise", "mua"]). keep_good_only : bool, default: True Whether to only keep good units. If True, only Kilosort-labeled 'good' units are returned. @@ -234,7 +244,7 @@ class KiloSortSortingExtractor(BasePhyKilosortSortingExtractor): Returns ------- extractor : KiloSortSortingExtractor - The loaded data. + The loaded Sorting object. """ extractor_name = "KiloSortSorting" From e3cb9bb14ee56e07cbc251556482b9a861d465a2 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Thu, 21 Sep 2023 12:00:26 +0200 Subject: [PATCH 2/4] Typing and docstrings --- .../extractors/phykilosortextractors.py | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/spikeinterface/extractors/phykilosortextractors.py b/src/spikeinterface/extractors/phykilosortextractors.py index 2769e03344..d32846dd79 100644 --- a/src/spikeinterface/extractors/phykilosortextractors.py +++ b/src/spikeinterface/extractors/phykilosortextractors.py @@ -1,3 +1,6 @@ +from __future__ import __annotations__ + +from typing import Optional, List from pathlib import Path import numpy as np @@ -13,7 +16,7 @@ class BasePhyKilosortSortingExtractor(BaseSorting): ---------- folder_path: str or Path Path to the output Phy folder (containing the params.py) - exclude_cluster_groups: list or str, optional + exclude_cluster_groups: list or str, default: None Cluster groups to exclude (e.g. "noise" or ["noise", "mua"]). keep_good_only : bool, default: True Whether to only keep good units. @@ -33,11 +36,11 @@ class BasePhyKilosortSortingExtractor(BaseSorting): def __init__( self, - folder_path, - exclude_cluster_groups=None, - keep_good_only=False, - remove_empty_units=False, - load_all_cluster_properties=True, + folder_path: Path | str, + exclude_cluster_groups: Optional[List[str] | str] = None, + keep_good_only: bool = False, + remove_empty_units: bool = False, + load_all_cluster_properties: bool = True, ): try: import pandas as pd @@ -199,7 +202,7 @@ class PhySortingExtractor(BasePhyKilosortSortingExtractor): ---------- folder_path: str or Path Path to the output Phy folder (containing the params.py). - exclude_cluster_groups: list or str, optional + exclude_cluster_groups: list or str, default: None Cluster groups to exclude (e.g. "noise" or ["noise", "mua"]). load_all_cluster_properties : bool, default: True If True, all cluster properties are loaded from the tsv/csv files. @@ -213,7 +216,12 @@ class PhySortingExtractor(BasePhyKilosortSortingExtractor): extractor_name = "PhySorting" name = "phy" - def __init__(self, folder_path, exclude_cluster_groups=None, load_all_cluster_properties=True): + def __init__( + self, + folder_path: Path | str, + exclude_cluster_groups: Optional[List[str] | str] = None, + load_all_cluster_properties: bool = True, + ): BasePhyKilosortSortingExtractor.__init__( self, folder_path, @@ -250,7 +258,7 @@ class KiloSortSortingExtractor(BasePhyKilosortSortingExtractor): extractor_name = "KiloSortSorting" name = "kilosort" - def __init__(self, folder_path, keep_good_only=False, remove_empty_units=True): + def __init__(self, folder_path: Path | str, keep_good_only: bool = False, remove_empty_units: bool = True): BasePhyKilosortSortingExtractor.__init__( self, folder_path, From 195f03c2a710dadc9978cc9f9369f571a7e31554 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Thu, 21 Sep 2023 12:17:12 +0200 Subject: [PATCH 3/4] oups --- src/spikeinterface/extractors/phykilosortextractors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spikeinterface/extractors/phykilosortextractors.py b/src/spikeinterface/extractors/phykilosortextractors.py index d32846dd79..96c0415c65 100644 --- a/src/spikeinterface/extractors/phykilosortextractors.py +++ b/src/spikeinterface/extractors/phykilosortextractors.py @@ -1,4 +1,4 @@ -from __future__ import __annotations__ +from __future__ import annotations from typing import Optional, List from pathlib import Path From 8e3324b77849a00467fc75f146663ee39201204c Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Thu, 21 Sep 2023 13:26:14 +0200 Subject: [PATCH 4/4] List -> list --- src/spikeinterface/extractors/phykilosortextractors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/spikeinterface/extractors/phykilosortextractors.py b/src/spikeinterface/extractors/phykilosortextractors.py index 96c0415c65..05aee160f5 100644 --- a/src/spikeinterface/extractors/phykilosortextractors.py +++ b/src/spikeinterface/extractors/phykilosortextractors.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Optional, List +from typing import Optional from pathlib import Path import numpy as np @@ -37,7 +37,7 @@ class BasePhyKilosortSortingExtractor(BaseSorting): def __init__( self, folder_path: Path | str, - exclude_cluster_groups: Optional[List[str] | str] = None, + exclude_cluster_groups: Optional[list[str] | str] = None, keep_good_only: bool = False, remove_empty_units: bool = False, load_all_cluster_properties: bool = True, @@ -219,7 +219,7 @@ class PhySortingExtractor(BasePhyKilosortSortingExtractor): def __init__( self, folder_path: Path | str, - exclude_cluster_groups: Optional[List[str] | str] = None, + exclude_cluster_groups: Optional[list[str] | str] = None, load_all_cluster_properties: bool = True, ): BasePhyKilosortSortingExtractor.__init__(