Mask manager module

This module is responsible for creating and applying the masks. The idea and lots of the code were very heavily borrowed from this study: https://www.cis.upenn.edu/~jshi/ped_html/

class library.image_manipulation.mask_manager.MaskManager

Bases: object

Class containing all methods related to image masks This class is used to create masks for each tiff image (post-extraction from czi files), apply user-modified masks

Note: Uses pytorch for ML generation of masks

apply_user_mask_edits()

Apply the edits made on the image masks to extract the tissue from the surround debris to create the final masks used to clean the images. Input dir is the colored merged masks

create_contour_mask()

Create masks for the downsampled images using contours The input files are the files that have not been normalized The output files are the colored merged files.

create_downsampled_mask()

Create masks for the downsampled images using a machine learning algorithm. The input files are the files that have been normalized. The output files are the colored merged files.

create_full_resolution_mask()

Upsample the masks created for the downsampled images to the full resolution

create_mask()

Helper method to call either full resolition of downsampled. Create the images masks for extracting the tissue from the surrounding debris using a CNN based machine learning algorithm. If the images are from the MDXXX brains, they are 3 dimenions so the masks need to be done differently

get_model_instance_segmentation(num_classes)

This loads the mask model CNN

Parameters

num_classes – int showing how many classes, usually 2, brain tissue, not brain tissue

load_machine_learning_model()

Load the CNN model used to generate image masks

static resize_tif(file_key)

Function to upsample mask images

Parameters

file_key – tuple of inputs to the upsampling program including:

  • path to thumbnail file

  • The output directory of upsampled image

  • resulting size after upsampling