-
Notifications
You must be signed in to change notification settings - Fork 279
BUG: preserve correlogram unit axes across segments #4767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
71284b8
6c09713
105e958
640fae6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -521,14 +521,14 @@ def _compute_correlograms_numpy(sorting, window_size, bin_size): | |||||||||||
| spike_times = spikes[seg_index]["sample_index"] | ||||||||||||
| spike_unit_indices = spikes[seg_index]["unit_index"] | ||||||||||||
|
|
||||||||||||
| c0 = correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bin_size) | ||||||||||||
| c0 = correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bin_size, num_units=num_units) | ||||||||||||
|
|
||||||||||||
| correlograms += c0 | ||||||||||||
|
|
||||||||||||
| return correlograms | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bin_size): | ||||||||||||
| def correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bin_size, num_units=None): | ||||||||||||
| """ | ||||||||||||
| A very well optimized algorithm for the cross-correlation of | ||||||||||||
| spike trains, copied from the Phy package, written by Cyrille Rossant. | ||||||||||||
|
|
@@ -545,6 +545,9 @@ def correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bi | |||||||||||
| The window size over which to perform the cross-correlation, in samples | ||||||||||||
| bin_size : int | ||||||||||||
| The size of which to bin lags, in samples. | ||||||||||||
| num_units : int or None | ||||||||||||
| Number of units in the complete sorting. If ``None``, use the number | ||||||||||||
| of unique indices in ``spike_unit_indices`` for backward compatibility. | ||||||||||||
|
Comment on lines
+548
to
+550
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| Returns | ||||||||||||
| ------- | ||||||||||||
|
|
@@ -572,7 +575,8 @@ def correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bi | |||||||||||
| match within the window size. | ||||||||||||
| """ | ||||||||||||
| num_bins, num_half_bins = _compute_num_bins(window_size, bin_size) | ||||||||||||
| num_units = len(np.unique(spike_unit_indices)) | ||||||||||||
| if num_units is None: | ||||||||||||
| num_units = len(np.unique(spike_unit_indices)) | ||||||||||||
|
Comment on lines
+578
to
+579
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| correlograms = np.zeros((num_units, num_units, num_bins), dtype="int64") | ||||||||||||
|
|
||||||||||||
|
|
@@ -963,14 +967,16 @@ def _compute_auto_correlograms_numpy(sorting, window_size, bin_size): | |||||||||||
| spike_times = spikes[seg_index]["sample_index"] | ||||||||||||
| spike_unit_indices = spikes[seg_index]["unit_index"] | ||||||||||||
|
|
||||||||||||
| c0 = auto_correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bin_size) | ||||||||||||
| c0 = auto_correlogram_for_one_segment( | ||||||||||||
| spike_times, spike_unit_indices, window_size, bin_size, num_units=num_units | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| correlograms += c0 | ||||||||||||
|
|
||||||||||||
| return correlograms | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def auto_correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bin_size): | ||||||||||||
| def auto_correlogram_for_one_segment(spike_times, spike_unit_indices, window_size, bin_size, num_units=None): | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| """ | ||||||||||||
| A very well optimized algorithm for the auto-correlation of | ||||||||||||
| spike trains, copied from the Phy package, written by Cyrille Rossant. | ||||||||||||
|
|
@@ -987,6 +993,9 @@ def auto_correlogram_for_one_segment(spike_times, spike_unit_indices, window_siz | |||||||||||
| The window size over which to perform the cross-correlation, in samples | ||||||||||||
| bin_size : int | ||||||||||||
| The size of which to bin lags, in samples. | ||||||||||||
| num_units : int or None | ||||||||||||
| Number of units in the complete sorting. If ``None``, use the number | ||||||||||||
| of unique indices in ``spike_unit_indices`` for backward compatibility. | ||||||||||||
|
Comment on lines
+996
to
+998
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| Returns | ||||||||||||
| ------- | ||||||||||||
|
|
@@ -1014,7 +1023,8 @@ def auto_correlogram_for_one_segment(spike_times, spike_unit_indices, window_siz | |||||||||||
| match within the window size. | ||||||||||||
| """ | ||||||||||||
| num_bins, num_half_bins = _compute_num_bins(window_size, bin_size) | ||||||||||||
| num_units = len(np.unique(spike_unit_indices)) | ||||||||||||
| if num_units is None: | ||||||||||||
| num_units = len(np.unique(spike_unit_indices)) | ||||||||||||
|
Comment on lines
+1026
to
+1027
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| correlograms = np.zeros((num_units, num_bins), dtype="int64") | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.