cellmap_data.utils.figs

cellmap_data.utils.figs#

Functions

get_image_dict(input_data, target_data, ...)

Create a dictionary of images for input, target, and output data.

get_image_grid(input_data, target_data, ...)

Create a grid of images for input, target, and output data.

get_image_grid_numpy(input_data, ...[, ...])

Create a grid of images for input, target, and output data using matplotlib and convert it to a numpy array.

cellmap_data.utils.figs.get_image_grid(input_data: Tensor, target_data: Tensor, outputs: Tensor, classes: Sequence[str], batch_size: int | None = None, fig_size: int = 3, clim: Sequence | None = None, cmap: str | None = None) Figure[source]#

Create a grid of images for input, target, and output data. :param input_data: Input data. :type input_data: torch.Tensor :param target_data: Target data. :type target_data: torch.Tensor :param outputs: Model outputs. :type outputs: torch.Tensor :param classes: List of class labels. :type classes: list :param batch_size: Number of images to display. Defaults to the length of the first axis of ‘input_data’. :type batch_size: int, optional :param fig_size: Size of the figure. Defaults to 3. :type fig_size: int, optional :param clim: Color limits for the images. Defaults to be scaled by the image’s intensity. :type clim: tuple, optional :param cmap: Colormap for the images. Defaults to None. :type cmap: str, optional

Returns:

Figure object.

Return type:

fig (matplotlib.figure.Figure)

Parameters:
  • input_data (Tensor)

  • target_data (Tensor)

  • outputs (Tensor)

  • classes (Sequence[str])

  • batch_size (int | None)

  • fig_size (int)

  • clim (Sequence | None)

  • cmap (str | None)

cellmap_data.utils.figs.get_image_grid_numpy(input_data: Tensor, target_data: Tensor, outputs: Tensor, classes: Sequence[str], batch_size: int | None = None, fig_size: int = 3, clim: Sequence | None = None, cmap: str | None = None) ndarray[source]#

Create a grid of images for input, target, and output data using matplotlib and convert it to a numpy array. :param input_data: Input data. :type input_data: torch.Tensor :param target_data: Target data. :type target_data: torch.Tensor :param outputs: Model outputs. :type outputs: torch.Tensor :param classes: List of class labels. :type classes: list :param batch_size: Number of images to display. Defaults to the length of the first axis of ‘input_data’. :type batch_size: int, optional :param fig_size: Size of the figure. Defaults to 3. :type fig_size: int, optional :param clim: Color limits for the images. Defaults to be scaled by the image’s intensity. :type clim: tuple, optional :param cmap: Colormap for the images. Defaults to None. :type cmap: str, optional

Returns:

Image data.

Return type:

fig (numpy.ndarray)

Parameters:
  • input_data (Tensor)

  • target_data (Tensor)

  • outputs (Tensor)

  • classes (Sequence[str])

  • batch_size (int | None)

  • fig_size (int)

  • clim (Sequence | None)

  • cmap (str | None)

cellmap_data.utils.figs.get_image_dict(input_data: Tensor, target_data: Tensor, outputs: Tensor, classes: Sequence[str], batch_size: int | None = None, fig_size: int = 3, clim: Sequence | None = None, colorbar: bool = True) dict[source]#

Create a dictionary of images for input, target, and output data. :param input_data: Input data. :type input_data: torch.Tensor :param target_data: Target data. :type target_data: torch.Tensor :param outputs: Model outputs. :type outputs: torch.Tensor :param classes: List of class labels. :type classes: list :param batch_size: Number of images to display. Defaults to the length of the first axis of ‘input_data’. :type batch_size: int, optional :param fig_size: Size of the figure. Defaults to 3. :type fig_size: int, optional :param clim: Color limits for the images. Defaults to be scaled by the image’s intensity. :type clim: tuple, optional :param colorbar: Whether to display a colorbar for the model outputs. Defaults to True. :type colorbar: bool, optional

Returns:

Dictionary of figure objects.

Return type:

image_dict (dict)

Parameters:
  • input_data (Tensor)

  • target_data (Tensor)

  • outputs (Tensor)

  • classes (Sequence[str])

  • batch_size (int | None)

  • fig_size (int)

  • clim (Sequence | None)

  • colorbar (bool)