-
Notifications
You must be signed in to change notification settings - Fork 1
PyPlaque_view_plate_image
PyPlaque.view.plate_image
PlateImage Class
The PlateImage class is designed to encapsulate a full multi-title plate image and its corresponding binary mask. It provides methods to extract individual well images from the plate based on specified criteria, visualize these wells annotated with their positions, and more.
Attributes: n_rows (int, required): The number of rows in the plate. This should be less than the number of columns.
n_columns (int, required): The number of columns in the plate. This should be greater than the number of rows.
plate_image (np.ndarray, required): A 2D or 3D numpy array representing the image of individual wells on the plate.
plate_mask (np.ndarray, required): A binary 2D numpy array that outlines the regions corresponding to each well.
use_picks (bool, optional): An indicator for whether to use pick area calculations during analysis. Defaults to False.
inverted (bool, optional): A boolean flag indicating whether the plate image is inverted or not.
get_well_positions Method
This method identifies and returns individual wells from a plate image as binary numpy arrays. Each well is represented by its masked image, mask, cropped image, and bounding box coordinates along with row (nrow) and column (ncol) numbers.
Args: min_area (int, optional): The minimum area in pixels for a well to be considered. Default is 100.
Returns: dict: A dictionary where each key corresponds to an individual well, containing the following items: - 'masked_img' (numpy array): Binary mask of the well. - 'mask' (numpy array): Binary mask of the plate region occupied by the well. - 'img' (numpy array): Image cropped from the plate corresponding to the well. - 'maxr' (int): Maximum row index of the bounding box for the well. - 'minc' (int): Minimum column index of the bounding box for the well. - 'minr' (int): Minimum row index of the bounding box for the well. - 'maxc' (int): Maximum column index of the bounding box for the well. - 'nrow' (int): Row number of the well, starting from 0. - 'ncol' (int): Column number of the well, starting from 0.
Notes: The method processes the plate mask to identify and extract individual wells based on area threshold.Wells are identified using bounding boxes derived from regionprops analysis after clearing border artifacts. The returned dictionary is ordered by column unless the plate is inverted (in which case it orders by columns in reverse).
get_wells Method
This method identifies and returns individual wells from a plate image as binary numpy arrays. Each well is represented by its masked image within the bounding box derived from regionprops analysis after clearing border artifacts from the plate mask.
Args: min_area (int, optional): The minimum area in pixels for a well to be considered. Default is 100.
Returns: list: A list of numpy arrays, where each array represents a well cropped from the plate image.
Notes: Wells are identified based on their area threshold and are extracted using bounding boxes derived from regionprops analysis after clearing border artifacts from the plate mask.
plot_well_positions Method
Plots boxes around individual wells of the plate using the mask. Wells are annotated with their row and column positions.
This method visualizes the well locations on a plate by drawing white rectangles around each well inferred from the plate mask. The rows and columns are numbered starting from 0, and annotations indicate both the column and row numbers for each well.
Args: save_path (str, optional): File path where the plot image will be saved. If None (default), the figure is shown but not saved.
Returns: None
Example: To visualize and save the well positions on a plate with a specific mask, use:
instance_of_plate.plot_well_positions(save_path='path/to/save/figure.png')