fastplotlib.ImageWidget#

class ImageWidget(data, window_funcs=None, frame_apply=None, figure_shape=None, names=None, figure_kwargs=None, histogram_widget=True, rgb=None, cmap='plasma', graphic_kwargs=None)[source]#

This widget facilitates high-level navigation through image stacks, which are arrays containing one or more images. It includes sliders for key dimensions such as “t” (time) and “z”, enabling users to smoothly navigate through one or multiple image stacks simultaneously.

Allowed dimensions orders for each image stack: Note that each has a an optional (c) channel which refers to RGB(A) a channel. So this channel should be either 3 or 4.

n_dims

dims order

2

“xy(c)”

3

“txy(c)”

4

“tzxy(c)”

Parameters:
  • data (Union[np.ndarray, List[np.ndarray]) – array-like or a list of array-like

  • window_funcs (dict[str, tuple[Callable, int]], i.e. {"t" or "z": (callable, int)}) –

    Apply function(s) with rolling windows along “t” and/or “z” dimensions of the data arrays.
    Pass a dict in the form: {dimension: (func, window_size)}, func must take a slice of the data array as
    the first argument and must take axis as a kwarg.
    Ex: mean along “t” dimension: {“t”: (np.mean, 11)}, if current_index of “t” is 50, it will pass frames
    45 to 55 to np.mean with axis=0.
    Ex: max along z dim: {“z”: (np.max, 3)}, passes current, previous & next frame to np.max with axis=1

  • frame_apply (Union[callable, Dict[int, callable]]) –

    Apply function(s) to data arrays before to generate final 2D image that is displayed.
    Ex: apply a spatial gaussian filter
    Pass a single function or a dict of functions to apply to each array individually
    examples: {array_index: to_grayscale}, {0: to_grayscale, 2: threshold_img}
    ”array_index” is the position of the corresponding array in the data list.
    if window_funcs is used, then this function is applied after window_funcs
    this function must be a callable that returns a 2D array
    example use case: converting an RGB frame from video to a 2D grayscale frame

  • figure_shape (Optional[Tuple[int, int]]) – manually provide the shape for the Figure, otherwise the number of rows and columns is estimated

  • figure_kwargs (dict, optional) – passed to GridPlot

  • names (Optional[str]) – gives names to the subplots

  • histogram_widget (bool, default False) – make histogram LUT widget for each subplot

  • rgb (bool | list[bool], default None) – bool or list of bool for each input data array in the ImageWidget, indicating whether the corresponding data arrays are grayscale or RGB(A).

  • graphic_kwargs (Any) – passed to each ImageGraphic in the ImageWidget figure subplots

Examples#

Image widget

Image widget

Image widget videos side by side

Image widget videos side by side

Image widget grid

Image widget grid

Image widget Video

Image widget Video

Explore Covariance Matrix

Explore Covariance Matrix

ImGUI with ImageWidget

ImGUI with ImageWidget

ImageWidget as QtWidget

ImageWidget as QtWidget