Skip to content

Commit

Permalink
* change default stop_label to None
Browse files Browse the repository at this point in the history
* correct base where units was used accidentally instead of the generic input_data
* add route_psth, which decides between a standard PSTHWidget and a PSTHWidget inside a TimeIntervalsSelector wrapper
* change view to use new routing function
  • Loading branch information
bendichter committed Jan 21, 2022
1 parent dec17c7 commit af031bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nwbwidgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def __init__(self, input_data, **kwargs):

trials = list(self.intervals_tables.values())[0]
inner_widget = self.InnerWidget(
units=self.input_data,
input_data=self.input_data,
trials=trials,
**kwargs
)
Expand Down
14 changes: 11 additions & 3 deletions nwbwidgets/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pynwb.misc import AnnotationSeries, Units, DecompositionSeries

from .analysis.spikes import compute_smoothed_firing_rate
from .base import TimeIntervalsSelector
from .controllers import (
make_trial_event_controller,
GroupAndSortController,
Expand Down Expand Up @@ -283,9 +284,6 @@ def __init__(

if trials is None:
self.trials = self.get_trials()
if self.trials is None:
self.children = [widgets.HTML("No trials present")]
return
else:
self.trials = trials

Expand Down Expand Up @@ -535,6 +533,16 @@ def update(
fig.subplots_adjust(wspace=0.3)
return fig

class IntervalsPSTHWidget(TimeIntervalsSelector):
InnerWidget = PSTHWidget

def route_psth(units, **kwargs):
trials = units.get_ancestor("NWBFile").trials
if trials is None:
return IntervalsPSTHWidget(units, **kwargs)
else:
return PSTHWidget(units, **kwargs)


def show_histogram(
data, ax: plt.Axes, start: float, end: float, group_inds=None, nbins: int = 30
Expand Down
2 changes: 1 addition & 1 deletion nwbwidgets/utils/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def align_by_time_intervals(
index,
intervals,
start_label="start_time",
stop_label="stop_time",
stop_label=None,
start=0.0,
end=0.0,
rows_select=(),
Expand Down
2 changes: 1 addition & 1 deletion nwbwidgets/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def show_dynamic_table(node, **kwargs) -> widgets.Widget:
{
"Summary": DynamicTableSummaryWidget,
"Session Raster": misc.RasterWidget,
"Grouped PSTH": misc.PSTHWidget,
"Grouped PSTH": misc.route_psth,
"Raster Grid": misc.RasterGridWidget,
"Tuning Curves": misc.TuningCurveWidget,
"Combined": misc.TuningCurveExtendedWidget,
Expand Down

0 comments on commit af031bb

Please sign in to comment.