Skip to content

Commit

Permalink
Continue hunting for solution to numpy left-bound.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZiminski committed Jun 19, 2024
1 parent dd371e0 commit 5391363
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/spikeinterface/postprocessing/correlograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,13 @@ def correlogram_for_one_segment(spike_times, spike_labels, window_size, bin_size
if sign == -1:
mask[:-shift][spike_diff_b < -num_half_bins] = False
else:
spike_diff_b[np.where(spike_diff_b == num_half_bins)] -= 1
# spike_diff_b[np.where(spike_diff_b == num_half_bins)] -= 1 adds to the first AND last bin, which we dont want.
mask[:-shift][spike_diff_b >= num_half_bins] = False
# spike_diff_b[spike_diff_b == num_half_bins] = 0 # fills the central bin
# the problem is that we need to mask specific pairs of comparisons
# but this is just masking the entire spike time.
# I still don't understand why removing the bound is leading to error at all,
# it is leading to extra counting.

m = mask[:-shift]

Expand Down
11 changes: 8 additions & 3 deletions src/spikeinterface/postprocessing/tests/test_correlograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ def test_detect_injected_correlation():
# 3) some different window_ms and bin_ms. Instead, maybe core utils
# can be factored out and segment stuff is handled in a new test.
# otherwise, will be too much!


# keep the window and bin fixed. test across num filled bins
def test_correlograms_unit():
""" """
sampling_frequency = 30000
Expand Down Expand Up @@ -242,9 +245,11 @@ def test_correlograms_unit():

# TODO: tidy up this test, add multi-segment case. Decide which cases to test neatly.
for auto_idx in [(0, 0), (1, 1)]:
breakpoint()
assert np.array_equal(expected_results, result_numpy[auto_idx]) # TODO: CHECK!
assert np.array_equal(expected_results, result_numba[auto_idx])
try:
assert np.array_equal(expected_results, result_numpy[auto_idx]) # TODO: CHECK!
assert np.array_equal(expected_results, result_numba[auto_idx])
except:
breakpoint()

expected_results[int(num_bins / 2)] = num_filled_bins
for auto_idx in [(1, 0), (0, 1)]:
Expand Down

0 comments on commit 5391363

Please sign in to comment.