Diff of /readme.md [000000] .. [cb5984]

Switch to unified view

a b/readme.md
1
# HD-GLIO
2
3
## Introduction
4
5
This repository provides easy to use access to our HD-GLIO brain tumor segmentation tool. HD-GLIO is the result of a 
6
joint project between the Department of Neuroradiology at the Heidelberg University Hospital, Germany and the 
7
Division of Medical Image Computing at the German Cancer Research Center (DKFZ) Heidelberg, Germany. If you are using 
8
HD-GLIO, please cite the following two publications:
9
10
- Kickingereder P, Isensee F, Tursunova I, Petersen J, Neuberger U, Bonekamp D, Brugnara G, Schell M, Kessler T, 
11
Foltyn M, Harting I, Sahm F, Prager M, Nowosielski M, Wick A, Nolden M, Radbruch A, Debus J, Schlemmer HP, Heiland S, 
12
Platten M, von Deimling A, van den Bent MJ, Gorlia T, Wick W, Bendszus M, Maier-Hein KH. Automated quantitative tumour 
13
response assessment of MRI in neuro-oncology with artificial neural networks: a multicentre, retrospective study. 
14
Lancet Oncol. 2019 May;20(5):728-740. (https://doi.org/10.1016/S1470-2045(19)30098-1)
15
- Isensee F, Petersen J, Kohl SAA, Jaeger PF, Maier-Hein KH. nnU-Net: Breaking the Spell on 
16
Successful Medical Image Segmentation. arXiv preprint 2019 arXiv:1904.08128. (https://arxiv.org/abs/1904.08128)
17
18
HD-GLIO was developed with 3220 MRI examinations from 1450 brain tumor patients (80% for training and 20% for testing). 
19
Specifically the data included:
20
1) a single-institutional retrospective dataset with 694 MRI examinations from 495 patients acquired at the 
21
Department of Neuroradiology, Heidelberg University Hospital, Germany (corresponding to the “Heidelberg training 
22
dataset and Heidelberg test dataset” described in Kickingereder et al. Lancet Oncol. 2019)
23
2) a multicentric clinical trial dataset with 2034 MRI examinations from 532 patients acquired across 34 institutions 
24
in Europe  (corresponding to the “EORTC-26101 test dataset” described in Kickingereder et al. Lancet Oncol. 2019)
25
3) a single-institutional retrospective dataset with 492 MRI examinations from 423 patients (80% glial brain tumors, 
26
20% other histological entities) undergoing routine MRI at different stages of the disease (including 79 early 
27
postoperative MRI scans acquired <72h after surgery) at the Department of Neuroradiology, Heidelberg University 
28
Hospital, Germany 
29
 
30
Specifically, each MRI examination included precontrast T1-weighted, postcontrast T1-weighted, T2-weighted and FLAIR 
31
sequences (all sequences brain extracted and co-registered) as well as corresponding ground-truth tumor segmentation 
32
masks. HD-GLIO performs brain tumor segmentation for contrast-enhancing tumor and non-enhancing T2/FLAIR signal 
33
abnormality. We applied a variant of the nnU-Net ('no-new-Net') framework (as described in Isensee et al. arXiv preprint 2019) 
34
for training the HD-GLIO algorithm.
35
36
HD-GLIO is very fast on GPU with <10s run time per MRI examination. 
37
38
## Installation Instructions
39
40
###  Installation Requirements
41
Unlike HD-BET, HD-GLIO requires a GPU to perform brain tumor segmentation. Any GPU with 4 GB of VRAM and cuda/pytorch 
42
support will do. 
43
Running the prediction on CPU is not supported.
44
45
### Installation with Pip
46
Installation with pip is quick an easy, just run the following command and everything will be done for you:
47
48
`pip install hd_glio`
49
50
### Manual installation
51
If you intend to modify HD-GLIO, you can also install is manually:
52
53
1) Clone this repository:
54
    
55
    `git clone https://github.com/MIC-DKFZ/HD-GLIO`
56
57
2) Go into the repository (the folder with the setup.py file) and install:
58
59
    `cd HD-GLIO`
60
61
    `pip install -e .`
