Image cleaner module

This module takes clear of cleaning up the junk from outside the brain area by using masks.

class library.image_manipulation.image_cleaner.ImageCleaner

Bases: object

Methods for cleaning images [and rotation, if necessary]. ‘Cleaning’ means applying user-verified masks (QC step) to downsampled or full-resolution images

create_cleaned_images()

This method applies the image masks that has been edited by the user to extract the tissue image from the surrounding debris 1. Set up the mask, input and output directories 2. clean images 3. Crop images if mask is set to FULL_MASK 4. Get biggest box size from all contours from all files and update DB with that info 5. Place images in new cropped image size with correct background color

create_cleaned_imagesOLD()

This method applies the image masks that has been edited by the user to extract the tissue image from the surrounding debris

create_cleaned_imagesTODO()

This method applies the image masks that has been edited by the user to extract the tissue image from the surrounding debris 1. Set up the mask, input and output directories 2. clean images 3. Crop images if mask is set to FULL_MASK 4. Get biggest box size from all contours from all files and update DB with that info 5. Place images in new cropped image size with correct background color

create_cleaned_images_full_resolutionOLD(channel)

Clean the image using the masks for the full resolution image

create_cleaned_images_thumbnailOLD(channel)

Clean the image using the masks for the downsampled version

create_rotated_aligned_masks()
create_shell()
create_shell_from_mask()
mask_aligned_imageNOTUSED(img, file)
parallel_create_cleaned(INPUT, CLEANED, MASKS)

Do the image cleaning in parallel

Parameters:
  • INPUT – str of file location input

  • CLEANED – str of file location output

  • MASKS – str of file location of masks

set_crop_sizeTODO()

This is not working

set_max_width_and_height()
set_max_width_and_heightTODO()
setup_parallel_create_cleanedTODO()

Do the image cleaning in parallel If we are working on the downsampled files, we delete the output directory to make sure there are no stale files

setup_parallel_place_imagesTODO()

Do the image placing in parallel. Cleaning has already taken place. We first need to get all the correct image sizes and then update the DB. f1 = c(28417,46233) t2 = c(28224,46233) f2 = c(26106,53785) t2 = c(26106,53568) f3 = c(25951,53624) t3 = c(25951,53568) f4 = c(26779,53882) t4 = c(26779,53568) f5 = c(28865,49615) t5 = c(28224,49615)

from shape (28865,49615) into shape (28224,49615)

update_bg_color()

Updates the background color of the image.

This method retrieves the background color of the image using the ImageManager class, and then updates the corresponding field in the scan run table using the SQLController class.

Parameters:

None

Returns:

None