Skip to content

Commit

Permalink
Merge pull request #3153 from alejoe91/clean-extractor-class-attrs
Browse files Browse the repository at this point in the history
Remove unused legacy class name/mode from extractors
  • Loading branch information
alejoe91 authored Jul 5, 2024
2 parents 8a97e10 + 5b663ad commit e764147
Show file tree
Hide file tree
Showing 47 changed files with 32 additions and 280 deletions.
3 changes: 0 additions & 3 deletions src/spikeinterface/core/binaryfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ class BinaryFolderRecording(BinaryRecordingExtractor):
The recording
"""

mode = "folder"
name = "binaryfolder"

def __init__(self, folder_path):
folder_path = Path(folder_path)

Expand Down
3 changes: 0 additions & 3 deletions src/spikeinterface/core/binaryrecordingextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ class BinaryRecordingExtractor(BaseRecording):
The recording Extractor
"""

mode = "file"
name = "binary"

def __init__(
self,
file_paths,
Expand Down
3 changes: 0 additions & 3 deletions src/spikeinterface/core/npzsortingextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ class NpzSortingExtractor(BaseSorting):
All spike are store in two columns maner index+labels
"""

mode = "file"
name = "npz"

def __init__(self, file_path):
self.npz_filename = file_path

Expand Down
8 changes: 0 additions & 8 deletions src/spikeinterface/core/numpyextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class NumpyRecording(BaseRecording):
An optional list of channel_ids. If None, linear channels are assumed
"""

mode = "memory"
name = "numpy"

def __init__(self, traces_list, sampling_frequency, t_starts=None, channel_ids=None):
if isinstance(traces_list, list):
all_elements_are_list = all(isinstance(e, list) for e in traces_list)
Expand Down Expand Up @@ -142,9 +139,6 @@ class SharedMemoryRecording(BaseRecording):
If True, the main instance will unlink the sharedmem buffer when deleted
"""

mode = "memory"
name = "SharedMemory"

def __init__(
self, shm_names, shape_list, dtype, sampling_frequency, channel_ids=None, t_starts=None, main_shm_owner=True
):
Expand Down Expand Up @@ -252,8 +246,6 @@ class NumpySorting(BaseSorting):
A list of unit_ids.
"""

name = "numpy"

def __init__(self, spikes, sampling_frequency, unit_ids):
""" """
BaseSorting.__init__(self, sampling_frequency, unit_ids)
Expand Down
12 changes: 0 additions & 12 deletions src/spikeinterface/core/zarrextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ class ZarrRecordingExtractor(BaseRecording):
The recording Extractor
"""

installed = True
mode = "folder"
installation_mesg = ""
name = "zarr"

def __init__(self, folder_path: Path | str, storage_options: dict | None = None):
assert self.installed, self.installation_mesg

folder_path, folder_path_kwarg = resolve_zarr_path(folder_path)

Expand Down Expand Up @@ -167,13 +161,7 @@ class ZarrSortingExtractor(BaseSorting):
The sorting Extractor
"""

installed = True
mode = "folder"
installation_mesg = ""
name = "zarr"

def __init__(self, folder_path: Path | str, storage_options: dict | None = None, zarr_group: str | None = None):
assert self.installed, self.installation_mesg

folder_path, folder_path_kwarg = resolve_zarr_path(folder_path)

Expand Down
3 changes: 1 addition & 2 deletions src/spikeinterface/extractors/alfsortingextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ class ALFSortingExtractor(BaseSorting):
"""

installation_mesg = "To use the ALF extractors, install ONE-api: \n\n pip install ONE-api\n\n"
name = "alf"

def __init__(self, folder_path, sampling_frequency=30000):
try:
import one.alf.io as alfio
except ImportError as e:
except ImportError:
raise ImportError(self.installation_mesg)

self._folder_path = Path(folder_path)
Expand Down
4 changes: 1 addition & 3 deletions src/spikeinterface/extractors/cbin_ibl.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ class CompressedBinaryIblExtractor(BaseRecording):
The loaded data.
"""

mode = "folder"
installation_mesg = "To use the CompressedBinaryIblExtractor, install mtscomp: \n\n pip install mtscomp\n\n"
name = "cbin_ibl"

def __init__(self, folder_path=None, load_sync_channel=False, stream_name="ap", cbin_file=None):
from neo.rawio.spikeglxrawio import read_meta_file

try:
import mtscomp
except:
except ImportError:
raise ImportError(self.installation_mesg)
if cbin_file is None:
folder_path = Path(folder_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class CellExplorerSortingExtractor(BaseSorting):
Path to the `sessionInfo.mat` file. If None, it will be inferred from the file_path.
"""

mode = "file"
installation_mesg = "To use the CellExplorerSortingExtractor install pymatreader"

def __init__(
Expand Down
14 changes: 5 additions & 9 deletions src/spikeinterface/extractors/combinatoextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
from spikeinterface.core import BaseSorting, BaseSortingSegment
from spikeinterface.core.core_tools import define_function_from_class

try:
import h5py

HAVE_H5PY = True
except ImportError:
HAVE_H5PY = False


class CombinatoSortingExtractor(BaseSorting):
"""Load Combinato format data as a sorting extractor.
Expand All @@ -37,11 +30,14 @@ class CombinatoSortingExtractor(BaseSorting):
The loaded data.
"""

installed = HAVE_H5PY
installation_mesg = "To use the CombinatoSortingExtractor install h5py: \n\n pip install h5py\n\n"
name = "combinato"

def __init__(self, folder_path, sampling_frequency=None, user="simple", det_sign="both", keep_good_only=True):
try:
import h5py
except ImportError:
raise ImportError(self.installation_mesg)

folder_path = Path(folder_path)
assert folder_path.is_dir(), "Folder {} doesn't exist".format(folder_path)
if sampling_frequency is None:
Expand Down
49 changes: 0 additions & 49 deletions src/spikeinterface/extractors/extractorlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,52 +116,3 @@
event_extractor_full_list += neo_event_extractors_list

snippets_extractor_full_list = [NpySnippetsExtractor, WaveClusSnippetsExtractor]


recording_extractor_full_dict = {recext.name: recext for recext in recording_extractor_full_list}
sorting_extractor_full_dict = {recext.name: recext for recext in sorting_extractor_full_list}
snippets_extractor_full_dict = {recext.name: recext for recext in snippets_extractor_full_list}


def get_recording_extractor_from_name(name: str) -> Type[BaseRecording]:
"""
Returns the Recording Extractor class based on its name.
Parameters
----------
name: str
The Recording Extractor's name.
Returns
-------
recording_extractor: BaseRecording
The Recording Extractor class.
"""

for recording_extractor in recording_extractor_full_list:
if recording_extractor.__name__ == name:
return recording_extractor

raise ValueError(f"Recording extractor '{name}' not found.")


def get_sorting_extractor_from_name(name: str) -> Type[BaseSorting]:
"""
Returns the Sorting Extractor class based on its name.
Parameters
----------
name: str
The Sorting Extractor's name.
Returns
-------
sorting_extractor: BaseSorting
The Sorting Extractor class.
"""

for sorting_extractor in sorting_extractor_full_list:
if sorting_extractor.__name__ == name:
return sorting_extractor

raise ValueError(f"Sorting extractor '{name}' not found.")
3 changes: 0 additions & 3 deletions src/spikeinterface/extractors/hdsortextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ class HDSortSortingExtractor(MatlabHelper, BaseSorting):
The loaded data.
"""

mode = "file"
name = "hdsort"

def __init__(self, file_path, keep_good_only=True):
MatlabHelper.__init__(self, file_path)

Expand Down
19 changes: 5 additions & 14 deletions src/spikeinterface/extractors/herdingspikesextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
from spikeinterface.core import BaseSorting, BaseSortingSegment
from spikeinterface.core.core_tools import define_function_from_class

try:
import h5py

HAVE_HS2SX = True
except ImportError:
HAVE_HS2SX = False


class HerdingspikesSortingExtractor(BaseSorting):
"""Load HerdingSpikes format data as a sorting extractor.
Expand All @@ -31,15 +24,13 @@ class HerdingspikesSortingExtractor(BaseSorting):
The loaded data.
"""

installed = HAVE_HS2SX # check at class level if installed or not
mode = "file"
installation_mesg = (
"To use the HS2SortingExtractor install h5py: \n\n pip install h5py\n\n" # error message when not installed
)
name = "herdingspikes"
installation_mesg = "To use the HS2SortingExtractor install h5py: \n\n pip install h5py\n\n"

def __init__(self, file_path, load_unit_info=True):
assert self.installed, self.installation_mesg
try:
import h5py
except ImportError:
raise ImportError(self.installation_mesg)

self._recording_file = file_path
self._rf = h5py.File(self._recording_file, mode="r")
Expand Down
3 changes: 0 additions & 3 deletions src/spikeinterface/extractors/iblextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ class IblRecordingExtractor(BaseRecording):
The recording extractor which allows access to the traces.
"""

mode = "folder"
installation_mesg = "To use the IblRecordingSegment, install ibllib: \n\n pip install ONE-api\npip install ibllib\n"
name = "ibl_recording"

@staticmethod
def _get_default_one(cache_folder: Optional[Union[Path, str]] = None):
Expand Down Expand Up @@ -304,7 +302,6 @@ class IblSortingExtractor(BaseSorting):
The loaded data.
"""

name = "ibl"
installation_mesg = "IBL extractors require ibllib as a dependency." " To install, run: \n\n pip install ibllib\n\n"

def __init__(self, pid: str, good_clusters_only: bool = False, load_unit_properties: bool = True, one=None):
Expand Down
20 changes: 5 additions & 15 deletions src/spikeinterface/extractors/klustaextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
from spikeinterface.core import BaseRecording, BaseSorting, BaseRecordingSegment, BaseSortingSegment, read_python
from spikeinterface.core.core_tools import define_function_from_class

try:
import h5py

HAVE_H5PY = True
except ImportError:
HAVE_H5PY = False


# noinspection SpellCheckingInspection
class KlustaSortingExtractor(BaseSorting):
Expand All @@ -43,18 +36,15 @@ class KlustaSortingExtractor(BaseSorting):
The loaded data.
"""

installed = HAVE_H5PY # check at class level if installed or not
installation_mesg = (
"To use the KlustaSortingExtractor install h5py: \n\n pip install h5py\n\n" # error message when not installed
)
mode = "file_or_folder"
name = "klusta"
installation_mesg = "To use the KlustaSortingExtractor install h5py: \n\n pip install h5py\n\n"

default_cluster_groups = {0: "Noise", 1: "MUA", 2: "Good", 3: "Unsorted"}

def __init__(self, file_or_folder_path, exclude_cluster_groups=None):
assert HAVE_H5PY, self.installation_mesg
# ~ SortingExtractor.__init__(self)
try:
import h5py
except ImportError:
raise ImportError(self.installation_mesg)

kwik_file_or_folder = Path(file_or_folder_path)
kwikfile = None
Expand Down
2 changes: 0 additions & 2 deletions src/spikeinterface/extractors/mclustextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class MClustSortingExtractor(BaseSorting):
Loaded data.
"""

name = "mclust"

def __init__(self, folder_path, sampling_frequency, sampling_frequency_raw=None):
end_header_str = "%%ENDHEADER"
ext_list = ["t64", "t32", "t", "raw64", "raw32"]
Expand Down
8 changes: 1 addition & 7 deletions src/spikeinterface/extractors/mcsh5extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@ class MCSH5RecordingExtractor(BaseRecording):
The loaded data.
"""

mode = "file"
installation_mesg = (
"To use the MCSH5RecordingExtractor install h5py: \n\n pip install h5py\n\n" # error message when not installed
)
name = "mcsh5"
installation_mesg = "To use the MCSH5RecordingExtractor install h5py: \n\n pip install h5py\n\n"

def __init__(self, file_path, stream_id=0):

try:
import h5py

HAVE_MCSH5 = True
except ImportError:
raise ImportError(self.installation_mesg)

Expand Down
6 changes: 0 additions & 6 deletions src/spikeinterface/extractors/mdaextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class MdaRecordingExtractor(BaseRecording):
The loaded data.
"""

mode = "folder"
name = "mda"

def __init__(self, folder_path, raw_fname="raw.mda", params_fname="params.json", geom_fname="geom.csv"):
folder_path = Path(folder_path)
self._folder_path = folder_path
Expand Down Expand Up @@ -192,9 +189,6 @@ class MdaSortingExtractor(BaseSorting):
The loaded data.
"""

mode = "file"
name = "mda"

def __init__(self, file_path, sampling_frequency):
firings = readmda(str(Path(file_path).absolute()))
labels = firings[2, :]
Expand Down
2 changes: 0 additions & 2 deletions src/spikeinterface/extractors/neoextractors/alphaomega.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class AlphaOmegaRecordingExtractor(NeoBaseRecordingExtractor):
Load exhaustively all annotations from neo.
"""

mode = "folder"
NeoRawIOClass = "AlphaOmegaRawIO"
name = "alphaomega"

def __init__(self, folder_path, lsx_files=None, stream_id="RAW", stream_name=None, all_annotations=False):
neo_kwargs = self.map_to_neo_kwargs(folder_path, lsx_files)
Expand Down
2 changes: 0 additions & 2 deletions src/spikeinterface/extractors/neoextractors/axona.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class AxonaRecordingExtractor(NeoBaseRecordingExtractor):
Load exhaustively all annotations from neo.
"""

mode = "folder"
NeoRawIOClass = "AxonaRawIO"
name = "axona"

def __init__(self, file_path, all_annotations=False):
neo_kwargs = self.map_to_neo_kwargs(file_path)
Expand Down
2 changes: 0 additions & 2 deletions src/spikeinterface/extractors/neoextractors/biocam.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class BiocamRecordingExtractor(NeoBaseRecordingExtractor):
Load exhaustively all annotations from neo.
"""

mode = "file"
NeoRawIOClass = "BiocamRawIO"
name = "biocam"

def __init__(
self,
Expand Down
Loading

0 comments on commit e764147

Please sign in to comment.