Skip to content

Commit

Permalink
add mode to provide any function
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 committed Nov 27, 2023
1 parent 6c3b4eb commit 8db93e3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/spikeanalysis/spike_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,11 @@ def plot_response_trace(
Color to plot the traces in
show_stim: bool, default=True
Whether to show stimulus lines
mode: 'mean'| 'median' | 'max' | 'min', deafult: 'mean'
How to calculate values for plotting
mode: 'mean'| 'median' | 'max' | 'min' | func default: 'mean'
How to calculate values for plotting, can be a string in which case
the appropriate nan-based numpy function is used. Otherwise the user
can give an appropriate function to use (it needs to be able to handle)
data with nans
"""

Expand All @@ -848,15 +851,17 @@ def plot_response_trace(

assert mode in ('mean', 'median', 'max', 'min'), f"mode must be 'mean' 'median', 'max', 'min you entered {mode}"

if mode=='mean':
if mode == 'mean':
func = np.nanmean
elif mode == 'median':
func = np.nanmedian
elif mode == 'max':
func = np.nanmax
else:
elif mode == 'min':
func = np.nanmin

else:
func = mode

for stimulus, response in data.items():
current_length = stim_lengths[stimulus]
current_bins = bins[stimulus]
Expand Down

0 comments on commit 8db93e3

Please sign in to comment.