Skip to content

Commit b16101f

Browse files
samuelgarciapre-commit-ci[bot]alejoe91
authored
Improve backward compatibility for dartsort after the chunkable PR (#4559)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alessio Buccino <alejoe9187@gmail.com>
1 parent c291e90 commit b16101f

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

src/spikeinterface/core/recording_tools.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
split_job_kwargs,
1919
)
2020

21-
from .time_series_tools import get_random_sample_slices, get_chunks, get_chunk_with_margin
21+
from .time_series_tools import get_random_sample_slices, get_chunks, get_time_series_chunk_with_margin
2222
from .time_series_tools import write_binary as _write_binary
2323
from .time_series_tools import write_memory as _write_memory
2424
from .time_series_tools import _write_time_series_to_zarr
@@ -804,3 +804,39 @@ def do_recording_attributes_match(
804804
exception_str = ""
805805

806806
return attributes_match, exception_str
807+
808+
809+
def get_chunk_with_margin(
810+
rec_segment,
811+
start_frame,
812+
end_frame,
813+
channel_indices,
814+
margin,
815+
add_zeros=False,
816+
add_reflect_padding=False,
817+
window_on_margin=False,
818+
dtype=None,
819+
):
820+
"""
821+
Helper to get chunk with margin
822+
823+
The margin is extracted from the recording when possible. If
824+
at the edge of the recording, no margin is used unless one
825+
of `add_zeros` or `add_reflect_padding` is True. In the first
826+
case zero padding is used, in the second case np.pad is called
827+
with mod="reflect".
828+
"""
829+
830+
# wrapper to keep backward compatibility with the previous naming and signature
831+
# this help dartsort for instance
832+
return get_time_series_chunk_with_margin(
833+
rec_segment,
834+
start_frame,
835+
end_frame,
836+
channel_indices,
837+
margin,
838+
add_zeros=add_zeros,
839+
add_reflect_padding=add_reflect_padding,
840+
window_on_margin=window_on_margin,
841+
dtype=dtype,
842+
)

src/spikeinterface/core/time_series_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def get_chunks(time_series: TimeSeries, concatenated=True, get_data_kwargs=None,
567567
return chunk_list
568568

569569

570-
def get_chunk_with_margin(
570+
def get_time_series_chunk_with_margin(
571571
chunkable_segment: TimeSeriesSegment,
572572
start_frame,
573573
end_frame,

src/spikeinterface/preprocessing/highpass_spatial_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_traces(self, start_frame, end_frame, channel_indices):
221221
self.parent_recording_segment,
222222
start_frame=start_frame,
223223
end_frame=end_frame,
224-
last_dimension_indices=slice(None),
224+
channel_indices=slice(None),
225225
margin=margin,
226226
)
227227
# apply sorting by depth

0 commit comments

Comments
 (0)