diff --git a/doc/api.rst b/doc/api.rst index 5d3dc39a0c..d1e460a604 100755 --- a/doc/api.rst +++ b/doc/api.rst @@ -287,8 +287,6 @@ spikeinterface.comparison .. autofunction:: compare_sorter_to_ground_truth .. autofunction:: compare_templates .. autofunction:: compare_multiple_templates - .. autofunction:: create_hybrid_units_recording - .. autofunction:: create_hybrid_spikes_recording .. autoclass:: GroundTruthComparison :members: diff --git a/doc/get_started/quickstart.rst b/doc/get_started/quickstart.rst index 7b2b72a782..b5d3c2a985 100644 --- a/doc/get_started/quickstart.rst +++ b/doc/get_started/quickstart.rst @@ -247,7 +247,7 @@ object to disk. To reload a preprocessed recording that was saved to disk, you can use -``load_extractor()`` function from the ``core`` module. +``load()`` function from the ``core`` module. Now you are ready to spike sort using the ``spikeinterface.sorters`` module! Let’s first check which sorters are implemented and which are diff --git a/examples/get_started/quickstart.py b/examples/get_started/quickstart.py index 9eff361925..2481f8569f 100644 --- a/examples/get_started/quickstart.py +++ b/examples/get_started/quickstart.py @@ -159,7 +159,7 @@ print(recording_preprocessed) # - -# To reload a preprocessed recording that was saved to disk, you can use `load_extractor()` function from the `core` module. +# To reload a preprocessed recording that was saved to disk, you can use `load()` function from the `core` module. # # Now you are ready to spike sort using the `spikeinterface.sorters` module! # Let's first check which sorters are implemented and which are installed diff --git a/examples/tutorials/core/plot_1_recording_extractor.py b/examples/tutorials/core/plot_1_recording_extractor.py index 39520f2195..e3bfda5855 100644 --- a/examples/tutorials/core/plot_1_recording_extractor.py +++ b/examples/tutorials/core/plot_1_recording_extractor.py @@ -151,13 +151,13 @@ # The "dump" operation is lazy, i.e., the traces are not exported. # Only the information about how to reconstruct the recording are dumped: -from spikeinterface import load_extractor +from spikeinterface import load from pprint import pprint d = recording2.to_dict() pprint(d) -recording2_loaded = load_extractor(d) +recording2_loaded = load(d) print(recording2_loaded) ############################################################################### @@ -165,7 +165,7 @@ recording2.dump("my_recording.json") -recording2_loaded = load_extractor("my_recording.json") +recording2_loaded = load("my_recording.json") print(recording2_loaded) ############################################################################### @@ -181,5 +181,5 @@ pprint(os.listdir("./my_recording")) -recording2_cached = load_extractor("my_recording.json") +recording2_cached = load("my_recording.json") print(recording2_cached) diff --git a/examples/tutorials/core/plot_2_sorting_extractor.py b/examples/tutorials/core/plot_2_sorting_extractor.py index bf45e15aa7..b3ea82c77a 100644 --- a/examples/tutorials/core/plot_2_sorting_extractor.py +++ b/examples/tutorials/core/plot_2_sorting_extractor.py @@ -103,13 +103,13 @@ # The "dump" operation is lazy, i.e., the spike trains are not exported. # Only the information about how to reconstruct the sorting are dumped: -from spikeinterface import load_extractor +from spikeinterface import load from pprint import pprint d = sorting2.to_dict() pprint(d) -sorting2_loaded = load_extractor(d) +sorting2_loaded = load(d) print(sorting2_loaded) ############################################################################### @@ -117,7 +117,7 @@ sorting2.dump("my_sorting.json") -sorting2_loaded = load_extractor("my_sorting.json") +sorting2_loaded = load("my_sorting.json") print(sorting2_loaded) ############################################################################### @@ -133,5 +133,5 @@ pprint(os.listdir("./my_sorting")) -sorting2_cached = load_extractor("./my_sorting") +sorting2_cached = load("./my_sorting") print(sorting2_cached) diff --git a/src/spikeinterface/benchmark/benchmark_base.py b/src/spikeinterface/benchmark/benchmark_base.py index 3f861fff7c..a6e4932cb1 100644 --- a/src/spikeinterface/benchmark/benchmark_base.py +++ b/src/spikeinterface/benchmark/benchmark_base.py @@ -654,8 +654,6 @@ def load_folder(cls, folder): with open(file, mode="rb") as f: result[k] = pickle.load(f) elif format == "sorting": - from spikeinterface.core import load_extractor - sorting_folder = folder / k if sorting_folder.exists(): result[k] = load(sorting_folder) diff --git a/src/spikeinterface/comparison/__init__.py b/src/spikeinterface/comparison/__init__.py index f4ada19f73..b700adfb7b 100644 --- a/src/spikeinterface/comparison/__init__.py +++ b/src/spikeinterface/comparison/__init__.py @@ -32,11 +32,3 @@ from .groundtruthstudy import GroundTruthStudy from .collision import CollisionGTComparison from .correlogram import CorrelogramGTComparison - -from .hybrid import ( - HybridSpikesRecording, - HybridUnitsRecording, - generate_sorting_to_inject, - create_hybrid_units_recording, - create_hybrid_spikes_recording, -) diff --git a/src/spikeinterface/comparison/hybrid.py b/src/spikeinterface/comparison/hybrid.py deleted file mode 100644 index 25eb4fad0e..0000000000 --- a/src/spikeinterface/comparison/hybrid.py +++ /dev/null @@ -1,236 +0,0 @@ -import warnings - -from pathlib import Path -import numpy as np -from spikeinterface.core import ( - BaseRecording, - BaseSorting, - load_waveforms, -) -from spikeinterface.core.core_tools import define_function_from_class -from spikeinterface.core.generate import ( - generate_sorting, - InjectTemplatesRecording, - _ensure_seed, - generate_sorting_to_inject, -) - -# TODO aurelien : this is still using the WaveformExtractor!!! can you change it to use SortingAnalyzer ? - - -class HybridUnitsRecording(InjectTemplatesRecording): - """ - DEPRECATED, will be removed in 0.104.0 - - Class for creating a hybrid recording where additional units are added - to an existing recording. - - Parameters - ---------- - parent_recording : BaseRecording - Existing recording to add on top of. - templates : np.ndarray[n_units, n_samples, n_channels] - Array containing the templates to inject for all the units. - injected_sorting : BaseSorting | None: - The sorting for the injected units. - If None, will be generated using the following parameters. - nbefore : list[int] | int | None - Where is the center of the template for each unit? - If None, will default to the highest peak. - firing_rate : float - The firing rate of the injected units (in Hz). - amplitude_factor : np.ndarray | None: - The amplitude factor for each spike. - If None, will be generated as a gaussian centered at 1.0 and with an std of amplitude_std. - amplitude_std : float - The standard deviation of the amplitude (centered at 1.0). - refractory_period_ms : float - The refractory period of the injected spike train (in ms). - injected_sorting_folder : str | Path | None - If given, the injected sorting is saved to this folder. - It must be specified if injected_sorting is None or not serialisable to file. - seed : int, default: None - Random seed for amplitude_factor - - Returns - ------- - hybrid_units_recording : HybridUnitsRecording - The recording containing real and hybrid units. - """ - - def __init__( - self, - parent_recording: BaseRecording, - templates: np.ndarray, - injected_sorting: BaseSorting | None = None, - nbefore: list[int] | int | None = None, - firing_rate: float = 10, - amplitude_factor: np.ndarray | None = None, - amplitude_std: float = 0.0, - refractory_period_ms: float = 2.0, - injected_sorting_folder: str | Path | None = None, - seed=None, - ): - - warnings.warn( - "create_hybrid_units_recording() will be removed in 0.104.0 please use `spikeinterface.generation.hybrid_tools` instead", - DeprecationWarning, - stacklevel=2, - ) - - num_samples = [ - parent_recording.get_num_frames(seg_index) for seg_index in range(parent_recording.get_num_segments()) - ] - fs = parent_recording.sampling_frequency - n_units = len(templates) - - if injected_sorting is not None: - assert injected_sorting.get_num_units() == n_units - assert parent_recording.get_num_segments() == injected_sorting.get_num_segments() - else: - assert injected_sorting_folder is not None, "Provide sorting_folder to save generated sorting object" - durations = [ - parent_recording.get_num_frames(seg_index) / fs - for seg_index in range(parent_recording.get_num_segments()) - ] - injected_sorting = generate_sorting( - num_units=len(templates), - sampling_frequency=fs, - durations=durations, - firing_rates=firing_rate, - refractory_period_ms=refractory_period_ms, - ) - # save injected sorting if necessary - self.injected_sorting = injected_sorting - if not self.injected_sorting.check_serializability("json"): - # TODO later : also use pickle - assert injected_sorting_folder is not None, "Provide injected_sorting_folder to injected sorting object" - self.injected_sorting = self.injected_sorting.save(folder=injected_sorting_folder) - - if amplitude_factor is None: - seed = _ensure_seed(seed) - rng = np.random.default_rng(seed=seed) - num_spikes = self.injected_sorting.to_spike_vector().size - amplitude_factor = rng.normal(loc=1.0, scale=amplitude_std, size=num_spikes) - - InjectTemplatesRecording.__init__( - self, self.injected_sorting, templates, nbefore, amplitude_factor, parent_recording, num_samples - ) - - self._kwargs = dict( - parent_recording=parent_recording, - templates=templates, - injected_sorting=self.injected_sorting, - nbefore=nbefore, - firing_rate=firing_rate, - amplitude_factor=amplitude_factor, - amplitude_std=amplitude_std, - refractory_period_ms=refractory_period_ms, - injected_sorting_folder=None, - seed=seed, - ) - - -class HybridSpikesRecording(InjectTemplatesRecording): - """ - DEPRECATED, will be removed in 0.104.0 - - Class for creating a hybrid recording where additional spikes are added - to already existing units. - - Parameters - ---------- - wvf_extractor : WaveformExtractor - The waveform extractor object of the existing recording. - injected_sorting : BaseSorting | None - Additional spikes to inject. - If None, will generate it. - max_injected_per_unit : int - If injected_sorting=None, the max number of spikes per unit - that is allowed to be injected. - unit_ids : list[int] | None - unit_ids to take in the wvf_extractor for spikes injection. - injected_rate : float - If injected_sorting=None, the max fraction of spikes per - unit that is allowed to be injected. - refractory_period_ms : float - If injected_sorting=None, the injected spikes need to respect - this refractory period. - injected_sorting_folder : str | Path | None - If given, the injected sorting is saved to this folder. - It must be specified if injected_sorting is None or not serializable to file. - - Returns - ------- - hybrid_spikes_recording : HybridSpikesRecording: - The recording containing units with real and hybrid spikes. - """ - - def __init__( - self, - wvf_extractor, - injected_sorting: BaseSorting | None = None, - unit_ids: list[int] | None = None, - max_injected_per_unit: int = 1000, - injected_rate: float = 0.05, - refractory_period_ms: float = 1.5, - injected_sorting_folder: str | Path | None = None, - ) -> None: - - warnings.warn( - "create_hybrid_spikes_recording() will be removed in 0.104.0 please use `spikeinterface.generation.hybrid_tools` instead", - DeprecationWarning, - stacklevel=2, - ) - - if isinstance(wvf_extractor, (Path, str)): - wvf_extractor = load_waveforms(wvf_extractor) - - target_recording = wvf_extractor.recording - target_sorting = wvf_extractor.sorting - templates = wvf_extractor.get_all_templates() - - if unit_ids is not None: - target_sorting = target_sorting.select_units(unit_ids) - templates = templates[target_sorting.ids_to_indices(unit_ids)] - - if injected_sorting is None: - assert ( - injected_sorting_folder is not None - ), "Provide injected_sorting_folder to save generated injected sorting object" - num_samples = [ - target_recording.get_num_frames(seg_index) for seg_index in range(target_recording.get_num_segments()) - ] - self.injected_sorting = generate_sorting_to_inject( - target_sorting, num_samples, max_injected_per_unit, injected_rate, refractory_period_ms - ) - else: - self.injected_sorting = injected_sorting - - # save injected sorting if necessary - if not self.injected_sorting.check_serializability("json"): - # TODO later : also use pickle - assert injected_sorting_folder is not None, "Provide injected_sorting_folder to injected sorting object" - self.injected_sorting = self.injected_sorting.save(folder=injected_sorting_folder) - - InjectTemplatesRecording.__init__( - self, self.injected_sorting, templates, wvf_extractor.nbefore, parent_recording=target_recording - ) - - self._kwargs = dict( - wvf_extractor=str(wvf_extractor.folder.absolute()), - injected_sorting=self.injected_sorting, - unit_ids=unit_ids, - max_injected_per_unit=max_injected_per_unit, - injected_rate=injected_rate, - refractory_period_ms=refractory_period_ms, - injected_sorting_folder=None, - ) - - -create_hybrid_units_recording = define_function_from_class( - source_class=HybridUnitsRecording, name="create_hybrid_units_recording" -) -create_hybrid_spikes_recording = define_function_from_class( - source_class=HybridSpikesRecording, name="create_hybrid_spikes_recording" -) diff --git a/src/spikeinterface/comparison/tests/test_hybrid.py b/src/spikeinterface/comparison/tests/test_hybrid.py deleted file mode 100644 index cbcb8c01d4..0000000000 --- a/src/spikeinterface/comparison/tests/test_hybrid.py +++ /dev/null @@ -1,96 +0,0 @@ -import pytest -import shutil -from pathlib import Path -from spikeinterface.core import extract_waveforms, load_waveforms, load -from spikeinterface.core.testing import check_recordings_equal -from spikeinterface.comparison import ( - create_hybrid_units_recording, - create_hybrid_spikes_recording, -) -from spikeinterface.extractors import toy_example -from spikeinterface.preprocessing import bandpass_filter - - -@pytest.fixture(scope="module") -def setup_module(tmp_path_factory): - cache_folder = tmp_path_factory.mktemp("cache_folder") - if cache_folder.is_dir(): - shutil.rmtree(cache_folder) - cache_folder.mkdir(parents=True, exist_ok=True) - recording, sorting = toy_example( - duration=60, num_channels=4, num_units=5, num_segments=2, average_peak_amplitude=-1000 - ) - recording = bandpass_filter(recording, freq_min=300, freq_max=6000) - recording = recording.save(folder=cache_folder / "recording") - sorting = sorting.save(folder=cache_folder / "sorting") - - wvf_extractor = extract_waveforms( - recording, sorting, folder=cache_folder / "wvf_extractor", ms_before=10.0, ms_after=10.0 - ) - return cache_folder - - -def test_hybrid_units_recording(setup_module): - cache_folder = setup_module - wvf_extractor = load_waveforms(cache_folder / "wvf_extractor") - print(wvf_extractor) - print(wvf_extractor.sorting_analyzer) - - recording = wvf_extractor.recording - templates = wvf_extractor.get_all_templates() - templates[:, 0, :] = 0 - templates[:, -1, :] = 0 - hybrid_units_recording = create_hybrid_units_recording( - recording, templates, nbefore=wvf_extractor.nbefore, injected_sorting_folder=cache_folder / "injected0" - ) - - assert hybrid_units_recording.get_traces(end_frame=600, segment_index=0).shape == (600, 4) - assert hybrid_units_recording.get_traces(start_frame=100, end_frame=600, segment_index=1).shape == (500, 4) - assert hybrid_units_recording.get_traces(start_frame=recording.get_num_frames(0) - 200, segment_index=0).shape == ( - 200, - 4, - ) - - # Check dumpability - saved_loaded = load(hybrid_units_recording.to_dict()) - check_recordings_equal(hybrid_units_recording, saved_loaded, return_in_uV=False) - - saved_1job = hybrid_units_recording.save(folder=cache_folder / "units_1job") - saved_2job = hybrid_units_recording.save(folder=cache_folder / "units_2job", n_jobs=2, chunk_duration="1s") - check_recordings_equal(hybrid_units_recording, saved_1job, return_in_uV=False) - check_recordings_equal(hybrid_units_recording, saved_2job, return_in_uV=False) - - -def test_hybrid_spikes_recording(setup_module): - cache_folder = setup_module - wvf_extractor = load_waveforms(cache_folder / "wvf_extractor") - recording = wvf_extractor.recording - sorting = wvf_extractor.sorting - hybrid_spikes_recording = create_hybrid_spikes_recording( - wvf_extractor, injected_sorting_folder=cache_folder / "injected1" - ) - hybrid_spikes_recording = create_hybrid_spikes_recording( - wvf_extractor, unit_ids=sorting.unit_ids[:3], injected_sorting_folder=cache_folder / "injected2" - ) - - assert hybrid_spikes_recording.get_traces(end_frame=600, segment_index=0).shape == (600, 4) - assert hybrid_spikes_recording.get_traces(start_frame=100, end_frame=600, segment_index=1).shape == (500, 4) - assert hybrid_spikes_recording.get_traces(start_frame=recording.get_num_frames(0) - 200, segment_index=0).shape == ( - 200, - 4, - ) - - # Check dumpability - saved_loaded = load(hybrid_spikes_recording.to_dict()) - check_recordings_equal(hybrid_spikes_recording, saved_loaded, return_in_uV=False) - - saved_1job = hybrid_spikes_recording.save(folder=cache_folder / "spikes_1job") - saved_2job = hybrid_spikes_recording.save(folder=cache_folder / "spikes_2job", n_jobs=2, chunk_duration="1s") - check_recordings_equal(hybrid_spikes_recording, saved_1job, return_in_uV=False) - check_recordings_equal(hybrid_spikes_recording, saved_2job, return_in_uV=False) - - -if __name__ == "__main__": - setup_module() - test_hybrid_units_recording() - test_hybrid_spikes_recording() diff --git a/src/spikeinterface/core/__init__.py b/src/spikeinterface/core/__init__.py index 24c64162ee..168494caf7 100644 --- a/src/spikeinterface/core/__init__.py +++ b/src/spikeinterface/core/__init__.py @@ -4,7 +4,7 @@ from .basesnippets import BaseSnippets, BaseSnippetsSegment from .baserecordingsnippets import BaseRecordingSnippets -from .loading import load, load_extractor +from .loading import load # main extractor from dump and cache from .binaryrecordingextractor import BinaryRecordingExtractor, read_binary diff --git a/src/spikeinterface/core/job_tools.py b/src/spikeinterface/core/job_tools.py index 640c7d54aa..4bb1356769 100644 --- a/src/spikeinterface/core/job_tools.py +++ b/src/spikeinterface/core/job_tools.py @@ -119,17 +119,6 @@ def fix_job_kwargs(runtime_job_kwargs): # in this case this will be the global job_kwargs runtime_job_kwargs = dict() - # deprecation with backward compatibility - # this can be removed in 0.104.0 - if "max_threads_per_process" in runtime_job_kwargs: - runtime_job_kwargs = runtime_job_kwargs.copy() - runtime_job_kwargs["max_threads_per_worker"] = runtime_job_kwargs.pop("max_threads_per_process") - warnings.warn( - "job_kwargs: max_threads_per_process was changed to max_threads_per_worker, max_threads_per_process will be removed in 0.104", - DeprecationWarning, - stacklevel=2, - ) - for k in runtime_job_kwargs: assert k in job_keys, ( f"{k} is not a valid job keyword argument. " f"Available keyword arguments are: {list(job_keys)}" diff --git a/src/spikeinterface/core/loading.py b/src/spikeinterface/core/loading.py index 8fec7ebf77..4242473fd5 100644 --- a/src/spikeinterface/core/loading.py +++ b/src/spikeinterface/core/loading.py @@ -127,15 +127,6 @@ def load( return loaded_object -def load_extractor(file_or_folder_or_dict, base_folder=None) -> "BaseExtractor": - warnings.warn( - "load_extractor() is deprecated and will be removed in version 0.104.0. Please use load() instead.", - DeprecationWarning, - stacklevel=2, - ) - return load(file_or_folder_or_dict, base_folder=base_folder) - - def _guess_object_from_dict(d): """ When an object is read from json or pickle or zarr attr we can guess which object it is diff --git a/src/spikeinterface/core/numpyextractors.py b/src/spikeinterface/core/numpyextractors.py index 52829f2a3a..1200612864 100644 --- a/src/spikeinterface/core/numpyextractors.py +++ b/src/spikeinterface/core/numpyextractors.py @@ -364,23 +364,6 @@ def from_times_and_labels(times_list, labels_list, sampling_frequency, unit_ids= sample_list = [np.round(t * sampling_frequency).astype("int64") for t in times_list] return NumpySorting.from_samples_and_labels(sample_list, labels_list, sampling_frequency, unit_ids) - @staticmethod - def from_times_labels(times_list, labels_list, sampling_frequency, unit_ids=None) -> "NumpySorting": - warning_msg = ( - "`from_times_labels` is deprecated and will be removed in 0.104.0. Note this function requires" - "samples rather than times so should not be used for clarity purposes. For those working in samples please" - "use `from_samples_and_labels` instead. For those working in time units (seconds) please use " - "`from_times_and_labels` instead." - ) - - warnings.warn( - warning_msg, - DeprecationWarning, - stacklevel=2, - ) - # despite the naming of the original function this required samples - return NumpySorting.from_samples_and_labels(times_list, labels_list, sampling_frequency, unit_ids) - @staticmethod def from_unit_dict(units_dict_list, sampling_frequency) -> "NumpySorting": """ diff --git a/src/spikeinterface/core/tests/test_sorting_folder.py b/src/spikeinterface/core/tests/test_sorting_folder.py index 0fe19534ec..a285ae8d29 100644 --- a/src/spikeinterface/core/tests/test_sorting_folder.py +++ b/src/spikeinterface/core/tests/test_sorting_folder.py @@ -3,7 +3,7 @@ import numpy as np -from spikeinterface.core import NpzFolderSorting, NumpyFolderSorting, load_extractor +from spikeinterface.core import NpzFolderSorting, NumpyFolderSorting from spikeinterface.core import generate_sorting from spikeinterface.core.testing import check_sorted_arrays_equal, check_sortings_equal diff --git a/src/spikeinterface/extractors/__init__.py b/src/spikeinterface/extractors/__init__.py index 216c668e0e..75879528bb 100644 --- a/src/spikeinterface/extractors/__init__.py +++ b/src/spikeinterface/extractors/__init__.py @@ -3,7 +3,6 @@ from .toy_example import toy_example as toy_example from .bids import read_bids as read_bids -from .neuropixels_utils import get_neuropixels_channel_groups, get_neuropixels_sample_shifts from .neoextractors import get_neo_num_blocks, get_neo_streams from .phykilosortextractors import read_kilosort_as_analyzer diff --git a/src/spikeinterface/extractors/neoextractors/openephys.py b/src/spikeinterface/extractors/neoextractors/openephys.py index 1d16df534b..c6774e622e 100644 --- a/src/spikeinterface/extractors/neoextractors/openephys.py +++ b/src/spikeinterface/extractors/neoextractors/openephys.py @@ -73,15 +73,7 @@ def __init__( block_index=None, all_annotations: bool = False, use_names_as_ids: bool = False, - ignore_timestamps_errors: bool = None, ): - if ignore_timestamps_errors is not None: - dep_msg = "OpenEphysLegacyRecordingExtractor: `ignore_timestamps_errors` is deprecated. It will be removed in version 0.104.0 and is currently ignored" - warnings.warn( - dep_msg, - DeprecationWarning, - stacklevel=2, - ) neo_kwargs = self.map_to_neo_kwargs(folder_path) NeoBaseRecordingExtractor.__init__( self, diff --git a/src/spikeinterface/extractors/neuropixels_utils.py b/src/spikeinterface/extractors/neuropixels_utils.py index 6c0a690719..9ecb71b414 100644 --- a/src/spikeinterface/extractors/neuropixels_utils.py +++ b/src/spikeinterface/extractors/neuropixels_utils.py @@ -56,128 +56,6 @@ def get_neuropixels_sample_shifts_from_probe(probe: Probe, stream_name: str = "a return sample_shifts -def get_neuropixels_sample_shifts( - num_channels: int = 384, num_channels_per_adc: int = 12, num_cycles: int | None = None -) -> np.ndarray: - """ - DEPRECATED - Calculate the relative sampling phase (inter-sample shifts) for each channel - in Neuropixels probes due to ADC multiplexing. - - Neuropixels probes sample channels sequentially through multiple ADCs, - introducing slight temporal delays between channels within each sampling cycle. - These inter-sample shifts are fractions of the sampling period and are crucial - to consider during preprocessing steps, such as phase correction, to ensure - accurate alignment of the recorded signals. - - This function computes these relative phase shifts, returning an array where - each value represents the fractional delay (ranging from 0 to 1) for the - corresponding channel. - - Parameters - ---------- - num_channels : int, default: 384 - Total number of channels in the recording. - Neuropixels probes typically have 384 channels. - num_channels_per_adc : int, default: 12 - Number of channels assigned to each ADC on the probe. - Neuropixels 1.0 probes have 32 ADCs, each handling 12 channels. - Neuropixels 2.0 probes have 24 ADCs, each handling 16 channels. - num_cycles : int or None, default: None - Number of cycles in the ADC sampling sequence. - Neuropixels 1.0 probes have 13 cycles for AP (action potential) signals - and 12 for LFP (local field potential) signals. - Neuropixels 2.0 probes have 16 cycles. - If None, defaults to the value of `num_channels_per_adc`. - - Returns - ------- - sample_shifts : np.ndarray - Array of relative phase shifts for each channel, with values ranging from 0 to 1, - representing the fractional delay within the sampling period due to sequential ADC sampling. - """ - warnings.warn( - "`get_neuropixels_sample_shifts` is deprecated and will be removed in 0.104.0. " - "Use `get_neuropixels_sample_shifts_from_probe` instead.", - DeprecationWarning, - stacklevel=2, - ) - if num_cycles is None: - num_cycles = num_channels_per_adc - - adc_indices = np.floor(np.arange(num_channels) / (num_channels_per_adc * 2)) * 2 + np.mod( - np.arange(num_channels), 2 - ) - - sample_shifts = np.zeros_like(adc_indices) - - for adc_index in adc_indices: - sample_shifts[adc_indices == adc_index] = np.arange(num_channels_per_adc) / num_cycles - return sample_shifts - - -def get_neuropixels_channel_groups(num_channels=384, num_channels_per_adc=12): - """ - DEPRECATED - Returns groups of simultaneously sampled channels on a Neuropixels probe. - - The Neuropixels ADC sampling pattern is as follows: - - Channels: ADCs: - ||| ||| - ... ... - 26 27 2 3 - 24 25 2 3 - 22 23 0 1 - ... ... - 2 3 0 1 - 0 1 0 1 <-- even and odd channels are digitized by separate ADCs - ||| ||| - V V - - This information is needed to perform the preprocessing.common_reference operation - on channels that are sampled synchronously. - - Parameters - ---------- - num_channels : int, default: 384 - The total number of channels in a recording. - All currently available Neuropixels variants have 384 channels. - num_channels_per_adc : int, default: 12 - The number of channels per ADC on the probe. - Neuropixels 1.0 probes have 32 ADCs, each handling 12 channels. - Neuropixels 2.0 probes have 24 ADCs, each handling 16 channels. - - Returns - ------- - groups : list - A list of lists of simultaneously sampled channel indices - """ - warnings.warn( - "`get_neuropixels_channel_groups` is deprecated and will be removed in 0.104.0. " - "Use the `adc_group` contact annotation from the `Probe` instead.", - DeprecationWarning, - stacklevel=2, - ) - groups = [] - - for i in range(num_channels_per_adc): - groups.append( - list( - np.sort( - np.concatenate( - [ - np.arange(i * 2, num_channels, num_channels_per_adc * 2), - np.arange(i * 2 + 1, num_channels, num_channels_per_adc * 2), - ] - ) - ) - ) - ) - - return groups - - def synchronize_neuropixel_streams(recording_ref, recording_other): """ Use the last "sync" channel from spikeglx or openephys neuropixels to synchronize diff --git a/src/spikeinterface/postprocessing/template_similarity.py b/src/spikeinterface/postprocessing/template_similarity.py index b0e21492dc..3f5699d955 100644 --- a/src/spikeinterface/postprocessing/template_similarity.py +++ b/src/spikeinterface/postprocessing/template_similarity.py @@ -55,13 +55,6 @@ def _handle_backward_compatibility_on_load(self): self.params["support"] = "union" def _set_params(self, method="cosine", max_lag_ms=0, support="union"): - if method == "cosine_similarity": - warnings.warn( - "The method 'cosine_similarity' is deprecated and will be removed in the next version. Use 'cosine' instead.", - DeprecationWarning, - stacklevel=2, - ) - method = "cosine" params = dict(method=method, max_lag_ms=max_lag_ms, support=support) return params diff --git a/src/spikeinterface/sorters/internal/simplesorter.py b/src/spikeinterface/sorters/internal/simplesorter.py index 28847367da..5cedcf3945 100644 --- a/src/spikeinterface/sorters/internal/simplesorter.py +++ b/src/spikeinterface/sorters/internal/simplesorter.py @@ -1,6 +1,6 @@ from .si_based import ComponentsBasedSorter -from spikeinterface.core import load_extractor, BaseRecording, get_noise_levels, extract_waveforms, NumpySorting +from spikeinterface.core import BaseRecording, get_noise_levels, extract_waveforms, NumpySorting from spikeinterface.core.job_tools import fix_job_kwargs from spikeinterface.sortingcomponents.tools import cache_preprocessing from spikeinterface.preprocessing import bandpass_filter, common_reference, zscore diff --git a/src/spikeinterface/widgets/amplitudes.py b/src/spikeinterface/widgets/amplitudes.py index 00b2cb7327..49e8f0d24a 100644 --- a/src/spikeinterface/widgets/amplitudes.py +++ b/src/spikeinterface/widgets/amplitudes.py @@ -58,26 +58,9 @@ def __init__( plot_histograms=False, bins=None, plot_legend=True, - segment_index=None, backend=None, **backend_kwargs, ): - import warnings - - # Handle deprecation of segment_index parameter - if segment_index is not None: - warnings.warn( - "The 'segment_index' parameter is deprecated and will be removed in a future version. " - "Use 'segment_indices' instead.", - DeprecationWarning, - stacklevel=2, - ) - if segment_indices is None: - if isinstance(segment_index, int): - segment_indices = [segment_index] - else: - segment_indices = segment_index - sorting_analyzer = self.ensure_sorting_analyzer(sorting_analyzer) sorting = sorting_analyzer.sorting self.check_extensions(sorting_analyzer, "spike_amplitudes") diff --git a/src/spikeinterface/widgets/motion.py b/src/spikeinterface/widgets/motion.py index a05e92d3aa..831bd74352 100644 --- a/src/spikeinterface/widgets/motion.py +++ b/src/spikeinterface/widgets/motion.py @@ -159,24 +159,9 @@ def __init__( backend: str | None = None, **backend_kwargs, ): - import warnings from matplotlib.pyplot import colormaps from matplotlib.colors import Normalize - # Handle deprecation of segment_index parameter - if segment_index is not None: - warnings.warn( - "The 'segment_index' parameter is deprecated and will be removed in a future version. " - "Use 'segment_indices' instead.", - DeprecationWarning, - stacklevel=2, - ) - if segment_indices is None: - if isinstance(segment_index, int): - segment_indices = [segment_index] - else: - segment_indices = segment_index - assert peaks is not None or sorting_analyzer is not None if peaks is not None: diff --git a/src/spikeinterface/widgets/rasters.py b/src/spikeinterface/widgets/rasters.py index 5aa654fac9..1ddde77bf9 100644 --- a/src/spikeinterface/widgets/rasters.py +++ b/src/spikeinterface/widgets/rasters.py @@ -375,26 +375,8 @@ def __init__( backend: str | None = None, sorting: BaseSorting | None = None, sorting_analyzer: SortingAnalyzer | None = None, - segment_index: int | None = None, **backend_kwargs, ): - - import warnings - - # Handle deprecation of segment_index parameter - if segment_index is not None: - warnings.warn( - "The 'segment_index' parameter is deprecated and will be removed in a future version. " - "Use 'segment_indices' instead.", - DeprecationWarning, - stacklevel=2, - ) - if segment_indices is None: - if isinstance(segment_index, int): - segment_indices = [segment_index] - else: - segment_indices = segment_index - if sorting is not None: # When removed, make `sorting_analyzer_or_sorting` a required argument rather than None. deprecation_msg = "`sorting` argument is deprecated and will be removed in version 0.105.0. Please use `sorting_analyzer_or_sorting` instead" diff --git a/src/spikeinterface/widgets/sorting_summary.py b/src/spikeinterface/widgets/sorting_summary.py index 76cd5469b7..87c5b9d2d8 100644 --- a/src/spikeinterface/widgets/sorting_summary.py +++ b/src/spikeinterface/widgets/sorting_summary.py @@ -1,7 +1,5 @@ import numpy as np -import warnings - from .base import BaseWidget, to_attr from .amplitudes import AmplitudesWidget @@ -79,18 +77,8 @@ def __init__( curation_dict=None, label_definitions=None, backend=None, - unit_table_properties=None, **backend_kwargs, ): - - if unit_table_properties is not None: - warnings.warn( - "plot_sorting_summary() : `unit_table_properties` is deprecated and will be removed in version 0.104.0, use `displayed_unit_properties` instead", - category=DeprecationWarning, - stacklevel=2, - ) - displayed_unit_properties = unit_table_properties - sorting_analyzer = self.ensure_sorting_analyzer(sorting_analyzer) self.check_extensions( sorting_analyzer, ["correlograms", "spike_amplitudes", "unit_locations", "template_similarity"]