62
63
Per default, model parameters will be downloaded to ~/.hd_glio_params. If you wish to use a different folder, open 
64
hd_glio/paths.py in a text editor and modify folder_with_parameter_files.
65
66
67
Both manual and pip installation will install two commands with which you can use HD-GLIO from anywhere in your 
68
system: `hd_glio_predict` and `hd_glio_predict_folder`.
69
70
## How to use it
71
Using HD_GLIO is straightforward. You can use it in any terminal on your linux system. The `hd_glio_predict` and 
72
`hd_glio_predict_folder` commands were installed automatically. HD-GLIO requires a GPU with at least 4 GB of VRAM to run. 
73
74
### Prerequisites
75
HD-GLIO was trained with four MRI modalities: T1, constrast-enhanced T1, T2 and FLAIR. All these modalities must be present
76
in order to run HD-GLIO. 
77
78
All input files must be provided as nifti (.nii.gz) files containing 2D or 3D MRI image data. Sequences with 
79
multiple temporal volumes (i.e. 4D sequences) are not supported (however can be splitted upfront into the individual 
80
temporal volumes using fslsplit1). 
81
82
- INPUT_T1 must be a T1-weighted sequence before contrast-agent administration (T1-w) acquired as 2D with axial 
83
orientation (e.g. TSE) or as 3D (e.g. MPRAGE)
84
- INPUT_CT1 must be a T1-weighted sequence after contrast-agent administration (cT1-w) acquired as 2D with axial 
85
orientation (e.g. TSE) or as 3D (e.g. MPRAGE)
86
- INPUT_T2 must be a T2-weighted sequence (T2-w) acquired as 2D 
87
- INPUT_FLAIR must be a fluid attenuated inversion recovery (FLAIR) sequence acquired as 2D with axial orientation
88
 (e.g. TSE). A 3D acquisition (e.g. 3D TSE/FSE) may work as well.
89
 
