Skip to content

Commit

Permalink
test by neuron
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 committed Oct 3, 2023
1 parent 1d3061d commit 9604e40
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions src/spikeanalysis/spike_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,46 +670,45 @@ def plot_zscores_ind(self, z_bar: Optional[list[int]] = None, show_stim: bool =
plt.figure(dpi=self.dpi)
plt.show()


def plot_latencies(self):

try:
latency = self.data.latency
latency = self.data.latency
except AttributeError:
raise Exception('must run `latencies()` function')
raise Exception("must run `latencies()` function")

bin_size = self.data._latency_time_bin
bins = np.arange(0, 400+bin_size, bin_size)
bins = np.arange(0, 400 + bin_size, bin_size)
for stimulus, lats in latency.items():

stim_lats = lats['latency'][~np.isnan(lats['latency'])]
shuffled_lats = lats['latency_shuffled'].flatten()
shuffled_lats = shuffled_lats[~np.isnan(shuffled_lats)]
fig, ax = plt.subplots(figsize=self.figsize)
ax.hist(stim_lats, bins=bins, color='r')
ax.hist(shuffled_lats, bins=bins, color='k')
ax.set_xlabel('Time', fontsize="small")
ax.set_ylabel("Counts", fontsize="small")
self._despine(ax)
plt.tight_layout()
plt.figure(dpi=self.dpi)
plt.show()

stim_lats = lats["latency"]
shuffled_lats = lats["latency_shuffled"]

for neuron in range(np.shape(stim_lats)[0]):
lat_by_neuron = stim_lats[neuron]
shuf_bsl_neuron = shuffled_lats[neuron].flatten()
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(stim_lats, bins=bins, color="r")
ax.hist(shuffled_lats, bins=bins, color="k")
ax.set_xlabel("Time", fontsize="small")
ax.set_ylabel("Counts", fontsize="small")
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()`')
raise Exception("must run `get_interspike_intervals()`")

for cluster in raw_isi.keys():
isi = raw_isi['isi'] / self.data._sampling_rate
isi = raw_isi["isi"] / self.data._sampling_rate

raise NotImplementedError



def _get_event_lengths(self) -> dict:
"""
Utility function to get the event lengths and convert from samples to seconds on a trial
Expand Down

0 comments on commit 9604e40

Please sign in to comment.