Skip to content

Commit

Permalink
wip plot_isi
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 committed Oct 3, 2023
1 parent fa6190f commit 72a22cc
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/spikeanalysis/spike_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,26 +688,36 @@ def plot_latencies(self):
lat_by_neuron = lat_by_neuron[~np.isnan(lat_by_neuron)]
shufl_bsl_neuron = shufl_bsl_neuron[~np.isnan(shufl_bsl_neuron)]
fig, ax = plt.subplots(figsize=self.figsize)
ax.hist(lat_by_neuron, bins=bins, color="r")
ax.hist(shufl_bsl_neuron, bins=bins, color="k")
ax.set_xlabel("Time", fontsize="small")
ax.hist(lat_by_neuron, density=True, bins=bins, color="r", alpha=0.8)
ax.hist(shufl_bsl_neuron, density=True, bins=bins, color="k", alpha=0.8)
ax.set_xlabel("Time (ms)", fontsize="small")
ax.set_ylabel("Counts", fontsize="small")
plt.title(f"{stimulus.title()}: {self.data.cluster_ids[neuron]}")
self._despine(ax)
plt.tight_layout()
plt.figure(dpi=self.dpi)
plt.title(f"{stimulus.title()}: {self.data.cluster_ids[neuron]}")
plt.show()

def plot_isi(self):

try:
raw_isi = self.data.isi_raw
except AttributeError:
raise Exception("must run `get_interspike_intervals()`")

bins = np.arange(0, 500, 10)
for cluster in raw_isi.keys():
isi = raw_isi["isi"] / self.data._sampling_rate
isi = raw_isi['cluster']["isi"] * 1000 / self.data._sampling_rate

fig, ax = plt.subplots(figsize=self.figsize)
ax.hist(isi, density=True, bins=bins, color='k' )
ax.set_xlabel("Time (ms)")
ax.set_ylabel("Counts")
plt.title(f"ISI {cluster}")
plt.tight_layout()
plt.figure(dpi=self.dpi)
plt.show()


raise NotImplementedError

def _get_event_lengths(self) -> dict:
"""
Expand Down

0 comments on commit 72a22cc

Please sign in to comment.