90
(These specifications are in line with the consensus recommendations for a standardized brain tumor imaging protocol 
91
in clinical trials - see Ellingson et al. Neuro Oncol. 2015 Sep;17(9):1188-98 - www.ncbi.nlm.nih.gov/pubmed/26250565)
92
93
Input files must contain 3D images; Sequences with multiple temporal volumes (i.e. 4D sequences) are not supported 
94
(however can be splitted upfront into the individual temporal volumes using fslsplit<sup>1</sup>).
95
96
All input files must match the orientation of standard MNI152 template and must be brain extracted and co-registered. 
97
All non-brain voxels must be 0.
98
To ensure that these pre-processing steps are performed correctly you may adhere to the following example:
99
100
##### Reorient MRI sequences to standard space
101
102
```
103
fslreorient2std T1.nii.gz T1_reorient.nii.gz
104
fslreorient2std CT1.nii.gz CT1_reorient.nii.gz
105
fslreorient2std T2.nii.gz T2_reorient.nii.gz
106
fslreorient2std FLAIR.nii.gz FLAIR_reorient.nii.gz
107
```
108
109
##### The following is the recommended workflow for FSL5. There is a better way to do this but this requires FSL6 (see below)
110
```
111
# perform brain extraction using HD-BET (https://github.com/MIC-DKFZ/HD-BET)
112
hd-bet -i T1_reorient.nii.gz
113
hd-bet -i CT1_reorient.nii.gz
114
hd-bet -i T2_reorient.nii.gz
115
hd-bet -i FLAIR_reorient.nii.gz 
116
117
# register all sequences to T1
118
fsl5.0-flirt -in CT1_reorient_bet.nii.gz -ref T1_reorient_bet.nii.gz -out CT1_reorient_bet_reg.nii.gz -dof 6 -interp spline
119
fsl5.0-flirt -in T2_reorient_bet.nii.gz -ref T1_reorient.nii.gz -out T2_reorient_bet_reg.nii.gz -dof 6 -interp spline
120
fsl5.0-flirt -in FLAIR_reorient_bet.nii.gz -ref T1_reorient.nii.gz -out FLAIR_reorient_bet_reg.nii.gz -dof 6 -interp spline
121
122
# reapply T1 brain mask (this is important because HD-GLIO expects non-brain voxels to be 0 and the registration 
123
process can introduce nonzero values
124
# T1_BRAIN_MASK.nii.gz is the mask (not the brain extracted image!) as obtained from HD-Bet
125
fsl5.0-fslmaths CT1_reorient_bet_reg.nii.gz -mas T1_BRAIN_MASK.nii.gz CT1_reorient_bet_reg.nii.gz
126
fsl5.0-fslmaths T2_reorient_bet_reg.nii.gz -mas T1_BRAIN_MASK.nii.gz T2_reorient_bet_reg.nii.gz
127
fsl5.0-fslmaths FLAIR_reorient_bet_reg.nii.gz -mas T1_BRAIN_MASK.nii.gz FLAIR_reorient_bet_reg.nii.gz
128
```
129
130
##### This is how to do it with FSL6:
131
```
132
# run hd bet
133
hd-bet -i T1_reorient.nii.gz -o t1_bet.nii.gz -s 1
134
hd-bet -i CT1_reorient.nii.gz -o ct1_bet.nii.gz
135
hd-bet -i T2_reorient.nii.gz -o t2_bet.nii.gz
136
hd-bet -i FLAIR_reorient.nii.gz -o flair_bet.nii.gz
137
138
# register brain extracted images to t1, save matrix
139
flirt -in ct1_bet.nii.gz -out ct1_bet_reg.nii.gz -ref t1_bet.nii.gz -omat ct1_to_t1.mat -interp spline -dof 6 &
140
flirt -in t2_bet.nii.gz -out t2_bet_reg.nii.gz -ref t1_bet.nii.gz -omat t2_to_t1.mat -interp spline -dof 6 &
141
flirt -in flair_bet.nii.gz -out flair_bet_reg.nii.gz -ref t1_bet.nii.gz -omat flair_to_t1.mat -interp spline -dof 6 &
142
wait
143
144
# we are only interested in the matrices, delete the other output images
145
rm ct1_bet.nii.gz t2_bet.nii.gz flair_bet.nii.gz
146
rm ct1_bet_reg.nii.gz t2_bet_reg.nii.gz flair_bet_reg.nii.gz
147
148
# now apply the transformation matrices to the original images (pre hd-bet)
149
flirt -in CT1_reorient.nii.gz -out ct1_reg.nii.gz -ref t1_bet.nii.gz -applyxfm -init ct1_to_t1.mat -interp spline &
150
flirt -in T2_reorient.nii.gz -out t2_reg.nii.gz -ref t1_bet.nii.gz -applyxfm -init t2_to_t1.mat -interp spline &
151
flirt -in FLAIR_reorient.nii.gz -out flair_reg.nii.gz -ref t1_bet.nii.gz -applyxfm -init flair_to_t1.mat -interp spline &
152
wait
153
154
# now apply t1 brain mask to all registered images
155
fslmaths ct1_reg.nii.gz -mas t1_bet_mask.nii.gz CT1_reorient_reg_bet.nii.gz & # t1_bet_mask.nii.gz was generated by hd-bet (see above)
156
fslmaths t2_reg.nii.gz -mas t1_bet_mask.nii.gz T2_reorient_reg_bet.nii.gz & # t1_bet_mask.nii.gz was generated by hd-bet (see above)
157
fslmaths flair_reg.nii.gz -mas t1_bet_mask.nii.gz FLAIR_reorient_reg_bet.nii.gz & # t1_bet_mask.nii.gz was generated by hd-bet (see above)
158
wait
159
160
# done
161
```
162
163
After applying this example you would use `T1_reorient.nii.gz`, `CT1_reorient_reg_bet.nii.gz`, `T2_reorient_reg_bet.nii.gz` 
164
and `FLAIR_reorient_reg_bet.nii.gz` to proceed.
165
166
167
### Run HD-GLIO
168
HD-GLIO provides two main scripts: `hd_glio_predict` and `hd_glio_predict_folder`.
169
170
#### Predicting a single case
171
`hd_glio_predict` can be used to predict a single case. It is useful for exploration or if the number of cases to be 
172
procesed is low. Here is how to use it:
173
174
`hd_glio_predict -t1 T1_FILE -t1c CT1_FILE -t2 T2_FILE -flair FLAIR_FILE -o OUTPUT_FILE`
175
176
T1_FILE, CT1_FILE, T2_FILE, FLAIR_FILE and OUTPUT_FILE must all be niftis (end with .nii.gz). The four input files must 
177
be preprocesed as specified in *How to use it - Prerequisites* (ses above). 
178
179
#### Predicting multiple cases
180
`hd_glio_predict_folder` is useful for batch processing, especially if the number of cases to be processed is large. By 
181
interleaving preprocessing, inference and segmentation export we can speed up the prediction significantly. Furthermore, 
182
the pipeline is initialized only once for all cases, again saving a lot of computation time.  Here is how to use it:
183
184
`hd_glio_predict_folder -i INPUT_FOLDER -o OUTPUT_FOLDER`
185
186
INPUT_FOLDER hereby contains the T1, T1c, T2 and FLAIR images. In order to ensure that HD-GLIO correctly assigns 
187
filenames to modalities, you **must** apply the following naming convention to your data
188
189
- INPUT_T1: PATIENT_IDENTIFIER_0000.nii.gz
190
- INPUT_CT1: PATIENT_IDENTIFIER_0001.nii.gz
191
- INPUT_T2: PATIENT_IDENTIFIER_0002.nii.gz
192
- INPUT_FLAIR: PATIENT_IDENTIFIER_0003.nii.gz
193
194
Hereby, PATIENT_IDENTIFIER can be anything. You can use an arbitrary number of patients (by using a different 
195
PATIENT_IDENTIFIER for each patient). Predicted segmentations will be saved as `PATIENT_IDENTIFIER.nii.gz` in the 
196
OUTPUT_FOLDER
197
198
199
<sup>1</sup>https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Fslutils