From 9802c34f78081b63e5d953fb0601cd6e079ce7cf Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 23 Jul 2024 08:33:50 -0400 Subject: [PATCH 1/6] add `is_filtered` to annotations --- src/spikeinterface/core/baserecording.py | 1 + src/spikeinterface/core/binaryrecordingextractor.py | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/spikeinterface/core/baserecording.py b/src/spikeinterface/core/baserecording.py index e65afabaca..03db6bd9af 100644 --- a/src/spikeinterface/core/baserecording.py +++ b/src/spikeinterface/core/baserecording.py @@ -549,6 +549,7 @@ def _save(self, format="binary", verbose: bool = False, **save_kwargs): channel_ids=self.get_channel_ids(), time_axis=0, file_offset=0, + is_filtered=self.is_filtered(), gain_to_uV=self.get_channel_gains(), offset_to_uV=self.get_channel_offsets(), ) diff --git a/src/spikeinterface/core/binaryrecordingextractor.py b/src/spikeinterface/core/binaryrecordingextractor.py index a0e349728e..8f542647f1 100644 --- a/src/spikeinterface/core/binaryrecordingextractor.py +++ b/src/spikeinterface/core/binaryrecordingextractor.py @@ -65,13 +65,9 @@ def __init__( gain_to_uV=None, offset_to_uV=None, is_filtered=None, - num_chan=None, ): - # This assigns num_channels if num_channels is not None, otherwise num_chan is assigned - num_channels = num_channels or num_chan + assert num_channels is not None, "You must provide num_channels or num_chan" - if num_chan is not None: - warnings.warn("`num_chan` is to be deprecated in version 0.100, please use `num_channels` instead") if channel_ids is None: channel_ids = list(range(num_channels)) From 309be48e5b38ad56c0ab2cf25c2e359f3058b7f2 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 23 Jul 2024 08:40:09 -0400 Subject: [PATCH 2/6] fix test for deprecation --- src/spikeinterface/core/tests/test_binaryrecordingextractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spikeinterface/core/tests/test_binaryrecordingextractor.py b/src/spikeinterface/core/tests/test_binaryrecordingextractor.py index ea5edc6e6e..7d90c48947 100644 --- a/src/spikeinterface/core/tests/test_binaryrecordingextractor.py +++ b/src/spikeinterface/core/tests/test_binaryrecordingextractor.py @@ -94,7 +94,7 @@ def test_sequential_reading_of_small_traces(folder_with_binary_files): file_paths = [folder / "traces_cached_seg0.raw"] recording = BinaryRecordingExtractor( - num_chan=num_channels, + num_channels=num_channels, file_paths=file_paths, sampling_frequency=sampling_frequency, dtype=dtype, From e5e0dd206dce9b51065893b1ebb2d3ef2b1709ed Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:06:25 -0400 Subject: [PATCH 3/6] Revert "add `is_filtered` to annotations" This reverts commit 9802c34f78081b63e5d953fb0601cd6e079ce7cf. --- src/spikeinterface/core/baserecording.py | 1 - src/spikeinterface/core/binaryrecordingextractor.py | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/spikeinterface/core/baserecording.py b/src/spikeinterface/core/baserecording.py index 03db6bd9af..e65afabaca 100644 --- a/src/spikeinterface/core/baserecording.py +++ b/src/spikeinterface/core/baserecording.py @@ -549,7 +549,6 @@ def _save(self, format="binary", verbose: bool = False, **save_kwargs): channel_ids=self.get_channel_ids(), time_axis=0, file_offset=0, - is_filtered=self.is_filtered(), gain_to_uV=self.get_channel_gains(), offset_to_uV=self.get_channel_offsets(), ) diff --git a/src/spikeinterface/core/binaryrecordingextractor.py b/src/spikeinterface/core/binaryrecordingextractor.py index 8f542647f1..a0e349728e 100644 --- a/src/spikeinterface/core/binaryrecordingextractor.py +++ b/src/spikeinterface/core/binaryrecordingextractor.py @@ -65,9 +65,13 @@ def __init__( gain_to_uV=None, offset_to_uV=None, is_filtered=None, + num_chan=None, ): - + # This assigns num_channels if num_channels is not None, otherwise num_chan is assigned + num_channels = num_channels or num_chan assert num_channels is not None, "You must provide num_channels or num_chan" + if num_chan is not None: + warnings.warn("`num_chan` is to be deprecated in version 0.100, please use `num_channels` instead") if channel_ids is None: channel_ids = list(range(num_channels)) From 66d7fcb31ae17e301003cc6df46e3317877e9b69 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:12:11 -0400 Subject: [PATCH 4/6] include num_chan for backward compatibility --- src/spikeinterface/core/baserecording.py | 1 + src/spikeinterface/core/binaryrecordingextractor.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/spikeinterface/core/baserecording.py b/src/spikeinterface/core/baserecording.py index e65afabaca..03db6bd9af 100644 --- a/src/spikeinterface/core/baserecording.py +++ b/src/spikeinterface/core/baserecording.py @@ -549,6 +549,7 @@ def _save(self, format="binary", verbose: bool = False, **save_kwargs): channel_ids=self.get_channel_ids(), time_axis=0, file_offset=0, + is_filtered=self.is_filtered(), gain_to_uV=self.get_channel_gains(), offset_to_uV=self.get_channel_offsets(), ) diff --git a/src/spikeinterface/core/binaryrecordingextractor.py b/src/spikeinterface/core/binaryrecordingextractor.py index a0e349728e..36de79d111 100644 --- a/src/spikeinterface/core/binaryrecordingextractor.py +++ b/src/spikeinterface/core/binaryrecordingextractor.py @@ -68,10 +68,12 @@ def __init__( num_chan=None, ): # This assigns num_channels if num_channels is not None, otherwise num_chan is assigned + # num_chan needs to be be kept for backward compatibility but should not be used by the + # end user num_channels = num_channels or num_chan assert num_channels is not None, "You must provide num_channels or num_chan" if num_chan is not None: - warnings.warn("`num_chan` is to be deprecated in version 0.100, please use `num_channels` instead") + warnings.warn("`num_chan` is to be deprecated as of version 0.100, please use `num_channels` instead") if channel_ids is None: channel_ids = list(range(num_channels)) From ec0a63949262a535ff5b1e484c7ca6cf5f65c1ca Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:12:34 -0400 Subject: [PATCH 5/6] Revert "fix test for deprecation" This reverts commit 309be48e5b38ad56c0ab2cf25c2e359f3058b7f2. --- src/spikeinterface/core/tests/test_binaryrecordingextractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spikeinterface/core/tests/test_binaryrecordingextractor.py b/src/spikeinterface/core/tests/test_binaryrecordingextractor.py index 7d90c48947..ea5edc6e6e 100644 --- a/src/spikeinterface/core/tests/test_binaryrecordingextractor.py +++ b/src/spikeinterface/core/tests/test_binaryrecordingextractor.py @@ -94,7 +94,7 @@ def test_sequential_reading_of_small_traces(folder_with_binary_files): file_paths = [folder / "traces_cached_seg0.raw"] recording = BinaryRecordingExtractor( - num_channels=num_channels, + num_chan=num_channels, file_paths=file_paths, sampling_frequency=sampling_frequency, dtype=dtype, From 4b6b1b96f70edeaae197d2ca6175af11ab9b6d10 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:14:15 -0400 Subject: [PATCH 6/6] add comment about num_chan --- src/spikeinterface/core/tests/test_binaryrecordingextractor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/spikeinterface/core/tests/test_binaryrecordingextractor.py b/src/spikeinterface/core/tests/test_binaryrecordingextractor.py index ea5edc6e6e..700910f9cd 100644 --- a/src/spikeinterface/core/tests/test_binaryrecordingextractor.py +++ b/src/spikeinterface/core/tests/test_binaryrecordingextractor.py @@ -93,6 +93,8 @@ def test_sequential_reading_of_small_traces(folder_with_binary_files): dtype = "float32" file_paths = [folder / "traces_cached_seg0.raw"] + # `num_chan` is kept for backward compatibility so including it at least one test + # run is good to ensure that it is appropriately accepted as an argument recording = BinaryRecordingExtractor( num_chan=num_channels, file_paths=file_paths,