Giter Site home page Giter Site logo

lluissalord / radiology_ai Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 0.0 62.7 MB

OpenSource project collaborating with a healthcare mutual insurance company (data provider) focusing on classifying knee frontal radiographies (DICOM) according to Schatzker classification (0 to 6).

Home Page: https://lluissalord.github.io/radiology_ai/

License: MIT License

Jupyter Notebook 98.92% Python 1.06% Mako 0.02%
pytorch radiography schatzker-classification deep-learning semi-supervised-learning dicom-files

radiology_ai's Introduction

Radiology AI

This is an OpenSource project collaborating with a healthcare mutual insurance company (data provider). The aim of this project is to build a pipeline to classify knee frontal radiography images according to Schatzker classification (from 0 to 6) from DICOM files. However, as first approach it used a binary classification of fractured knee (Schatzker classification different than 0).

Medical imaging projects as this one have several features that should be taken into account:

  1. Lack of datasets/samples for specific task

  2. Annotation requires expertise on traumatology field, hence it is limited

  3. Data is highly imbalanced towards non-fractured knees

  4. Medical images require special treatments

In order to tackle these issues we implemented the following methods on PyTorch using Fastai platform:

  • Algorithm based:

    • Transfer Learning on several steps (first ImageNet and then using DICOM metadata for pretraining model)
    • Self-Supervised Learning (pytorch-lightning package) for state-of-the-art transfer learning
    • Semi-Supervised Learning (MixMatch and FixMatch own implementations) to be able to train model without full dataset annotated
    • Organize experiments for Hyperparameters search (MLFlow or Ax-BoTorch)
  • Data based:

    • DataLoader sampler which allows to have a minimum of samples of all the labels in each batch
    • Use of specific losses to be robust to imbalance datasets
    • Active Learning to select most interesting files to annotate
  • Image processing:

    • Preprocesses to transform DICOM files into images independently of its metadata
    • Adaptative equalization of histogram to normalize bimodal data
    • Improve Knee localization to center-crop images on relevant part
    • Clean background to avoid overfitting on noise
    • Model interpretation with GradCAM or Layer Relevance Propagation
    • Use several channels for different views of the radiography

See below some examples these image processing:

"Preprocess steps 1" "Preprocess steps 2" "Classification of OOS GradCAM example 1" "Classification of OOS GradCAM example 2"

For more information regarding the implemented preprocesses please see Preprocessing README or the related API documentation here

Below can be seen some initial results on the current state (May 2021) on supervised learning:

"Classification of fracture GradCAM example 1" "Classification of fracture GradCAM example 2"

Installation

Google Colab setup

All the notebooks are prepared to be directly used on Google Colab, then if you are going to be using Google Colab you do not have to worry at all.

In case you would like to reuse code for setting up your notebook please look on colab_pip_setup.ipynb and/or colab_conda_setup.ipynb. This last one is for the automatic conda installations on Google Colab. The gdcm package which is required to read all kind of DICOM files can only be installed with conda. Hence 0_eda.ipynb and 3_preprocess.ipynb notebooks which read DICOM files requires of this kind of installation.

Local installation

Add conda-forge channel:
conda config --add channels conda-forge

Create environment:
conda create -n radiology_ai python=3.6 --yes -q conda activate radiology_ai

Install environment:
conda install -n radiology_ai --override-channels -c main -c conda-forge -c fastai -c pytorch pytorch=1.6.0 fastai fastcore=1.0.9 pydicom gdcm=2.8.4 kornia=0.3.0 scikit-image scikit-learn pandas ipykernel ipywidgets tensorboard openpyxl black --yes -q

Install EfficientNet for Pytorch and Pytorch Ligthning Bolts:
pip install efficientnet_pytorch opencv-python

Install Pytorch Lignthning Bolts (due to an issue not yet solved on release better to use this than pip install pytorch-lightning):
pip install git+https://github.com/PytorchLightning/pytorch-lightning-bolts.git@master --upgrade
pip install https://github.com/lluissalord/pytorch-lightning-bolts/archive/issue_436_simCLR_IndexError.zip --upgrade

Install fastai2_extensions (renamed as amalgam) to use gradCAM visualizations:
pip install https://github.com/lluissalord/fastai2_extensions/archive/fix_to_cuda.zip palettable


API Documentation

API Documentation on lluissalord.github.io/radiology_ai/


Troubleshooting

  1. AttributeError: '_FakeLoader' object has no attribute 'persistent_workers':
    pip install --upgrade fastai

  2. Progress bar issues using VSCode:
    conda install "ipython>=6.0.0"

radiology_ai's People

Contributors

lluissalord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.