micro_dl.plotting module
Submodules
micro_dl.plotting.plot_utils module
Utility functions for plotting
- micro_dl.plotting.plot_utils.convert_to_8bit(img)
Scales, calculates absolute values, and convert the result to 8-bit. :param np.array img: image :param float alpha: scale factor :return np.array img_8bit: image with 8bit values
- micro_dl.plotting.plot_utils.save_center_slices(image_dir, pos_idx, save_path, mean_std=None, clip_limits=1, margin=20, z_scale=5, z_range=None, channel_str=None, font_size=15, color_map='gray', fig_title=None)
Given an image directory, loads a z-stack, plots the center cross-sections of xy, yz and xz planes with the larger xy section top left, yz top right and xz bottom left in the figure.
- Parameters:
image_dir (str) – Directory containing z-stacks
pos_idx (int) – Which FOV to plot
save_path (str) – Full path of where to write figure file
mean_std (tuple) – If None, just assume the image will plot well as is, if tuple containing a mean and std (e.g. mean over training data), set z-stack mean and std and convert to uint16
clip_limits (float) – top and bottom % of intensity to saturate in histogram clipping
margin (int) – Number of pixel margin between the three center slices xy and xz, yz
z_scale (int) – How much to upsample in z (to be able to see xz and yz)
z_range (list) – Min and max z slice from given stack
channel_str (str) – If there’s more than one channel in image_dir (e.g. input image dir as opposed to predictions) use this str to select which channel to build z-stack from. E.g. ‘3’, ‘brightfield’.
font_size (int) – font size of the image title
color_map (str) – Matplotlib colormap
fig_title (str) – Figure title
- micro_dl.plotting.plot_utils.save_mask_overlay(input_image, mask, op_fname, alpha=0.7)
Plot and save a collage of input, mask, overlay
- Parameters:
input_image (np.array) – 2D input image
mask (np.array) – 2D mask image
op_fname (str) – fname will full path for saving the collage as a jpg
alpha (int) – opacity/transparency for the mask overlay
- micro_dl.plotting.plot_utils.save_plot(x, y, fig_fname, fig_labels=None)
Plot values y = f(x) and save figure.
- Parameters:
x (list) – x values
y (list) – y values (same length as x)
fig_fname (str) – File name including full path
fig_labels (list) – Labels for x and y axes, and title
- micro_dl.plotting.plot_utils.save_predicted_images(input_imgs, target_img, pred_img, metric, output_dir, output_fname=None, ext='jpg', clip_limits=1, font_size=15)
Save plots of predicted images to prediction-figures directory. - Overlay of target & prediction - Plot of input, target, prediction, and overlay of target & prediction
- Parameters:
input_imgs (np.ndarray) – input images [c,y,x]
target_img (np.ndarray) – target [y,x]
pred_img (np.ndarray) – output predicted by the model with same shape as input_img
metric (pd.series/None) – xy similarity metrics between prediction and target
output_dir (str) – dir to store the output images/mosaics
output_fname (str) – fname for saving collage
ext (str) – 3 letter file extension
clip_limits (float) – top and bottom % of intensity to saturate
font_size (int) – font size of the image title