Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default visualisation for OnePhotonSeries #318

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions nwbwidgets/ophys.py
@@ -1,4 +1,5 @@
from functools import lru_cache
from typing import Union

import ipywidgets as widgets
import numpy as np
Expand All @@ -11,6 +12,7 @@
ImageSegmentation,
PlaneSegmentation,
RoiResponseSeries,
OnePhotonSeries,
TwoPhotonSeries,
)
from skimage import measure
Expand All @@ -25,10 +27,10 @@
color_wheel = px.colors.qualitative.Dark24


class TwoPhotonSeriesWidget(widgets.VBox):
"""Widget showing Image stack recorded over time from 2-photon microscope."""
class PhotonSeriesWidget(widgets.VBox):
"""Widget showing Image stack recorded over time from 2-photon or 1-photon microscope."""

def __init__(self, indexed_timeseries: TwoPhotonSeries, neurodata_vis_spec: dict):
def __init__(self, indexed_timeseries: Union[TwoPhotonSeries, OnePhotonSeries], neurodata_vis_spec: dict):
super().__init__()

def _add_fig_trace(img_fig: go.Figure, index):
Expand Down
5 changes: 3 additions & 2 deletions nwbwidgets/view.py
Expand Up @@ -42,7 +42,7 @@
)
from .ophys import (
RoiResponseSeriesWidget,
TwoPhotonSeriesWidget,
PhotonSeriesWidget,
route_plane_segmentation,
show_df_over_f,
show_grayscale_volume,
Expand Down Expand Up @@ -78,7 +78,8 @@ def show_dynamic_table(node, **kwargs) -> widgets.Widget:
pynwb.file.Subject: show_fields,
pynwb.ecephys.SpikeEventSeries: show_spike_event_series,
pynwb.ophys.ImageSegmentation: show_image_segmentation,
pynwb.ophys.TwoPhotonSeries: TwoPhotonSeriesWidget,
pynwb.ophys.TwoPhotonSeries: PhotonSeriesWidget,
pynwb.ophys.OnePhotonSeries: PhotonSeriesWidget,
ndx_grayscalevolume.GrayscaleVolume: show_grayscale_volume,
pynwb.ophys.PlaneSegmentation: route_plane_segmentation,
pynwb.ophys.DfOverF: show_df_over_f,
Expand Down
23 changes: 19 additions & 4 deletions test/test_ophys.py
Expand Up @@ -11,13 +11,13 @@
ImagingPlane,
OpticalChannel,
PlaneSegmentation,
TwoPhotonSeries,
TwoPhotonSeries, OnePhotonSeries,
)
from pynwb.testing.mock.ophys import mock_PlaneSegmentation

from nwbwidgets.ophys import (
PlaneSegmentation2DWidget,
TwoPhotonSeriesWidget,
PhotonSeriesWidget,
show_df_over_f,
show_grayscale_volume,
show_image_segmentation,
Expand Down Expand Up @@ -61,6 +61,16 @@ def setUpClass(self):
rate=1.0,
unit="n.a",
)

self.one_photon_series = OnePhotonSeries(
name="test_one_photon_series",
data=np.random.randn(100, 5, 5),
imaging_plane=self.imaging_plane,
starting_frame=[0],
rate=1.0,
unit="n.a.",
)

self.img_seg = ImageSegmentation()
self.ps2 = self.img_seg.create_plane_segmentation(
"output from segmenting my favorite imaging plane",
Expand Down Expand Up @@ -105,7 +115,7 @@ def setUpClass(self):
self.df_over_f = DfOverF(rrs)

def test_show_two_photon_series(self):
wid = TwoPhotonSeriesWidget(self.image_series, default_neurodata_vis_spec)
wid = PhotonSeriesWidget(self.image_series, default_neurodata_vis_spec)
assert isinstance(wid, widgets.Widget)
wid.controls["slider"].value = 50

Expand All @@ -118,7 +128,12 @@ def test_show_3d_two_photon_series(self):
rate=1.0,
unit="n.a",
)
wid = TwoPhotonSeriesWidget(image_series3, default_neurodata_vis_spec)
wid = PhotonSeriesWidget(image_series3, default_neurodata_vis_spec)
assert isinstance(wid, widgets.Widget)
wid.controls["slider"].value = 50

def test_show_one_photon_series(self):
wid = PhotonSeriesWidget(self.one_photon_series, default_neurodata_vis_spec)
assert isinstance(wid, widgets.Widget)
wid.controls["slider"].value = 50

Expand Down