Skip to content

Commit

Permalink
Merge pull request #2130 from zm711/fix-peak-activity
Browse files Browse the repository at this point in the history
Fix peak activity example & bugs in `peak_activity`
  • Loading branch information
samuelgarcia authored Oct 25, 2023
2 parents d07738d + aec80cc commit 2956c27
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
14 changes: 8 additions & 6 deletions examples/modules_gallery/widgets/plot_4_peaks_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Peaks Widgets Gallery
=====================
Some widgets are useful before sorting and works with "peaks" given by detect_peaks()
Some widgets are useful before sorting and works with the "peaks" given by the detect_peaks()
function.
They are useful to check drift before running sorters.
Expand All @@ -21,14 +21,14 @@


##############################################################################
Lets filter and detect peak on it
Let's filter and detect peaks on it

from spikeinterface.sortingcomponents.peak_detection import detect_peaks

rec_filtred = si.bandpass_filter(rec, freq_min=300., freq_max=6000., margin_ms=5.0)
rec_filtred = si.bandpass_filter(recording=rec, freq_min=300., freq_max=6000., margin_ms=5.0)
print(rec_filtred)
peaks = detect_peaks(
rec_filtred, method='locally_exclusive',
recording=rec_filtred, method='locally_exclusive',
peak_sign='neg', detect_threshold=6, exclude_sweep_ms=0.3,
radius_um=100,
noise_levels=None,
Expand All @@ -46,12 +46,14 @@
# This "peaks" vector can be used in several widgets, for instance
# plot_peak_activity()

si.plot_peak_activity(rec_filtred, peaks=peaks)
si.plot_peak_activity(recording=rec_filtred, peaks=peaks)

plt.show()

##############################################################################
# can be also animated with bin_duration_s=1.

si.plot_peak_activity(rec_filtred, bin_duration_s=1.)
si.plot_peak_activity(recording=rec_filtred, peaks=peaks, bin_duration_s=1.)


plt.show()
16 changes: 8 additions & 8 deletions src/spikeinterface/widgets/peak_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ def animate_func(i):
i0, i1 = np.searchsorted(peaks["sample_index"], [bin_size * i, bin_size * (i + 1)])
local_peaks = peaks[i0:i1]
artists = self._plot_one_bin(
rec,
probe,
local_peaks,
dp.with_channel_ids,
dp.bin_duration_s,
dp.with_contact_color,
dp.with_interpolated_map,
rec=rec,
probe=probe,
peaks=local_peaks,
duration=dp.bin_duration_s,
with_channel_ids=dp.with_channel_ids,
with_contact_color=dp.with_contact_color,
with_interpolated_map=dp.with_interpolated_map,
)
return artists

Expand All @@ -120,7 +120,7 @@ def _plot_one_bin(self, rec, probe, peaks, duration, with_channel_ids, with_cont
if with_contact_color:
text_on_contact = None
if with_channel_ids:
text_on_contact = self.recording.channel_ids
text_on_contact = rec.channel_ids

from probeinterface.plotting import plot_probe

Expand Down

0 comments on commit 2956c27

Please sign in to comment.