diff --git a/src/spikeanalysis/spike_plotter.py b/src/spikeanalysis/spike_plotter.py index f9189c3..6360843 100644 --- a/src/spikeanalysis/spike_plotter.py +++ b/src/spikeanalysis/spike_plotter.py @@ -702,7 +702,6 @@ def plot_latencies(self): plt.figure(dpi=self.dpi) plt.show() - def plot_isi(self): """ Function for plotting ISI distributions @@ -726,10 +725,15 @@ def plot_isi(self): plt.figure(dpi=self.dpi) plt.show() - - def plot_response_trace(self, type: Literal['zscore', 'raw'] = 'zscore', by_neuron: bool = False, by_trial:bool = False, ebar: bool = False, color='black'): - - assert type in ['zscore', 'raw'], 'type of data must be zscore or raw' + def plot_response_trace( + self, + type: Literal["zscore", "raw"] = "zscore", + by_neuron: bool = False, + by_trial: bool = False, + ebar: bool = False, + color="black", + ): + assert type in ["zscore", "raw"], "type of data must be zscore or raw" if type == "zscore": data = self.data.z_scores @@ -743,21 +747,23 @@ def plot_response_trace(self, type: Literal['zscore', 'raw'] = 'zscore', by_neur if by_trial and by_neuron: for neuron in range(np.shape(response)[0]): for trial in range(np.shape(response)[1]): - self._plot_one_trace(current_bins, response[neuron, trial, :], ebars=None, color=color, stim=stimulus) + self._plot_one_trace( + current_bins, response[neuron, trial, :], ebars=None, color=color, stim=stimulus + ) elif by_neuron: for neuron in range(np.shape(response)[0]): avg_response = np.mean(response[neuron], axis=0) ebars = np.std(response[neuron], axis=0) if ebar: - self._plot_one_trace(current_bins, avg_response, ebars=ebars, color=color,stim=stimulus) + self._plot_one_trace(current_bins, avg_response, ebars=ebars, color=color, stim=stimulus) else: - self._plot_one_trace(current_bins, avg_response, ebars=None, color=color,stim=stimulus) + self._plot_one_trace(current_bins, avg_response, ebars=None, color=color, stim=stimulus) elif by_trial: for trial in range(np.shape(response)[1]): - avg_response= np.mean(response[:, trial, :], axis=0) + avg_response = np.mean(response[:, trial, :], axis=0) ebars = np.std(response[:, trial, :], axis=0) if ebar: - self._plot_one_trace(current_bins, avg_response, ebars=ebars, color=color,stim=stimulus) + self._plot_one_trace(current_bins, avg_response, ebars=ebars, color=color, stim=stimulus) else: self._plot_one_trace(current_bins, avg_response, ebars=None, color=color, stim=stimulus) else: @@ -765,19 +771,15 @@ def plot_response_trace(self, type: Literal['zscore', 'raw'] = 'zscore', by_neur if ebar: self._plot_one_trace(current_bins, avg_response, ebars=ebars, color=color, stim=stimulus) else: - self._plot_one_trace(current_bins, avg_response, ebars=None, color=color,stim=stimulus) - - - - - def _plot_one_trace(self, bins, trace, ebars=None, color='black', stim=''): + self._plot_one_trace(current_bins, avg_response, ebars=None, color=color, stim=stimulus) + def _plot_one_trace(self, bins, trace, ebars=None, color="black", stim=""): fig, ax = plt.subplots(figsize=self.figsize) ax.plot(bins, trace, color=color) if ebars is not None: - ax.plot(bins, trace+ebars, color=color) - ax.plot(bins, trace-ebars, color=color) - ax.fill_between(bins, trace-ebars, trace+ebars, color=color, alpha=0.02) + ax.plot(bins, trace + ebars, color=color) + ax.plot(bins, trace - ebars, color=color) + ax.fill_between(bins, trace - ebars, trace + ebars, color=color, alpha=0.02) ax.set_xlabel("Time (s)") ax.set_ylabel(self.y_axis) @@ -787,7 +789,6 @@ def _plot_one_trace(self, bins, trace, ebars=None, color='black', stim=''): plt.figure(dpi=self.dpi) plt.show() - def _get_event_lengths(self) -> dict: """ Utility function to get the event lengths and convert from samples to seconds on a trial