The goal of this project is to estimate density of invasive cancer cells in breast cancer biopsies. The approach taken was to first segment invasive cancer on digital pathology slides and then use the segmentation maps to estimate the density of invasive cancer cells.
Whole slide images were annotated by a domain expert (Dr. Mark Sherman) in Aperio ImageScope. Those annotations were pulled from those whole slide images, relevant regions were pulled from the images and masks were created.
This was done using level_two_extraction_dict.py file. There were three folders that contained whole slide images with annotations. The relevant folders are processed by specifying 'file_dir' and 'xml_list'. All necessary paths are within this file. Note that this code was developed in a HPC and folders were mapped using Rclone - when working in a different environment change '/tmp/m271367/sherman_radisky' to '//mfad.mfroot.org/Researchfl/Cancer/Sherman-Group/' (access permissions to this folder are required - email Mark Sherman for access).
Images are pulled at different resolution levels so that the model can capture strucutral nuances at different levels. This is specified using the 'level' parameter. All images were pulled at level 2 and 3 corresponding to 1/2 and 1/4 original resolution.
Training images and masks are in data/cancer_and_dcis.
5 fold cross validation was done with a split at the slide level to determine appropriate learning rates. Independent models are trained at the level 2 and level 3 resolutions. Model results are combined by taking .3level_2 + .7level_3 - optimal combination was determined by brute force search on out of sample folds from cross validation.
train_cancer_dics_segmentation_cancer_only.py was used to train the model.
Because whole slides images are so large, to do inference on those slides, we need to tile them out and run inference on the tiles. Whole slide images were tiled at an iamge size of 520 and a stride of 260. Pixel probabilities are average across all runs. Because we haven't finalzed a method for estimating cellular desnity, probability maps are saved as 8bit .png images.
Inference on ACS images is done with the run_on_tar_files_level_cancer_only.py file.
The create_annotations_from_png.py file can be used to convert the probability maps into .xml annotation files that can be viewed on the whole slide images within Aperio ImageScope.
The estimate of cellular density is still under development. The most recent approach uses the estimated size for the cancer, finds the center of mass of invasive cancer in the whole slide images, and then calculates the density within the given radius. This is done in the get_radius_densities_png.py file.