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) – Includes a True or False for each array in the ImageWidget, indicating whether images are displayed as grayscale or RGB(A).

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