iss_preprocess.vis package

Submodules

iss_preprocess.vis.diagnostics module

iss_preprocess.vis.diagnostics.adjacent_tiles_registration(data_path, prefix, roi, shifts, raw_shifts, xcorr_max, max_shift=20, min_corrcoef=0.5, max_delta_shift=30)

Save figure of tile registration for within acquisition stitching

see pipeline.stitch.register_within_acquisition for usage.

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str) – Prefix of acquisition

  • roi (int) – ROI number

  • shifts (np.array) – (tilex x tiley x 4) vector of shifts per tile

  • raw_shifts (np.array) – (tilex x tiley x 4) vector of raw shifts per tile

  • xcorr_max (np.array) – (tilex x tiley x 2) vector of max correlation per tile

  • max_shift (int) – Maximum shift to plot, in pixels (default 20)

  • min_corrcoef (float) – Minimum correlation coefficient to plot

Returns:

Figure instance

Return type:

plt.Figure

iss_preprocess.vis.diagnostics.check_reg2ref_using_stitched(save_path, stitched_stack_reference, stitched_stack_target, ref_centers=None, trans_centers=None)

Check the registration to reference done on stitched images

Parameters:
  • data_path (str) – Relative path to data

  • reg_prefix (str) – Prefix of the registered images

  • ref_prefix (str) – Prefix of the reference images

  • roi (int) – ROI to process

  • stitched_stack_reference (np.ndarray) – Stitched stack of the reference images

  • stitched_stack_target (np.ndarray) – Stitched stack of the registered images

  • ref_centers (np.ndarray) – Reference centers to plot. Defaults to None.

  • trans_centers (np.ndarray) – Transformed centers to plot. Defaults

Returns:

Figure

Return type:

plt.Figure

iss_preprocess.vis.diagnostics.plot_affine_debug_images(debug_info, fig=None)

Plot debug images for affine registration

It will plot the correlation, shifts, affine predictions and residuals for each channel.

Parameters:
  • debug_info (dict) – Dictionary containing debug information

  • fig (plt.Figure, optional) – Figure to plot into. Defaults to None, will create a new figure.

Returns:

Figure instance

Return type:

plt.Figure

iss_preprocess.vis.diagnostics.plot_all_rounds(stack, view=None, channel_colors=None, grid=True, round_labels=None, fig=None, axes=None, vmin=None, vmax=None, legend_kwargs=None)

Plot all rounds of a stack in a grid

Parameters:
  • stack (np.array) – Image stack to plot (x y z round)

  • view (np.array, optional) – View to plot. Defaults to None, full view.

  • channel_colors (list, optional) – List of colors for each channel. Defaults to None, which will use the default colors (r, g, m, c).

  • grid (bool, optional) – Whether to plot a grid. Defaults to True.

  • round_labels (list, optional) – List of round labels. Defaults to None, which will use “Round {iround}”.

  • fig (plt.Figure, optional) – Figure to plot into. Defaults to None, will create a new figure.

  • axes (list, optional) – List of axes to plot into. Defaults to None, will create new axes.

  • vmin (float, optional) – Minimum value for the colormap. Defaults to None.

  • vmax (float, optional) – Maximum value for the colormap. Defaults to None.

Returns:

Figure instance np.array: RGB stack

Return type:

plt.Figure

iss_preprocess.vis.diagnostics.plot_correction_images(correction_images, grand_averages, figure_folder, verbose=True)

Plot average illumination correction images.

Parameters:
  • correction_images (dict) – Dictionary containing image stacks.

  • grand_averages (list) – List of grand averages to plot.

  • figure_folder (pathlib.Path) – Path where to save the figures.

  • verbose (bool) – Print info about progress. Defaults to True

iss_preprocess.vis.diagnostics.plot_registration_correlograms(data_path, prefix, figure_name, debug_dict)
iss_preprocess.vis.diagnostics.plot_round_registration_diagnostics(reg_stack, target_folder, fname_base, view_window=200, round_labels=None)

Generate 3 diagnostics tools for the registration of a tile

  • A static figure showing the stack of all rounds

  • An animated figure showing the stack of all rounds

  • A stack of RGB images for fiji

Parameters:
  • reg_stack (np.ndarray) – Registered stack of images

  • target_folder (pathlib.Path) – Folder to save the figures

  • fname_base (str) – Base name for the figures

  • view_window (int, optional) – Half size of the window to show in the figures. Defaults to 200.

Returns:

None

iss_preprocess.vis.diagnostics.plot_spot_sign_image(spot_image)

Plot the average spot sign image.

Parameters:

spot_image – X x Y array of average spot sign values.

iss_preprocess.vis.diagnostics.plot_tilestats_distributions(data_path, distributions, grand_averages, figure_folder)

Plot histogram of pixel values.

Parameters:
  • data_path (str) – Relative path to data

  • distributions (dict) – Dictionary containing tilestats distributions of pixel values per image.

  • grand_averages (list) – List of grand averages to plot.

  • figure_folder (pathlib.Path) – Path where to save the figures.

  • camera_order (list) – Order list of camera as in ops[‘camera_order’]

