Diff of /README.md [000000] .. [72c114]

Switch to unified view

a b/README.md
1
 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 
2
 [![Docker build passing](https://img.shields.io/badge/docker%20build-passing-brightgreen)](https://github.com/KibromBerihu/ai4elife/blob/main/Dockerfile) 
3
4
# News!  
5
## Please refer to [this link](https://github.com/KibromBerihu/MIPsegmentatorV1) for the new 2D version, which has been trained on more data (~2K data), and the 3D version of the method. It provides both the 2D MIP and 3D segmentations. 
6
7
8
## *AI4eLIFE: Artificial Intelligence for Efficient Learning-based Image Feature Extraction.*
9
10
#### <a name="introduction"> </a> [πŸ“‘](https://jnm.snmjournals.org/content/early/2022/06/16/jnumed.121.263501) *Fully automated tumor lesions segmentation in whole-body PET/CT images using data-centric artificial intelligence and fully automatically calculating the clinical endpoints.*
11
12
***Introduction:***
13
Baseline 18F-FDG PET/CT image-driven features have shown predictive values in Diffuse Large B-cell lymphoma (DLBCL)
14
patients. Notably, total metabolic active tumor volume (TMTV) and tumor dissemination (Dmax) have shown predictive values to
15
characterize tumor burden and dissemination. However, TMTV and Dmax calculation require tumor volume 
16
delineation over the whole-body 3D 18F-FDG PET/CT images, which is prone to observer-variability and complicates using these quantitative features in clinical routine. In this regard, we hypothesized that tumor burden and spread could 
17
be automatically evaluated from only two PET Maximum Intensity Projections (MIPs) images corresponding to coronal and 
18
sagittal views, thereby easy the calculation and validation of these features. 
19
20
Here, we developed data-driven AI to calculate surrogate biomarkers for DLBCL patients automatically. Briefly, first, the (3D)
21
18F-FDG PET images were projected in the coronal and sagittal directions. The projected PET MIP images are then fed to 
22
an AI algorithm to segment lymphoma regions automatically. From the segmented images, the surrogate TMTV (sTMTV) and 
23
surrogate Dmax (sDmax) are calculated and evaluated in terms of predictions for overall survival (OS) and 
24
progression-free survival (PFS).
25
26
![flow-digaram](https://github.com/KibromBerihu/ai4elife/blob/main/images/graphical-abstract.JPG)
27
28
*Figure 1: Flow diagram of the proposed data-centric AI to measure prognostic biomarkers automatically.*
29
30
***Results:***
31
Tested on an independent testing cohort (174 patients), the AI yielded a 0.86 median Dice score (IQR: 0.77-0.92), 87.9%
32
(IQR: 74.9.0%-94.4%) sensitivity, and 99.7% (IQR: 99.4%-99.8%) specificity. The PET MIP AI-driven surrogate biomarkers (sTMTV) and sDmax were highly correlated to the 3D 18F-FDG PET-driven biomarkers
33
(TMTV and Dmax) in both the training-validation cohort and the independent testing cohort. These PET MIP AI-driven 
34
features can be used to predict the OS and PFS in DLBCL patients, equivalent to the expert-driven 3D features. 
35
36
***Deep learning Model:*** 
37
We adapted the deep learning-based robust medical image segmentation method [LFBNet](https://doi.org/10.1109/TMI.2021.3060497).
38
Please refer to the [paper](https://doi.org/10.1109/TMI.2021.3060497) 
39
for details, and cite the paper if you use lfbnet for your research. 
40
41
[comment]: <![img_7.png](img_7.png)>
42
43
***Integrated framework:***
44
The whole pipeline, including the generation of PET MIPs, automatic segmentation, and sTMTV and sDmax calculation, is developed 
45
for a use case on personal/desktop computers or clusters. It could highly facilitate the analysis of PET MIP-based features 
46
leading to the potential translation of these features into clinical practice. 
47
48
Please refer to the paper for details and cite the paper if you use LFBNet for your research. 
49
50
### Table of contents  
51
- [Summary](#introduction)
52
- [Table of Contents](#table-of-contents)
53
- [ Required folder structure](#-required-folder-structure)
54
- [Installation](#installation)
55
- [Usage](#-usage)
56
  - [Easy use: testing mode](#easy-use-testing-mode)
57
  - [Transfer learning mode: development](#transfer-learning-mode-developmenttranserlearning)
58
- [Results](#-results)
59
- [FAQ](#-faq)
60
- [Citations](#-citations)
61
- [Adapting LFBNet for other configurations or segmentation tasks](#-how-to-configure-an-extended-lfbnet-for-other-2d-based-medical-image-segmentation)
62
- [Useful resources](#useful-resources) 
63
- [Acknowledgements](#-acknowledgments)
64
65
## πŸ“ Required folder structure
66
Please provide all data in a single directory. The method automatically analyses all given data batch-wise. 
67
68
To run the program, you only need PET scans (CT is not required) of patients in nifty format, where the PET images are coded in SUV units. If your images have already been segmented, you can also provide the mask (ground truth (gt)) as a binary image in nifty format. Suppose you provided ground truth (gt) data; it will print the dice, sensitivity, and specificity metrics between the reference segmentation by the expert (i.e., gt) and the predicted segmentation by the model. If the ground truth is NOT AVAILABLE, the model will only predict the segmentation. 
69
70
A typical data directory might look like:
71
72
73
    |-- main_folder                                             <-- The main folder or all patient folders (Give it any NAME)
74
75
    |      |-- parent folder (patient_folder_1)             <-- Individual patient folder name with unique id
76
    |           |-- pet                                     <-- The pet folder for the .nii suv file
77
                     | -- name.nii or name.nii.gz            <-- The pet image in nifti format (Name can be anything)
78
    |           |-- gt                                      <-- The corresponding ground truth folder for the .nii file  
79
                     | -- name.nii or name.nii.gz            <-- The ground truth (gt) image in nifti format (Name can be anything)
80
    |      |-- parent folder (patient_folder_2)             <-- Individual patient folder name with unique id
81
    |          |-- gt                                     <-- The pet folder for the .nii suv file
82
                    | -- name.nii or name.nii.gz            <-- The pet image in nifti format (Name can be anything)
83
    |         |-- pet                                      <-- The corresponding ground truth folder for the .nii file  
84
                    | -- name.nii or name.nii.gz            <-- The ground truth (gt) image in nifti format (Name can be anything)
85
    |           .
86
    |           .
87
    |           .
88
    |      |-- parent folder (patient_folder_N)             <-- Individual patient folder name with unique id
89
    |           |-- pet                                     <-- The pet folder for the .nii suv file
90
                    | -- name.nii or name.nii.gz            <-- The pet image in nifti format (Name can be anything)
91
    |           |-- gt                                      <-- The corresponding ground truth folder for the .nii file  
92
                    | -- name.nii or name.nii.gz            <-- The ground truth (gt) image in nifti format (Name can be anything)
93
94
95
 **Note:** the folder name for PET images should be `pet` and for the ground truth `gt`. All other folder and sub-folder names could be anything. 
96
97
## βš™οΈ  Installation <a name="installation"> </a>
98
  
99
Please read the documentation before opening an issue! 
100
101
<font size='4'> Download/clone code to your local computer </font> 
102
103
104
    - git clone https://github.com/KibromBerihu/ai4elife.git
105
   
106
    - Alternatively:
107
      1. go to https://github.com/KibromBerihu/ai4elife.git >> [Code] >> Download ZIP file.
108
 
109
      
110
111
112
   1) <font size ="4">To install in virtual environment </font>  
113
       1) We recommend you to create virtual environment. please refer to [THIS](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) regarding how to create a virtual environment using 
114
         conda.  
115
       2) Open terminal or Anaconda Prompt <br/><br>
116
       3) Change the working directory to the downloaded and unzipped ai4elife folder <br/><br>
117
       4) Create the virtual environment provided in the requirements.yaml: 
118
      
119
           `conda env create -f environment.yml`
120
      <br/><br>
121
       5) If you choose to use a virtual environment, the virtual environment must be activated before executing any script:
122
      
123
           `conda activate myenv`
124
      <br/><br>
125
       6) Verify the virtual environment was installed correctly:
126
   
127
            `conda info --envs`
128
      
129
           <font size='2'>  If you can see the virtual environment with a name 'myenv', well done, the virtual environment and dependencies are installed successfully. </font>
130
131
         
132
133
   2) <font size ="4"> Using docker image: building image from docker file [REPRODUCIBLE] </font> <br/><br>
134
      
135
      1) Assuming you already have [docker desktop](https://www.docker.com/) installed. For more information, kindly refer to [THIS](https://docs.docker.com/). 
136
      
137
      2) Make sure to change the directory to the downloaded and unzipped ai4elife directory. 
138
      <br/><br>
139
      3) Run the following commands to create a docker image with the name <DockerImageName>:<Tag>'
140
      <br/><br>
141
142
         `docker build -t <DockerImageName>:<Tag> .`
143
144
 
145
## πŸ’» Usage
146
This package has two usages. 
147
The first one is to segment tumor regions and then calculate the surrogate biomarkers such as sTMTV and sDmax on the given test dataset using the pre-trained weights, named as "easy use case". 
148
The second use case is transfer learning or retraining from scratch on your own dataset.
149
150
 
151
### [Easy use: testing mode](#virtual) <a name="easy-use-testing-mode"> </a> 
152
153
Please make sure that you organized your data as in the [Required folder structure](#-required-folder-structure).
154
### For reproducibility and better accuracy, please use OPTION 2. 
155
1. **Option 1:** Using the virtual environment: <br/><br>
156
    1. Change to the source directory: `cd  path/to/ai4elife/` <br/><br>
157
    2. Activate the virtual environment:    `conda activate myenv` <br/><br>
158
 
159
    3. Run:  `python test_env.py  --input_dir path/to/input/  --output_dir path/to/output/` 
160
   <br/><br>
161
2. **Option 2:** Using the docker: <br/><br>
162
   
163
    Option 1:`run_docker_image.bat path/to/input path/to/output  <docker_image_name> <Tag>  <container_id>`
164
    <br/><br>
165
    Option 2: `docker run -it --rm --name <container_id> -v path/to/input/:/input -v path/to/output/:/output <docker_image_name>:<Tag>`
166
    <br/><br>
167
 
168
### [Transfer learning mode: development](#transerlearning) <a name="transfer-learning-mode-developmenttranserlearning"> </a>  
169
 
170
To apply transfer learning by using the trained weights or training the deep learning method from scratch,
171
we recommend following the virtual environment-based [installation](#installation) option.
172
173
Run the following commands for activating the virtual environment, and then training, validating, and testing of the proposed model on your own dataset.
174
175
1. Activate the virtual environment:
176
   `conda activate myenv`
177
<br/><br>
178
2. To [train](#train) the model from a new dataset, change to the `ai4elife/src` directory: <br/><br>
179
   
180
   `python train.py --input_dir path/to/training_validation_data/  --data_id <unique_data_name> --task <train>`
181
<br/><br>
182
3. To [evaluate](#evaluate) on the validation data: <br/><br>
183
    `python train.py --input_dir path/to/validation_data/  --data_id <unique_data_name> --task <valid>`
184
<br/><br>
185
186
**Note:** You can also **configure** the deep learning model for **parameter and architectural search**. Please refer to the documentation
187
[configuration](architectural_and_parameter_search.md). Briefly, you can apply different features, kernel size in the convolution, depth of the neural networks, and other hyperparameters values. The segmentation 
188
model is designed in easy configurable mode. 
189
   
190
## πŸ“ˆ Results
191
192
- Two intermediate folders will be generated.
193
194
  - The resized and cropped 3D PET, and corresponding ground truth  Nifti images are saved under the folder name:
195
                  
196
      ```../output/data_default_3d_dir```, and 
197
  
198
  - The generated corresponding sagittal and coronal images are saved in the folder name       
199
``../output/data_default_mip_dir``.
200
  
201
  - For simplicity, the coronal PET MIP images are `pet_coronal.nii`, sagittal as `pet_sagittal.nii`, and corresponding ground truth as `ground_truth_coronal.nii`, and `ground_truth_sagittal.nii`, respectively.
202
  
203
  - NOTE: if there is no ground truth, it will only generate the coronal and sagittal PET MIPs. 
204
  Kindly check if these generated files are in order.
205
  
206
  
207
- Predicted results including predicted segmentation masks and calculated surrogate biomarekrs (sTMTV and sDmax) will be saved into the folder `output/.*`. 
208
209
 - Predicted masks are saved under the folder name `output/predicted/.*`. The predicted masks are indicated with the keyword `predicted` in the file name, and the input PET images are indicated with the keyword `pet`. For example, `patient_id_predicted.nii` for predicted mask of `patient_id` and `patient_id_pet.nii` for the PET images. If the ground truths are given, they are saved with the name `patient_id_ground_truth.nii`. Each .nii file has both sagittal and coronal views Each .nii file has both sagittal and coronal views concatenated.  
210
 
211
- Surrogate biomarkers (sTMTV and sDmax) will be automatically calculated and saved as an EXCEL file inside the folder output/*.csv. Two EXCEL files will be saved. The first one constitutes computed surrogate biomarkers calculated from the segmentation masks predicted from AI with an indicator `predicted` in the file name. The second EXCEL file would constitute the surrogate biomarkers computed from the reference segmentation masks (i.e., ground truth) from the expert (if available) with an indicator `ground_truth` in the file name. In addition to the `predicted` and `ground truth` indicator names, the CSV file's name also constitutes an automatically generated month, year, and the processing time.
212
213
214
## πŸ™‹ FAQ
215
Please visit the [FAQ](./documentation/FAQ.md) samples before creating an issue. 
216
217
## πŸ“– Citations 
218
Please cite the following papers if you use this package for your research:
219
```
220
Girum KB, Rebaud L, Cottereau A-S, et al. 18 F-FDG PET maximum intensity projections and artificial intelligence: a win-win combination to easily measure prognostic biomarkers in DLBCL patients. J Nucl Med. June 2022:jnumed.121.263501. DOI: https://doi.org/10.2967/jnumed.121.263501 
221
```
222
```
223
 Girum KB, CrΓ©hange G, Lalande A. Learning with context feedback loop for robust medical image segmentation. IEEE Transactions on Medical Imaging. 2021 Feb 19;40(6):1542-54. DOI: https://doi.org/10.1109/TMI.2021.3060497
224
```
225
226
## πŸ’­ How to configure an extended LFBNet for other 2D-based medical image segmentation? 
227
LFBNet is provided as a configurable network for 2D image-based multi-class and single-class segmentations.
228
Please refer to [THIS](./documentation/tutorial/jupyter_notebook_step_by_step_illustration.ipynb) guide. 
229
230
231
## πŸ’οΈ<a name="useful-resources"> </a> Useful resources
232
- The detailed step-by-step for preprocessing, dataset split into training and validation cohorts, and visualization of results are demonstrated in the [jupyter_notebook_step_by_step_illustration.ipynb](./documentation/tutorial/jupyter_notebook_step_by_step_illustration.ipynb).
233
234
## πŸ™ Acknowledgments
235
We thank you [the reader].  
236
237