diff --git a/nwbwidgets/icephys.py b/nwbwidgets/icephys.py index 2f052183..a2e88bed 100644 --- a/nwbwidgets/icephys.py +++ b/nwbwidgets/icephys.py @@ -2,20 +2,20 @@ from .timeseries import show_timeseries_mpl from ipywidgets import widgets import matplotlib.pyplot as plt -from ndx_icephys_meta.icephys import SweepSequences +from ndx_icephys_meta.icephys import SequentialRecordingsTable from functools import partial import numpy as np from matplotlib.pyplot import Figure import pandas as pd -def show_single_sweep_sequence(sweep_sequence, axs=None, title=None, **kwargs) -> Figure: +def show_single_sequential_recording(sequential_recording, axs=None, title=None, **kwargs) -> Figure: """ Show a single rep of a single stimulus sequence Parameters ---------- - sweep_sequence + sequential_recording axs: [matplotlib.pyplot.Axes, matplotlib.pyplot.Axes], optional title: str, optional kwargs: dict @@ -28,57 +28,57 @@ def show_single_sweep_sequence(sweep_sequence, axs=None, title=None, **kwargs) - """ - nsweeps = len(sweep_sequence) + nsweeps = len(sequential_recording) if axs is None: fig, axs = plt.subplots(2, 1, sharex=True) else: fig = axs[0].get_figure() for i in range(nsweeps): - start, stop, ts = sweep_sequence['recordings'].iloc[i]['response'].iloc[0] + start, stop, ts = sequential_recording['recordings'].iloc[i]['responses']['response'].iloc[0] show_timeseries_mpl(ts, istart=start, istop=stop, ax=axs[0], zero_start=True, xlabel='', title=title, **kwargs) - start, stop, ts = sweep_sequence['recordings'].iloc[i]['stimulus'].iloc[0] + start, stop, ts = sequential_recording['recordings'].iloc[i]['stimuli']['stimulus'].iloc[0] show_timeseries_mpl(ts, istart=start, istop=stop, ax=axs[1], zero_start=True, **kwargs) return fig -def show_sweep_sequence_reps(stim_df: pd.DataFrame, **kwargs) -> Figure: +def show_sequential_recordings_reps(stim_df: pd.DataFrame, **kwargs) -> Figure: """ - Show data from multiple reps of the same stimulus type + Show data from multiple repetitions of the same stimulus type Parameters ---------- stim_df: pandas.DataFrame kwargs: dict - passed to show_single_sweep_sequence + passed to show_single_sequential_recording Returns ------- matplotlib.pyplot.Figure """ - nsweeps = len(stim_df['sweeps']) + nsweeps = len(stim_df['simultaneous_recordings']) if 'repetition' in stim_df: stim_df = stim_df.sort_values('repetition') fig, axs = plt.subplots(2, nsweeps, sharex='col', sharey='row', figsize=[6.4 * nsweeps, 4.8]) if nsweeps == 1: axs = np.array([axs]).T - for i, (sweep, sweep_axs) in enumerate(zip(stim_df['sweeps'], axs.T)): + for i, (sweep, sweep_axs) in enumerate(zip(stim_df['simultaneous_recordings'], axs.T)): if i: kwargs.update(ylabel='') - show_single_sweep_sequence(sweep, axs=sweep_axs, title='rep {}'.format(i+1), **kwargs) + show_single_sequential_recording(sweep, axs=sweep_axs, title='Repetition {}'.format(i+1), **kwargs) return fig -def show_sweep_sequences(node: SweepSequences, *args, style: GroupingWidget = widgets.Accordion, **kwargs) -> \ +def show_sequential_recordings(node: SequentialRecordingsTable, *args, style: GroupingWidget = widgets.Accordion, **kwargs) -> \ GroupingWidget: """ - Visualize the sweep sequences table with a lazy accordion of sweep sequence repetitions + Visualize the sequential recordings table with a lazy accordion of stimulus types Parameters ---------- - node: SweepSequences + node: SequentialRecordingsTable style: widgets.Accordion or widgets.Tabs Returns @@ -89,7 +89,7 @@ def show_sweep_sequences(node: SweepSequences, *args, style: GroupingWidget = wi if 'stimulus_type' in node: labels, data = zip(*[(stim_label, stim_df) for stim_label, stim_df in node.to_dataframe().groupby('stimulus_type')]) - func_ = show_sweep_sequence_reps + func_ = show_sequential_recordings_reps else: data = node['sweeps'] labels = None diff --git a/nwbwidgets/view.py b/nwbwidgets/view.py index a3f69825..0aecf7a9 100644 --- a/nwbwidgets/view.py +++ b/nwbwidgets/view.py @@ -4,12 +4,12 @@ from nwbwidgets import behavior, misc, base, ecephys, image, ophys, icephys, timeseries, file import hdmf from functools import partial -from ndx_icephys_meta.icephys import SweepSequences +from ndx_icephys_meta.icephys import SequentialRecordingsTable default_neurodata_vis_spec = { pynwb.NWBFile: file.show_nwbfile, - SweepSequences: icephys.show_sweep_sequences, + SequentialRecordingsTable: icephys.show_sequential_recordings, pynwb.behavior.BehavioralEvents: behavior.show_behavioral_events, pynwb.ecephys.LFP: ecephys.show_lfp, pynwb.misc.Units: OrderedDict({ diff --git a/setup.py b/setup.py index 3183c120..1edafbc4 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ 'plotly', 'scikit-image', 'tqdm>=4.36.0', - 'ndx-icephys-meta'], + 'ndx-icephys-meta>0.1.0'], license='MIT', keywords=['jupyter', 'hdf5', 'notebook', 'nwb'], long_description=long_description,