From 2698f8f8e3950d5e559363954bf836a308f489bf Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Tue, 26 Mar 2024 16:32:52 -0400 Subject: [PATCH] update event plots to plot even with nans --- specparam/plts/event.py | 2 +- specparam/plts/templates.py | 2 +- specparam/utils/data.py | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/specparam/plts/event.py b/specparam/plts/event.py index 3800add1..8d650851 100644 --- a/specparam/plts/event.py +++ b/specparam/plts/event.py @@ -54,7 +54,7 @@ def plot_event_model(event_model, **plot_kwargs): figsize=plot_kwargs.pop('figsize', [10, 4 + 4 * n_bands])) axes = cycle(axes) - xlim = [0, time_model.n_time_windows] + xlim = [0, event_model.n_time_windows] # 01: aperiodic params alabels = ['offset', 'knee', 'exponent'] if has_knee else ['offset', 'exponent'] diff --git a/specparam/plts/templates.py b/specparam/plts/templates.py index 1c850280..d34932c1 100644 --- a/specparam/plts/templates.py +++ b/specparam/plts/templates.py @@ -289,7 +289,7 @@ def plot_params_over_time(times, params, labels=None, title=None, colors=None, @check_dependency(plt, 'matplotlib') -def plot_param_over_time_yshade(times, param, average='mean', shade='std', scale=1., +def plot_param_over_time_yshade(times, param, average='nanmean', shade='nanstd', scale=1., color=None, ax=None, **plot_kwargs): """Plot parameter over time with y-axis shading. diff --git a/specparam/utils/data.py b/specparam/utils/data.py index 19880a53..5e7affe4 100644 --- a/specparam/utils/data.py +++ b/specparam/utils/data.py @@ -15,11 +15,15 @@ AVG_FUNCS = { 'mean' : np.mean, 'median' : np.median, + 'nanmean' : np.nanmean, + 'nanmedian' : np.nanmedian, } DISPERSION_FUNCS = { 'var' : np.var, + 'nanvar' : np.nanvar, 'std' : np.std, + 'nanstd' : np.nanstd, 'sem' : sem, }