Skip to content

Commit

Permalink
wip fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 committed Oct 4, 2023
1 parent 7dba992 commit 8aca105
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/spikeanalysis/spike_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,12 +797,7 @@ def plot_response_trace(
for stimulus, response in data.items():
current_length = stim_lengths[stimulus]
current_bins = bins[stimulus]
bin_size = current_bins[1] - current_bins[0]
start_pt = np.where((current_bins > -bin_size) & (current_bins < bin_size))[0][0]
end_pt = np.where((current_bins > current_length - bin_size) & (current_bins < current_length + bin_size))[
0
][0]
stim_lines = [start_pt, end_pt]

if by_trial and by_neuron:
for neuron in range(np.shape(response)[0]):
for trial in range(np.shape(response)[1]):
Expand All @@ -813,7 +808,7 @@ def plot_response_trace(
color=color,
stim=stimulus,
show_stim=show_stim,
stim_lines=stim_lines,
stim_lines=current_length,
)
elif by_neuron:
for neuron in range(np.shape(response)[0]):
Expand All @@ -827,7 +822,7 @@ def plot_response_trace(
color=color,
stim=stimulus,
show_stim=show_stim,
stim_lines=stim_lines,
stim_lines=current_length,
)
else:
self._plot_one_trace(
Expand All @@ -837,7 +832,7 @@ def plot_response_trace(
color=color,
stim=stimulus,
show_stim=show_stim,
stim_lines=stim_lines,
stim_lines=current_length,
)
elif by_trial:
for trial in range(np.shape(response)[1]):
Expand All @@ -851,7 +846,7 @@ def plot_response_trace(
color=color,
stim=stimulus,
show_stim=show_stim,
stim_lines=stim_lines,
stim_lines=current_length,
)
else:
self._plot_one_trace(
Expand All @@ -861,7 +856,7 @@ def plot_response_trace(
color=color,
stim=stimulus,
show_stim=show_stim,
stim_lines=stim_lines,
stim_lines=current_length,
)
else:
avg_response = np.mean(np.mean(response, axis=1), axis=0)
Expand All @@ -873,7 +868,7 @@ def plot_response_trace(
color=color,
stim=stimulus,
show_stim=show_stim,
stim_lines=stim_lines,
stim_lines=current_length,
)
else:
self._plot_one_trace(
Expand All @@ -883,18 +878,18 @@ def plot_response_trace(
color=color,
stim=stimulus,
show_stim=show_stim,
stim_lines=stim_lines,
stim_lines=current_length,
)

def _plot_one_trace(
self, bins, trace, ebars=None, color="black", stim="", show_stim: bool = True, stim_lines: list = [0, 0]
self, bins, trace, ebars=None, color="black", stim="", show_stim: bool = True, stim_lines: list = 0
):
"""
Function for plotting one response trace in 2D. I'm going to try
to let it autoscale
"""
fig, ax = plt.subplots(figsize=self.figsize)
ax.plot(bins, trace, color=color, linewidth=0.75)
ax.plot(bins, trace, color=color, linewidthh=0.75)
max_pt = np.max(trace)
if ebars is not None:
ax.plot(bins, trace + ebars, color=color, linewidth=0.25)
Expand All @@ -903,15 +898,15 @@ def _plot_one_trace(
max_pt = np.max(trace + ebars)
if show_stim:
ax.axvline(
stim_lines[0],
0,
0,
max_pt,
color="black",
linestyle=":",
linewidth=0.5,
)
ax.axvline(
stim_lines[1],
stim_lines,
0,
max_pt,
color="black",
Expand Down

0 comments on commit 8aca105

Please sign in to comment.