add_nd_image#
- NDWSubplot.add_nd_image(data, dims, display_dims, rgb_dim=None, window_funcs=None, window_order=None, spatial_func=None, compute_histogram=True, clim_quantiles=None, slider_maps=None, slicer_type=NDImageSlicer, colorspace='srgb', colorrange='full', name=None, graphic_kwargs=None)[source]#
Add an n-dimensional image or volume to this subplot.
Every dim that is not listed in
display_dimsbecomes a slider dim.- Parameters:
data (ArrayProtocol or None) – n-dimensional image data, must have 2 or more dims. Pass
Noneto create theNDImagewithout a graphic and set the data later usingnd_image.data, the slider dims then require an explicit reference range in theNDWidget.dims (Sequence[str]) – name for every dim of
data, in order. They do not need to be in display order, ex: an array whose dims are("col", "depth", "row", "time")withdisplay_dimsof("row", "col").display_dims (tuple[str, str] | tuple[str, str, str]) –
The 2 or 3 spatial dims in display order, which also determines the graphic used for rendering:
(rows, cols), a 2D grayscaleImageGraphic(rows, cols, rgb_dim), a 2D RGB(A)ImageGraphic(z, rows, cols), a 3DImageVolumeGraphic
rgb_dim (str, optional) – Name of the RGB(A) dim, if present. It must be listed in
display_dimsand be of size 3 or 4.window_funcs (dict[str, tuple[WindowFuncCallable | None, int | float | None]], optional) –
Per-slider-dim window functions applied around the current slider position, ex:
{"time": (np.mean, 2.5)}. Each value is a(func, window_size)pair where:func must accept
axis: intandkeepdims: boolkwargs (ex:np.mean,np.max). It must return an array that has the same dims as the input, therefore the size of any dim along which it was applied should reduce to1. These dims must not be removed by the window func.window_size is in reference-space units (ex: 2.5 seconds).
window_order (tuple[str, ...], optional) – Order in which the window functions are applied across dims. Only dims listed here have their window function applied,
window_funcsare ignored for any dim not specified inwindow_order.spatial_func (Callable[[ArrayProtocol], ArrayProtocol], optional) – A function applied to the spatial slice after the window funcs, right before rendering. It is given the slice in
display_dimsorder, i.e. the array as it is rendered, and must return an array with those same dims.compute_histogram (bool, default
True) – Estimate a histogram of the data and display anImguiColorbaron the right edge of the subplot, which is used to interactively set vmin, vmax. Disable if random access of the data is not blazing-fast (ex: data that uses video codecs), or if a histogram is not useful for this data.clim_quantiles ((float, float), optional) –
(low, high)quantiles of the histogram, within[0, 1], used as vmin, vmax. Requirescompute_histogram=True, overrides any passed vmin, vmax ingraphic_kwargs. The limits are recomputed whenever the histogram is, so they follow the data.slider_maps (dict mapping dim_name -> Callable, an ArrayLike, or None, optional) – Per-slider-dim mapping from reference-space values to local array indices. An array of reference values may be given instead of a callable,
searchsortedis then used as the transform (ex: a timestamps array). Any dim without a transform uses the identity mapping, i.e. the current reference value is rounded to the nearest integer and used as the array index.slicer_type (type[NDImageSlicer], default
NDImageSlicer) –NDImageSlicersubclass that manages the data and produces the data slices.colorspace ("srgb" | "tex-srgb" | "physical" | "yuv420p" | "yuv444p", default "srgb") – Colorspace in which to interpret the data. The RGB colorspaces are rendered using an
ImageGraphicorImageVolumeGraphic, seeImageGraphicfor their meaning. The YUV colorspaces are rendered using anImageYUVGraphic, seeImageYUVGraphic.colorrange ("full" | "limited", default "full") – Used only for the YUV colorspaces, see
ImageYUVGraphic.name (str, optional) – Name for this
NDGraphic, used to retrieve it withnd_subplot[name].graphic_kwargs (dict, optional) – passed to the underlying image graphic, ex:
{"cmap": "viridis", "interpolation": "linear"}
- Return type: