Visualizations

Tensorboard visuals

monai.visualize.img2tensorboard.add_animated_gif(writer, tag, image_tensor, max_out, scale_factor, global_step=None)[source]

Creates an animated gif out of an image tensor in ‘CHWD’ format and writes it with SummaryWriter.

Parameters
  • writer (SummaryWriter) – Tensorboard SummaryWriter to write to

  • tag (str) – Data identifier

  • image_tensor (Union[ndarray, Tensor]) – tensor for the image to add, expected to be in CHWD format

  • max_out (int) – maximum number of slices to animate through

  • scale_factor (float) – amount to multiply values by. If the image data is between 0 and 1, using 255 for this value will scale it to displayable range

  • global_step (Optional[int]) – Global step value to record

Return type

None

monai.visualize.img2tensorboard.add_animated_gif_no_channels(writer, tag, image_tensor, max_out, scale_factor, global_step=None)[source]

Creates an animated gif out of an image tensor in ‘HWD’ format that does not have a channel dimension and writes it with SummaryWriter. This is similar to the “add_animated_gif” after inserting a channel dimension of 1.

Parameters
  • writer (SummaryWriter) – Tensorboard SummaryWriter to write to

  • tag (str) – Data identifier

  • image_tensor (Union[ndarray, Tensor]) – tensor for the image to add, expected to be in CHWD format

  • max_out (int) – maximum number of slices to animate through

  • scale_factor (float) – amount to multiply values by. If the image data is between 0 and 1, using 255 for this value will scale it to displayable range

  • global_step (Optional[int]) – Global step value to record

Return type

None

monai.visualize.img2tensorboard.make_animated_gif_summary(tag, image, max_out=3, animation_axes=(3, ), image_axes=(1, 2), other_indices=None, scale_factor=1.0)[source]

Creates an animated gif out of an image tensor in ‘CHWD’ format and returns Summary.

Parameters
  • tag (str) – Data identifier

  • image (Union[ndarray, Tensor]) – The image, expected to be in CHWD format

  • max_out (int) – maximum number of slices to animate through

  • animation_axes (Sequence[int]) – axis to animate on (not currently used)

  • image_axes (Sequence[int]) – axes of image (not currently used)

  • other_indices (Optional[Dict]) – (not currently used)

  • scale_factor (float) – amount to multiply values by. if the image data is between 0 and 1, using 255 for this value will scale it to displayable range

Return type

Summary

monai.visualize.img2tensorboard.plot_2d_or_3d_image(data, step, writer, index=0, max_channels=1, max_frames=64, tag='output')[source]

Plot 2D or 3D image on the TensorBoard, 3D image will be converted to GIF image.

Note

Plot 3D or 2D image(with more than 3 channels) as separate images.

Parameters
  • data (Union[Tensor, ndarray]) – target data to be plotted as image on the TensorBoard. The data is expected to have ‘NCHW[D]’ dimensions, and only plot the first in the batch.

  • step (int) – current step to plot in a chart.

  • writer (SummaryWriter) – specify TensorBoard SummaryWriter to plot the image.

  • index (int) – plot which element in the input data batch, default is the first element.

  • max_channels (int) – number of channels to plot.

  • max_frames (int) – number of frames for 2D-t plot.

  • tag (str) – tag of the plotted image on TensorBoard.

Return type

None