Skip to content

Commit f2dd329

Browse files
authored
Merge pull request #3724 from alejoe91/fix-3723
Renaming: `from_time_labels` -> `from_samples_and_labels`
2 parents 3cef709 + 1ab98d3 commit f2dd329

24 files changed

Lines changed: 115 additions & 63 deletions

doc/how_to/load_your_data_into_sorting.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ the requested unit_ids).
6565
6666
# in this case we are making a monosegment sorting
6767
# we have four spikes that are spread among two neurons
68-
my_sorting = NumpySorting.from_times_labels(
69-
times_list=[
68+
my_sorting = NumpySorting.from_samples_and_labels(
69+
samples_list=[
7070
np.array([1000,12000,15000,22000]) # Note these are samples/frames not times in seconds
7171
],
7272
labels_list=[
@@ -120,7 +120,7 @@ Loading multisegment data into a :code:`Sorting`
120120
One of the great advantages of SpikeInterface :code:`Sorting` objects is that they can also handle
121121
multisegment recordings and sortings (e.g. you have a baseline, stimulus, post-stimulus). The
122122
exact same machinery can be used to generate your sorting, but in this case we do a list of arrays instead of
123-
a single list. Let's go through one example for using :code:`from_times_labels`:
123+
a single list. Let's go through one example for using :code:`from_samples_and_labels`:
124124

125125
.. code-block:: python
126126
@@ -130,8 +130,8 @@ a single list. Let's go through one example for using :code:`from_times_labels`:
130130
# in this case we are making three-segment sorting
131131
# we have four spikes that are spread among two neurons
132132
# in each segment
133-
my_sorting = NumpySorting.from_times_labels(
134-
times_list=[
133+
my_sorting = NumpySorting.from_samples_and_labels(
134+
samples_list=[
135135
np.array([1000,12000,15000,22000]),
136136
np.array([30000,33000, 41000, 47000]),
137137
np.array([50000,53000,64000,70000]),

doc/modules/core.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,13 @@ In this example, we create a recording and a sorting object from numpy objects:
711711
spike_trains += spike_trains_i
712712
labels += labels_i
713713
714-
sorting_memory = NumpySorting.from_times_labels(times=spike_trains, labels=labels,
715-
sampling_frequency=sampling_frequency)
714+
# construct a mono-segment
715+
samples_list = [np.array(spike_trains)]
716+
labels_list = [np.array(labels)]
717+
718+
sorting_memory = NumpySorting.from_samples_and_labels(
719+
samples_list=samples_list, labels_list=labels_list, sampling_frequency=sampling_frequency
720+
)
716721
717722
718723
Any sorting object can be transformed into a :py:class:`~spikeinterface.core.NumpySorting` or

examples/tutorials/core/plot_2_sorting_extractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
##############################################################################
4141
# And instantiate a :py:class:`~spikeinterface.core.NumpySorting` object:
4242

43-
sorting = se.NumpySorting.from_times_labels([times0, times1], [labels0, labels1], sampling_frequency)
43+
sorting = se.NumpySorting.from_samples_and_labels([times0, times1], [labels0, labels1], sampling_frequency)
4444
print(sorting)
4545

4646
##############################################################################

src/spikeinterface/benchmark/benchmark_clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def compute_result(self, **result_params):
6060

6161
self.result["sliced_gt_sorting"].set_property("gt_unit_locations", gt_unit_locations)
6262

63-
self.result["clustering"] = NumpySorting.from_times_labels(
63+
self.result["clustering"] = NumpySorting.from_samples_and_labels(
6464
data["sample_index"], self.result["peak_labels"][~self.noise], self.recording.sampling_frequency
6565
)
6666

src/spikeinterface/benchmark/benchmark_peak_selection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def create_benchmark(self, key):
160160
# nb_garbage = len(garbage_peaks)
161161

162162
# ratio = 100 * len(garbage_peaks) / len(times2)
163-
# self.garbage_sorting = NumpySorting.from_times_labels(garbage_peaks, garbage_channels, self.sampling_rate)
163+
# self.garbage_sorting = NumpySorting.from_samples_and_labels(garbage_peaks, garbage_channels, self.sampling_rate)
164164

165165
# print("The peaks have {0:.2f}% of garbage (without gt around)".format(ratio))
166166

src/spikeinterface/comparison/tests/test_comparisontools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
def make_sorting(times1, labels1, times2, labels2):
2222
sampling_frequency = 30000.0
23-
sorting1 = NumpySorting.from_times_labels([times1], [labels1], sampling_frequency)
24-
sorting2 = NumpySorting.from_times_labels([times2], [labels2], sampling_frequency)
23+
sorting1 = NumpySorting.from_samples_and_labels([times1], [labels1], sampling_frequency)
24+
sorting2 = NumpySorting.from_samples_and_labels([times2], [labels2], sampling_frequency)
2525
return sorting1, sorting2
2626

2727

src/spikeinterface/comparison/tests/test_groundtruthcomparison.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
def make_sorting(times1, labels1, times2, labels2):
1010
sampling_frequency = 30000.0
11-
gt_sorting = NumpySorting.from_times_labels([times1], [labels1], sampling_frequency)
12-
tested_sorting = NumpySorting.from_times_labels([times2], [labels2], sampling_frequency)
11+
gt_sorting = NumpySorting.from_samples_and_labels([times1], [labels1], sampling_frequency)
12+
tested_sorting = NumpySorting.from_samples_and_labels([times2], [labels2], sampling_frequency)
1313
return gt_sorting, tested_sorting
1414

1515

src/spikeinterface/comparison/tests/test_multisortingcomparison.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def setup_module(tmp_path_factory):
1919

2020
def make_sorting(times1, labels1, times2, labels2, times3, labels3):
2121
sampling_frequency = 30000.0
22-
sorting1 = NumpySorting.from_times_labels([times1], [labels1], sampling_frequency)
23-
sorting2 = NumpySorting.from_times_labels([times2], [labels2], sampling_frequency)
24-
sorting3 = NumpySorting.from_times_labels([times3], [labels3], sampling_frequency)
22+
sorting1 = NumpySorting.from_samples_and_labels([times1], [labels1], sampling_frequency)
23+
sorting2 = NumpySorting.from_samples_and_labels([times2], [labels2], sampling_frequency)
24+
sorting3 = NumpySorting.from_samples_and_labels([times3], [labels3], sampling_frequency)
2525
sorting1 = sorting1.save()
2626
sorting2 = sorting2.save()
2727
sorting3 = sorting3.save()

src/spikeinterface/comparison/tests/test_symmetricsortingcomparison.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
def make_sorting(times1, labels1, times2, labels2):
99
sampling_frequency = 30000.0
10-
sorting1 = NumpySorting.from_times_labels([times1], [labels1], sampling_frequency)
11-
sorting2 = NumpySorting.from_times_labels([times2], [labels2], sampling_frequency)
10+
sorting1 = NumpySorting.from_samples_and_labels([times1], [labels1], sampling_frequency)
11+
sorting2 = NumpySorting.from_samples_and_labels([times2], [labels2], sampling_frequency)
1212
return sorting1, sorting2
1313

1414

src/spikeinterface/core/generate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def add_from_unit_dict(
509509
return sorting
510510

511511
@staticmethod
512-
def from_times_labels(
512+
def from_samples_and_labels(
513513
sorting1, times_list, labels_list, sampling_frequency, unit_ids=None, refractory_period_ms=None
514514
) -> "NumpySorting":
515515
"""
@@ -537,7 +537,7 @@ def from_times_labels(
537537
discarded.
538538
"""
539539

540-
sorting2 = NumpySorting.from_times_labels(times_list, labels_list, sampling_frequency, unit_ids)
540+
sorting2 = NumpySorting.from_samples_and_labels(times_list, labels_list, sampling_frequency, unit_ids)
541541
sorting = TransformSorting.add_from_sorting(sorting1, sorting2, refractory_period_ms)
542542
return sorting
543543

0 commit comments

Comments
 (0)