May 04, 2019

Pneumonia Detection

This is an interesting project, actually I learned a lot from it, you can get the data in Kaggle, this competition is called RSNA Pneumonia Detection Challenge and at the time I am writing this post no one has obtained a good result in the competition, I will talk more about this in later sections.

The project

In this dataset we have 26,684 different images of lungs, some of these images have lung opacities, this opacities are hard to detect even for a expert radiologist, when a patient has pneumonia the air in the lungs is usually replaced by fluids, bacterias and more materials, as a result these areas have opacities, although lung opacities are not always associated with pneumonia we can take them as hints.

lung opacities

The first problem we can notice in this dataset is that the classes are not balanced only 6,012 lung images have opacities and 20,672 lung images do not have. In order to train a model that predicts the coordinates of these opacities I used a one-shot detector, I already explained how these detectors work in my previous post, the network has one detector for each cell and feature map of size 5x5x5.

In the image below we can see some of the correct predictions that the model made:

model predictions

Medical Images

As I mentioned at the beginning, this project does not have a solution yet. There are several reasons why this project is hard to solve but I would say that the principal reason is the quality of the dataset, medical images are known for being chaotic, these images are usually dirty and different from one dataset to another, the labels that radiologists give are usually via natural language, is hard to resume a description in only one word and sometimes these descriptions do not match, radiologists make observations but these will be probability different.

Things we can learn

Despite the results and the quality of the dataset we can learn important things from this project, I have explained this in other posts but here we can see the problems of only use one metric, in this project we can obtain a good accuracy and even a good loss value but if we look at the sensitivity and specificity we notice that the sensitivity is quite good and the specificity is quite bad due to the fact is easier for the neural network to predict all the classes as false (no lung opacities) in order to obtain a low loss value since we have more false examples than positive examples.

You may think that data augmentation could help to generate more images with lung opacities, however in this dataset the most part of the images have the same aspect, if we add data augmentation we could improve the accuracy in this dataset but we could have problems with a different dataset.

One more good thing about this dataset is the object detection problem, in general you can learn a lot about how a neural network makes predictions with a problem like this due to the fact you need to know how the output of the neural network works along with the loss function, perhaps if you are not interested in this kind of projects this is not the most excited project to work on, but I really recommend to go through one of these object detections datasets and build the detection section from scratch.

You can see the code of this project in in this notebook, I mentioned in my previous post that the code is based on this notebook. I changed the name of some variables and functions to make the code easier to read.