Switch to unified view

a/README.md b/README.md
1
[![MIT](https://img.shields.io/badge/license-MIT-5eba00.svg)](https://github.com/ahmedbesbes/character-based-cnn/blob/master/LICENSE)
1
[![MIT](https://img.shields.io/badge/license-MIT-5eba00.svg)](https://github.com/ahmedbesbes/character-based-cnn/blob/master/LICENSE)
2
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/ahmedbesbes/mrnet)
2
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/ahmedbesbes/mrnet)
3
[![Twitter](https://img.shields.io/twitter/follow/ahmed_besbes_.svg?label=Follow&style=social)](https://twitter.com/ahmed_besbes_)
3
[![Twitter](https://img.shields.io/twitter/follow/ahmed_besbes_.svg?label=Follow&style=social)](https://twitter.com/ahmed_besbes_)
4
[![Stars](https://img.shields.io/github/stars/ahmedbesbes/character-based-cnn.svg?style=social)](https://github.com/ahmedbesbes/mrnet/stargazers)
4
[![Stars](https://img.shields.io/github/stars/ahmedbesbes/character-based-cnn.svg?style=social)](https://github.com/ahmedbesbes/mrnet/stargazers)
5
5
6
6
7
# Deep learning in medical imaging: How to automate the detection of knee injuries in MRI exams ? 
7
# Deep learning in medical imaging: How to automate the detection of knee injuries in MRI exams ? 
8
8
9
This repository contains an implementation of a convolutional neural network that classifies specific knee injuries from MRI exams.
9
This repository contains an implementation of a convolutional neural network that classifies specific knee injuries from MRI exams.
10
10
11
It also contains the matieral of a series of posts I wrote on <a href="http://ahmedbesbes.com"> my blog</a>.
11
It also contains the matieral of a series of posts I wrote on <a href="http://ahmedbesbes.com"> my blog</a>.
12
12
13
## Dataset: MRNet 
13
## Dataset: MRNet 
14
14
15
The data comes from Stanford ML Group research lab. It consits of 1,370 knee MRI exams performed at Stanford University Medical Center to study the presence of Anterior Cruciate Ligament (ACL) tears.
15
The data comes from Stanford ML Group research lab. It consits of 1,370 knee MRI exams performed at Stanford University Medical Center to study the presence of Anterior Cruciate Ligament (ACL) tears.
16
16
17
For more information about the ACL tear problem and the MRNet data please refer to my blog post where you can investigate the data and build the following data visualization in jupyter notebook:
17
For more information about the ACL tear problem and the MRNet data please refer to my blog post where you can investigate the data and build the following data visualization in jupyter notebook:
18
18
19
19
20
<p align="center">
20
21
    <img src="./images/mri.gif">
22
</p>
23
24
To learn more about the data and how to realize this visualization widget, read <a href="https://ahmedbesbes.com/automate-the-diagnosis-of-knee-injuries-with-deep-learning-part-1-an-overview-of-the-mrnet-dataset.html">my first post.</a>
21
To learn more about the data and how to realize this visualization widget, read <a href="https://ahmedbesbes.com/automate-the-diagnosis-of-knee-injuries-with-deep-learning-part-1-an-overview-of-the-mrnet-dataset.html">my first post.</a>
25
22
26
## Code structure:
23
## Code structure:
27
24
28
This charts summarizes the architecture of the project:
25
This charts summarizes the architecture of the project:
29
26
30
<img src="./images/pipeline.png">
27
31
32
For more details about the code, please refer to my second <a href="https://ahmedbesbes.com/automate-the-diagnosis-of-knee-injuries-with-deep-learning-part-2-building-an-acl-tear-classifier.html">blog post </a>.
28
For more details about the code, please refer to my second <a href="https://ahmedbesbes.com/automate-the-diagnosis-of-knee-injuries-with-deep-learning-part-2-building-an-acl-tear-classifier.html">blog post </a>.
33
29
34
## How to use the code:
30
## How to use the code:
35
31
36
If you want to retrain the network on your own you have to ask for the data from Stanford via this <a href="https://stanfordmlgroup.github.io/competitions/mrnet/">link</a>.
32
If you want to retrain the network on your own you have to ask for the data from Stanford via this <a href="https://stanfordmlgroup.github.io/competitions/mrnet/">link</a>.
37
33
38
Once you download the data, create a `data` folder and place it at the root of the project. You should have two folders inside: `train` and `valid` as well as a bunch of csv files.
34
Once you download the data, create a `data` folder and place it at the root of the project. You should have two folders inside: `train` and `valid` as well as a bunch of csv files.
39
35
40
To run the script you can execute it with the following arguments:
36
To run the script you can execute it with the following arguments:
41
37
42
```python
38
```python
43
parser = argparse.ArgumentParser()
39
parser = argparse.ArgumentParser()
44
parser.add_argument('-t', '--task', type=str, required=True,
40
parser.add_argument('-t', '--task', type=str, required=True,
45
                    choices=['abnormal', 'acl', 'meniscus'])
41
                    choices=['abnormal', 'acl', 'meniscus'])
46
parser.add_argument('-p', '--plane', type=str, required=True,
42
parser.add_argument('-p', '--plane', type=str, required=True,
47
                    choices=['sagittal', 'coronal', 'axial'])
43
                    choices=['sagittal', 'coronal', 'axial'])
48
parser.add_argument('--augment', type=int, choices=[0, 1], default=1)
44
parser.add_argument('--augment', type=int, choices=[0, 1], default=1)
49
parser.add_argument('--lr_scheduler', type=int, choices=[0, 1], default=1)
45
parser.add_argument('--lr_scheduler', type=int, choices=[0, 1], default=1)
50
parser.add_argument('--epochs', type=int, default=50)
46
parser.add_argument('--epochs', type=int, default=50)
51
parser.add_argument('--lr', type=float, default=1e-5)
47
parser.add_argument('--lr', type=float, default=1e-5)
52
parser.add_argument('--flush_history', type=int, choices=[0, 1], default=0)
48
parser.add_argument('--flush_history', type=int, choices=[0, 1], default=0)
53
parser.add_argument('--save_model', type=int, choices=[0, 1], default=1)
49
parser.add_argument('--save_model', type=int, choices=[0, 1], default=1)
54
parser.add_argument('--patience', type=int, choices=[0, 1], default=5)
50
parser.add_argument('--patience', type=int, choices=[0, 1], default=5)
55
```
51
```
56
52
57
example to train a model to detect acl tears on the sagittal plane for a 20 epochs:
53
example to train a model to detect acl tears on the sagittal plane for a 20 epochs:
58
54
59
`python -t acl -p sagittal --epochs=20`
55
`python -t acl -p sagittal --epochs=20`
60
56
61
Note: Before running the script, add the following (empty) folders at the root of the project:
57
Note: Before running the script, add the following (empty) folders at the root of the project:
62
- models
58
- models
63
- logs
59
- logs
64
60
65
61
66
## Results:
62
## Results:
67
63
68
I trained an ACL tear classifier on a sagittal plane and got the following AUC scores:
64
I trained an ACL tear classifier on a sagittal plane and got the following AUC scores:
69
65
70
- on train: 0.8669
66
- on train: 0.8669
71
- on validation: 0.8850
67
- on validation: 0.8850
72
68
73
Logs on Tensorboard:
69
Logs on Tensorboard:
74
70
75
<img src="./images/sagittal_tensorboard.png">
71
76
77
78
## Contributions - PR are welcome:
72
## Contributions - PR are welcome:
79
73
80
If you feel that some functionalities or improvements could be added to the project, don't hesitate to submit a pull request.
74
If you feel that some functionalities or improvements could be added to the project, don't hesitate to submit a pull request.
81
75