iss_preprocess.vis.vis module

iss_preprocess.vis.vis.add_bases_legend(channel_colors, transform=None, **kwargs)

Add legend for base colors to a plot.

Parameters:
  • channel_colors (list) – list of colors for each channel.

  • transform (matplotlib.transforms.Transform) – transform for legend.

  • kwargs – additional keyword arguments for plt.text.

iss_preprocess.vis.vis.animate_sequencing_rounds(stack, savefname, vmax=0.5, vmin=0, extent=((0, 2000), (0, 2000)), channel_colors=([1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 1]), axes_titles=None)

Animate sequencing rounds as RGB images amd save as an mp4 file.

Parameters:
  • stack (ndarray) – X x Y x C x R stack or list of such stacks

  • savefname (str) – filename to save animation

  • vmax (float) – maximum value for each channel.

  • vmin (float) – minimum value for each channel.

  • extent (list) – extent of plot. [[xmin, xmax], [ymin, ymax]]

  • channel_colors (list) – list of colors for each channel. Default: red, green, magenta, cyan = ([1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 1])

  • axes_titles (list, optional) – list of titles for each stack

iss_preprocess.vis.vis.make_lut(color, nlevels=256)

Create a look-up table by interpolating between (0,0,0) and provided color.

Parameters:
  • color – the maximum RGB value for look-up table.

  • nlevels – number of LUT levels

Returns:

nlevels x 3 matrix.

iss_preprocess.vis.vis.plot_clusters(cluster_means, spot_colors, cluster_inds)

Plot the cluster means and spot colors for each channel.

Parameters:
  • cluster_means – list of nch x nclusters cluster means.

  • spot_colors – round x channels x spots array of spot colors.

  • cluster_inds – list of arrays of cluster indices for each round.

Returns:

list of figures

Return type:

figs

iss_preprocess.vis.vis.plot_gene_matrix(gene_df, cmap='inferno', vmax=2)

Plot matrix of gene expression after sorting rows and columns using hierarchical clustering.

Parameters:

gene_df (DataFrame) – table of gene counts.

iss_preprocess.vis.vis.plot_gene_templates(gene_dict, gene_names, BASES, nrounds=7, nchannels=4)

Plot gene templates.

Parameters:
  • gene_dict (ndarray) – X x G matrix of gene templates. X = nrounds * nchannels

  • gene_names (list) – list of gene names

  • BASES (list) – list of base names

  • nrounds (int) – number of rounds. Default: 7

  • nchannels (int) – number of channels. Default: 4

iss_preprocess.vis.vis.plot_sequencing_rounds(stack, vmax=0.5, extent=((0, 2000), (0, 2000)), channel_colors=([1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 1]))

Plot sequencing rounds as RGB images.

Parameters:
  • stack (ndarray) – X x Y x C x R stack

  • vmax (float, optional) – maximum value for each channel. Default: 0.5

  • extent (list, optional) – extent of plot. [[xmin, xmax], [ymin, ymax]]. If None, use full image. Default: ((0, 2000), (0, 2000))

  • channel_colors (list, optional) – list of colors for each channel. Default: red, green, magenta, cyan = ([1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 1])

iss_preprocess.vis.vis.plot_spot_called_base(spots, ax, iround, base_color=None, **kwargs)

Plot called base for each spot.

This will write a single base, as colored letter, for each spot at the given round.

Parameters:
  • spots (DataFrame) – table of spots.

  • ax (matplotlib.axes.Axes) – axis to plot on.

  • iround (int) – round to plot.

  • base_color (dict, optional) – dictionary of base colors. Defaults to None.

  • kwargs – additional keyword arguments for plt.text.

Returns:

None

iss_preprocess.vis.vis.plot_spots(stack, spots, colors=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 0.0, 1.0], [0.0, 1.0, 1.0]], vmax=10000.0, vmin=500.0)

Visualize detected plots.

Parameters:
  • stack – X x Y x C stack

  • spots – pandas.DataFrame of spot locations

  • colors – maximum RGB values for each channel.

  • vmax – maximum level for each channel

  • vmin – minimum level for each channel

iss_preprocess.vis.vis.round_to_rgb(stack, iround, extent=None, channel_colors=([1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 1]), vmax=None, vmin=None)

Convert a single sequencing round to RGB image.

Parameters:
  • stack (ndarray) – X x Y x C x R stack

  • iround (int) – sequencing round to visualize

  • extent (list, optional) – extent of plot. [[xmin, xmax], [ymin, ymax]] or None, in which case the full image is used. Default: None

  • channel_colors (list, optional) – list of colors for each channel. Default to red, green, magenta, cyan

  • vmax (float, optional) – maximum value for each channel.

  • vmin (float, optional) – minimum value for each channel.

Returns:

RGB image.

iss_preprocess.vis.vis.to_rgb(stack, colors, vmax=None, vmin=None)

Convert multichannel stack to RGB image.

Parameters:
  • stack – X x Y x C stack.

  • colors – maximum RGB values for each channel.

  • vmax – maximum level for each channel

  • vmin – minimum level for each channel

Returns:

X x Y x 3 RGB image

Module contents