def test_plot_sizes(plot_height, plot_width):
    sv_hist = sv.Histogram(nplots=1,
                           plot_height=plot_height,
                           plot_width=plot_width)
    plot = sv_hist.plots[0]

    assert plot.plot_height == plot_height
    assert plot.plot_width == plot_width
def test_update_fixed(nbins):
    sv_hist = sv.Histogram(nplots=1, nbins=nbins)
    sv_hist.auto_toggle.active = [0]  # True
    data = [np.random.randint(-100, 100, 1000)]
    sv_hist.update(data)

    assert len(sv_hist._plot_sources[0].data["left"]) == nbins
    assert len(sv_hist._plot_sources[0].data["right"]) == nbins
    assert len(sv_hist._plot_sources[0].data["top"]) == nbins
Exemple #3
0
sv_main.add_as_zoom(sv_zoom)

sv_colormapper = sv.ColorMapper([sv_main, sv_zoom])
sv_colormapper.color_bar.width = MAIN_CANVAS_WIDTH // 2
sv_main.plot.add_layout(sv_colormapper.color_bar, place="below")

sv_resolrings = sv.ResolutionRings([sv_main, sv_zoom], sv_metadata,
                                   sv_streamctrl)
sv_intensity_roi = sv.IntensityROI([sv_main, sv_zoom], sv_metadata,
                                   sv_streamctrl)
sv_saturated_pixels = sv.SaturatedPixels([sv_main, sv_zoom], sv_metadata,
                                         sv_streamctrl)
sv_spots = sv.Spots([sv_main], sv_metadata, sv_streamctrl)
sv_disabled_modules = sv.DisabledModules([sv_main], sv_streamctrl)

sv_hist = sv.Histogram(nplots=2, plot_height=200, plot_width=700)
sv_hist.plots[0].title = Title(text="Full image")
sv_hist.plots[1].title = Title(text="Roi")

sv_streamgraph = sv.StreamGraph(nplots=2, plot_height=200, plot_width=700)
sv_streamgraph.plots[0].title = Title(text="Total intensity")
sv_streamgraph.plots[1].title = Title(text="Zoom total intensity")

sv_imageproc = sv.ImageProcessor()

# Final layouts
layout_utility = column(
    gridplot(sv_streamgraph.plots,
             ncols=1,
             toolbar_location="left",
             toolbar_options=dict(logo=None)),
def _sv_hist_single_plot():
    sv_hist = sv.Histogram(nplots=1)
    yield sv_hist
def test_nplots(nplots):
    sv_hist = sv.Histogram(nplots=nplots)

    assert len(sv_hist.plots) == nplots
    assert len(sv_hist._plot_sources) == nplots
sv_colormapper = sv.ColorMapper([sv_main, sv_zoom1, sv_zoom2])
sv_colormapper.color_bar.width = MAIN_CANVAS_WIDTH // 2
sv_main.plot.add_layout(sv_colormapper.color_bar, place="below")

sv_resolrings = sv.ResolutionRings([sv_main, sv_zoom1, sv_zoom2], sv_metadata,
                                   sv_streamctrl)
sv_intensity_roi = sv.IntensityROI([sv_main, sv_zoom1, sv_zoom2], sv_metadata,
                                   sv_streamctrl)
sv_saturated_pixels = sv.SaturatedPixels([sv_main, sv_zoom1, sv_zoom2],
                                         sv_metadata, sv_streamctrl)
sv_spots = sv.Spots([sv_main], sv_metadata, sv_streamctrl)
sv_disabled_modules = sv.DisabledModules([sv_main], sv_streamctrl)

sv_hist = sv.Histogram(nplots=2,
                       plot_height=280,
                       plot_width=sv_zoom1.plot.plot_width)

sv_imageproc = sv.ImageProcessor()

zoom1_spectrum_x_source = ColumnDataSource(dict(x=[], y=[]))
zoom1_spectrum_y_source = ColumnDataSource(dict(x=[], y=[]))
zoom2_spectrum_x_source = ColumnDataSource(dict(x=[], y=[]))
zoom2_spectrum_y_source = ColumnDataSource(dict(x=[], y=[]))

sv_zoom1_proj_v.plot.add_glyph(
    zoom1_spectrum_x_source,
    Line(x="x", y="y", line_color="maroon", line_width=2))
sv_zoom1_proj_h.plot.add_glyph(
    zoom1_spectrum_y_source,
    Line(x="x", y="y", line_color="maroon", line_width=1))
# Currently, it's possible to control only a canvas size, but not a size of the plotting area.
MAIN_CANVAS_WIDTH = 1000 + 55
MAIN_CANVAS_HEIGHT = 1000 + 59


# Create streamvis components
sv_metadata = sv.MetadataHandler(datatable_height=300, datatable_width=400)

sv_main = sv.ImageView(plot_height=MAIN_CANVAS_HEIGHT, plot_width=MAIN_CANVAS_WIDTH)

sv_colormapper = sv.ColorMapper([sv_main])
sv_colormapper.color_bar.width = MAIN_CANVAS_WIDTH // 2
sv_main.plot.add_layout(sv_colormapper.color_bar, place="below")

sv_hist = sv.Histogram(nplots=1, plot_height=400, plot_width=700)

file_path = TextInput(title="File Path:", value="/")

dataset_path = TextInput(title="Dataset Path:", value="/")


def _load_image_from_dataset(file, dataset, index):
    with h5py.File(file, "r") as f:
        image = f[dataset][index].astype("float32")
        metadata = dict(shape=list(image.shape))

    return image, metadata


def load_file_button_callback():
Exemple #8
0
sv_streamgraph = sv.StreamGraph(nplots=2, plot_height=160, plot_width=DEBUG_INTENSITY_WIDTH)
sv_streamgraph.plots[0].title = Title(text="Total intensity")
sv_streamgraph.plots[1].title = Title(text="Normalized signal−background Intensity")

sv_colormapper = sv.ColorMapper([sv_main, sv_zoom1, sv_zoom2])
sv_colormapper.color_bar.width = MAIN_CANVAS_WIDTH // 2
sv_colormapper.color_bar.height = 10
sv_main.plot.add_layout(sv_colormapper.color_bar, place="below")

sv_resolrings = sv.ResolutionRings([sv_main, sv_zoom1, sv_zoom2], sv_metadata, sv_streamctrl)
sv_intensity_roi = sv.IntensityROI([sv_main, sv_zoom1, sv_zoom2], sv_metadata, sv_streamctrl)
sv_saturated_pixels = sv.SaturatedPixels([sv_main, sv_zoom1, sv_zoom2], sv_metadata, sv_streamctrl)
sv_spots = sv.Spots([sv_main], sv_metadata, sv_streamctrl)
sv_disabled_modules = sv.DisabledModules([sv_main], sv_streamctrl)

sv_hist = sv.Histogram(nplots=3, plot_height=300, plot_width=600)
sv_hist.plots[0].title = Title(text="Full image")
sv_hist.plots[1].title = Title(text="Signal roi", text_color="red")
sv_hist.plots[2].title = Title(text="Background roi", text_color="green")

sv_imageproc = sv.ImageProcessor()


# Final layouts
layout_main = gridplot([[sv_main.plot, column(sv_zoom1.plot, sv_zoom2.plot)]], merge_tools=False)

layout_hist = column(
    gridplot([[sv_hist.plots[0], sv_hist.plots[1], sv_hist.plots[2]]], merge_tools=False),
    row(
        column(sv_hist.auto_toggle, sv_hist.log10counts_toggle),
        sv_hist.lower_spinner,