Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructions to run

  1. Download the dataset at https://atlas.kpmp.org, place it under the project directory and unzip. This project is a Resnet-152 model that supports svs format medical and pathological slide scans.

  2. install required packages for running our code (using conda (miniconda on SCC) is recommended) conda create --name myenv python=3.8 -y pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 pip install tqdm pip install pandas pip install numpy pip install pillow

  3. implement required modules and debug on cpu mode python train.py

  4. once you're done with step. 3, submit the batch job to run on GPU.

Overview

This project aims to develop a tool for solving the problem of correctly diagnosing kidney diseases through Whole Slide Images (WSIs). In the US, there are 35.5 million cases of kidney disease, with 9 out of 10 people who have kidney disease not knowing they have it. Therefore it is important to develop efficient and accurate tools to diagnose kidney pathologies early so that they can be treated properly. Automating the diagnostic process would help to allow anyone to receive the proper treatment they need— removing barriers to medical entry. In particular, differentiating between such illnesses as Acute Kidney Injury (AKI) and Chronic Kidney Disease (CKD) becomes an important problem to delineate the proper treatment and care methodologies for individual patients. Kidney pathologies refer to a wide variety of conditions including those which may result in sudden failure of the organ (AKI) or progressive decline in its function over time (CKD). In most cases these diagnoses are done by a manual examination of the kidney’s macroscopic features (such as size) or bloodwork, but frequently require examination of tissue samples under microscopes.

This project focuses on the latter method, by training a neural network on images of tissue slide samples. We do this in hopes that the model will learn diagnostic criteria directly from the cells (the lowest level within which the pathology presents) and therefore achieve higher accuracy than what might be obtained through macroscopic details. This development involves scanning entire tissue slides into digital copies using Whole Slide Imaging (sourced from the Kidney Precision Medicine Project) because this method offers more comprehensive information than traditional media formats. However, storing WSIs has proven difficult due to their size; each image contains billions of pixels, resulting in a space cost of dozens of gigabytes when decompressed from an SVS file. The WSIs can also vary drastically in size and dimension, with tissue samples of highly variable shapes. We therefore implement various solutions to drastically reduce the spatial cost of working with this image format, and allow for the model to easily process the images despite their inconsistency.

Methodology: We approach this problem with a degree of intuition. First, we assume that the shape of the tissue sample will not be a useful feature for diagnosing AKI or CKD. In other words, we can perform image manipulations that result in the loss of macroscopic features. We chose to use a convolutional residual neural network (ResNet) model, for its strengths in training models of high depth, as we expect that the diagnosis of Kidney Disease involves identifying more abstract, high level features. We begin with a preprocessing step (computed as a separate module to the project code) to prepare the WSIs for compatibility with our model. Because our model, a ResNet152, expects images of consistent dimensions, we use image patching to separate each image into portions of equal size (with significant overlap, so there is no feature of the image that is bisected by our image patching, and therefore is harder for our model to learn). Our previous assumption that the shape of the tissue sample is irrelevant allows us to perform this operation. (But it is worth considering that some image patches may appear otherwise perfectly healthy, while the tissue sample as a whole has signs of AKI or CKD. This could not be accounted for in our accuracy calculation, as each patch inherited the classification of the original image, so it is possible our accuracy can be slightly higher). Because this process involves extremely large images, we use NumPy’s memory-mapping functionality, in order to only load the subset of pixels within each patch at a time. This drastically reduces our VRAM cost by multiple orders of magnitude. While we initially experimented with masking the images to isolate tissue pixels, this did not improve our results. We initially used a 34 layer model, but eventually found that the 152 layer model achieved better performance. We sourced our model from a public implementation within the PyT orch library, which we loaded and trained. We used GPU acceleration using CUDA/MPS, a native function from PyT orch, to expedite the training, validation, and inference processes. We ultimately settled on 50 epochs to avoid overfitting. Results:

  • The model achieved 82% accuracy after 50 epochs, but we found that decreasing the epoch count to 20 yielded a close 79% accuracy. However, given the relatively fast training time and positive (albeit unsubstantial) gain, We ended up going with 50 epochs for the model training.
  • The model took 2.5 hours of time to train and less than 30 seconds of inference time on the test set with an Apple M1 Pro GPU. The VRAM usage during training was <6GB
  • Data preprocessing took a few hours
  • We achieved <0.0009 Cross-Entropy Loss after 50 epochs. The loss value was truncated after 4 decimal points. The loss at 20 epochs was 0.001.

About

Machine learning Classifier for Kidney Disease Diagnosis

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages