monai
medical
katielink commited on
Commit
df412c9
1 Parent(s): da44a57

add support for raw images

Browse files
README.md CHANGED
@@ -15,32 +15,39 @@ LUNA16 is a public dataset of CT lung nodule detection. Using raw CT scans, the
15
 
16
  Disclaimer: We are not the host of the data. Please make sure to read the requirements and usage policies of the data and give credit to the authors of the dataset!
17
 
18
- ## Data
 
19
  The dataset we are experimenting in this example is LUNA16 (https://luna16.grand-challenge.org/Home/), which is based on [LIDC/IDRI database](https://wiki.cancerimagingarchive.net/display/Public/LIDC-IDRI) [3,4,5].
20
 
21
  LUNA16 is a public dataset of CT lung nodule detection. Using raw CT scans, the goal is to identify locations of possible nodules, and to assign a probability for being a nodule to each location.
22
 
23
  Disclaimer: We are not the host of the data. Please make sure to read the requirements and usage policies of the data and give credit to the authors of the dataset! We acknowledge the National Cancer Institute and the Foundation for the National Institutes of Health, and their critical role in the creation of the free publicly available LIDC/IDRI Database used in this study.
24
 
 
25
  We follow the official 10-fold data splitting from LUNA16 challenge and generate data split json files using the script from [nnDetection](https://github.com/MIC-DKFZ/nnDetection/blob/main/projects/Task016_Luna/scripts/prepare.py).
26
- The resulted json files can be downloaded from https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/LUNA16_datasplit-20220615T233840Z-001.zip.
 
 
27
  In these files, the values of "box" are the ground truth boxes in world coordinate.
28
 
 
29
  The raw CT images in LUNA16 have various of voxel sizes. The first step is to resample them to the same voxel size.
30
- In this model, we resampled them into 0.703125 x 0.703125 x 1.25 mm. The code of resampling can be found in Section 3.1 of https://github.com/Project-MONAI/tutorials/tree/main/detection
 
 
31
 
32
- ## Training configuration
33
  The training was performed with at least 12GB-memory GPUs.
34
 
35
  Actual Model Input: 192 x 192 x 80
36
 
37
- ## Input and output formats
38
  Input: list of 1 channel 3D CT patches
39
 
40
  Output: dictionary of classification and box regression loss in training mode;
41
  list of dictionary of predicted box, classification label, and classification score in evaluation mode.
42
 
43
- ## Scores
44
  The script to compute FROC sensitivity value on inference results can be found in https://github.com/Project-MONAI/tutorials/tree/main/detection
45
 
46
  This model achieves the following FROC sensitivity value on the validation data (our own split from the training dataset):
@@ -53,28 +60,26 @@ This model achieves the following FROC sensitivity value on the validation data
53
 
54
  **Table 1**. The FROC sensitivity values at the predefined false positive per scan thresholds of the LUNA16 challenge.
55
 
56
- ## commands example
57
  Execute training:
58
-
59
  ```
60
  python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf
61
  ```
62
 
63
  Override the `train` config to execute evaluation with the trained model:
64
-
65
  ```
66
  python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf
67
  ```
68
 
69
- Execute inference:
70
-
71
  ```
72
  python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf
73
  ```
 
74
 
75
- Note that in inference.json, the transform "AffineBoxToWorldCoordinated" in "postprocessing" has `"affine_lps_to_ras": true`.
76
- This depends on the input images. It is possible that your inference dataset should set "affine_lps_to_ras": false.
77
- Please set it as `true` only when the original images were read by itkreader with affine_lps_to_ras=True.
78
 
79
 
80
  # Disclaimer
 
15
 
16
  Disclaimer: We are not the host of the data. Please make sure to read the requirements and usage policies of the data and give credit to the authors of the dataset!
17
 
18
+ ## 1. Data
19
+ ### 1.1 Data description
20
  The dataset we are experimenting in this example is LUNA16 (https://luna16.grand-challenge.org/Home/), which is based on [LIDC/IDRI database](https://wiki.cancerimagingarchive.net/display/Public/LIDC-IDRI) [3,4,5].
21
 
22
  LUNA16 is a public dataset of CT lung nodule detection. Using raw CT scans, the goal is to identify locations of possible nodules, and to assign a probability for being a nodule to each location.
23
 
24
  Disclaimer: We are not the host of the data. Please make sure to read the requirements and usage policies of the data and give credit to the authors of the dataset! We acknowledge the National Cancer Institute and the Foundation for the National Institutes of Health, and their critical role in the creation of the free publicly available LIDC/IDRI Database used in this study.
25
 
26
+ ### 1.2 10-fold data splitting
27
  We follow the official 10-fold data splitting from LUNA16 challenge and generate data split json files using the script from [nnDetection](https://github.com/MIC-DKFZ/nnDetection/blob/main/projects/Task016_Luna/scripts/prepare.py).
28
+
29
+ Please download the resulted json files from https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/LUNA16_datasplit-20220615T233840Z-001.zip.
30
+
31
  In these files, the values of "box" are the ground truth boxes in world coordinate.
32
 
33
+ ### 1.3 Data resampling
34
  The raw CT images in LUNA16 have various of voxel sizes. The first step is to resample them to the same voxel size.
35
+ In this model, we resampled them into 0.703125 x 0.703125 x 1.25 mm.
36
+
37
+ Please following the instruction in Section 3.1 of https://github.com/Project-MONAI/tutorials/tree/main/detection to do the resampling.
38
 
39
+ ## 2. Training configuration
40
  The training was performed with at least 12GB-memory GPUs.
41
 
42
  Actual Model Input: 192 x 192 x 80
43
 
44
+ ## 3. Input and output formats
45
  Input: list of 1 channel 3D CT patches
46
 
47
  Output: dictionary of classification and box regression loss in training mode;
48
  list of dictionary of predicted box, classification label, and classification score in evaluation mode.
49
 
50
+ ## 4. Results and Scores
51
  The script to compute FROC sensitivity value on inference results can be found in https://github.com/Project-MONAI/tutorials/tree/main/detection
52
 
53
  This model achieves the following FROC sensitivity value on the validation data (our own split from the training dataset):
 
60
 
61
  **Table 1**. The FROC sensitivity values at the predefined false positive per scan thresholds of the LUNA16 challenge.
62
 
63
+ ## 5. Commands example
64
  Execute training:
 
65
  ```
66
  python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf
67
  ```
68
 
69
  Override the `train` config to execute evaluation with the trained model:
 
70
  ```
71
  python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf
72
  ```
73
 
74
+ Execute inference on resampled LUNA16 images (resampled following Section 3.1 of https://github.com/Project-MONAI/tutorials/tree/main/detection) by setting `"whether_raw_luna16": false` in `inference.json`:
 
75
  ```
76
  python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf
77
  ```
78
+ With the same command, we can execute inference on raw LUNA16 images by setting `"whether_raw_luna16": true` in `inference.json`. Remember to also set `"data_list_file_path": "$@bundle_root + '/LUNA16_datasplit/original/dataset_fold0.json'"` and change `"data_file_base_dir"`.
79
 
80
+ Note that in inference.json, the transform "LoadImaged" in "preprocessing" and "AffineBoxToWorldCoordinated" in "postprocessing" has `"affine_lps_to_ras": true`.
81
+ This depends on the input images. LUNA16 needs `"affine_lps_to_ras": true`.
82
+ It is possible that your inference dataset should set `"affine_lps_to_ras": false`.
83
 
84
 
85
  # Disclaimer
configs/inference.json CHANGED
@@ -1,4 +1,6 @@
1
  {
 
 
2
  "imports": [
3
  "$import glob",
4
  "$import os"
@@ -6,7 +8,7 @@
6
  "bundle_root": "./",
7
  "ckpt_dir": "$@bundle_root + '/models'",
8
  "output_dir": "$@bundle_root + '/eval'",
9
- "data_list_file_path": "$@bundle_root + '/annotation/dataset_fold0.json'",
10
  "data_file_base_dir": "/home/canz/Projects/datasets/LUNA16/93176/Images_resample",
11
  "test_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, is_segmentation=True, data_list_key='validation', base_dir=@data_file_base_dir)",
12
  "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
@@ -71,16 +73,18 @@
71
  "_target_": "Compose",
72
  "transforms": [
73
  {
74
- "_target_": "DeleteItemsd",
75
- "keys": [
76
- "box",
77
- "label"
78
- ]
79
  },
80
  {
81
  "_target_": "LoadImaged",
82
  "keys": "image",
83
- "meta_key_postfix": "meta_dict"
 
 
 
84
  },
85
  {
86
  "_target_": "EnsureChannelFirstd",
@@ -99,7 +103,8 @@
99
  0.703125,
100
  0.703125,
101
  1.25
102
- ]
 
103
  },
104
  {
105
  "_target_": "ScaleIntensityRanged",
 
1
  {
2
+ "whether_raw_luna16": false,
3
+ "whether_resampled_luna16": "$(not @whether_raw_luna16)",
4
  "imports": [
5
  "$import glob",
6
  "$import os"
 
8
  "bundle_root": "./",
9
  "ckpt_dir": "$@bundle_root + '/models'",
10
  "output_dir": "$@bundle_root + '/eval'",
11
+ "data_list_file_path": "$@bundle_root + '/LUNA16_datasplit/dataset_fold0.json'",
12
  "data_file_base_dir": "/home/canz/Projects/datasets/LUNA16/93176/Images_resample",
13
  "test_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, is_segmentation=True, data_list_key='validation', base_dir=@data_file_base_dir)",
14
  "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
 
73
  "_target_": "Compose",
74
  "transforms": [
75
  {
76
+ "_target_": "LoadImaged",
77
+ "keys": "image",
78
+ "meta_key_postfix": "meta_dict",
79
+ "_disabled_": "@whether_raw_luna16"
 
80
  },
81
  {
82
  "_target_": "LoadImaged",
83
  "keys": "image",
84
+ "meta_key_postfix": "meta_dict",
85
+ "reader": "itkreader",
86
+ "affine_lps_to_ras": true,
87
+ "_disabled_": "@whether_resampled_luna16"
88
  },
89
  {
90
  "_target_": "EnsureChannelFirstd",
 
103
  0.703125,
104
  0.703125,
105
  1.25
106
+ ],
107
+ "_disabled_": "@whether_resampled_luna16"
108
  },
109
  {
110
  "_target_": "ScaleIntensityRanged",
configs/metadata.json CHANGED
@@ -1,7 +1,8 @@
1
  {
2
  "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
3
- "version": "0.3.0",
4
  "changelog": {
 
5
  "0.3.0": "update license files",
6
  "0.2.0": "unify naming",
7
  "0.1.1": "add reference for LIDC dataset",
 
1
  {
2
  "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
3
+ "version": "0.4.0",
4
  "changelog": {
5
+ "0.4.0": "add support for raw images",
6
  "0.3.0": "update license files",
7
  "0.2.0": "unify naming",
8
  "0.1.1": "add reference for LIDC dataset",
configs/train.json CHANGED
@@ -6,7 +6,7 @@
6
  "bundle_root": "./",
7
  "ckpt_dir": "$@bundle_root + '/models'",
8
  "output_dir": "$@bundle_root + '/eval'",
9
- "data_list_file_path": "$@bundle_root + '/annotation/dataset_fold0.json'",
10
  "data_file_base_dir": "/home/canz/Projects/datasets/LUNA16/93176/Images_resample",
11
  "train_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, is_segmentation=True, data_list_key='training', base_dir=@data_file_base_dir)",
12
  "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
 
6
  "bundle_root": "./",
7
  "ckpt_dir": "$@bundle_root + '/models'",
8
  "output_dir": "$@bundle_root + '/eval'",
9
+ "data_list_file_path": "$@bundle_root + '/LUNA16_datasplit/dataset_fold0.json'",
10
  "data_file_base_dir": "/home/canz/Projects/datasets/LUNA16/93176/Images_resample",
11
  "train_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, is_segmentation=True, data_list_key='training', base_dir=@data_file_base_dir)",
12
  "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
docs/README.md CHANGED
@@ -8,32 +8,39 @@ LUNA16 is a public dataset of CT lung nodule detection. Using raw CT scans, the
8
 
9
  Disclaimer: We are not the host of the data. Please make sure to read the requirements and usage policies of the data and give credit to the authors of the dataset!
10
 
11
- ## Data
 
12
  The dataset we are experimenting in this example is LUNA16 (https://luna16.grand-challenge.org/Home/), which is based on [LIDC/IDRI database](https://wiki.cancerimagingarchive.net/display/Public/LIDC-IDRI) [3,4,5].
13
 
14
  LUNA16 is a public dataset of CT lung nodule detection. Using raw CT scans, the goal is to identify locations of possible nodules, and to assign a probability for being a nodule to each location.
15
 
16
  Disclaimer: We are not the host of the data. Please make sure to read the requirements and usage policies of the data and give credit to the authors of the dataset! We acknowledge the National Cancer Institute and the Foundation for the National Institutes of Health, and their critical role in the creation of the free publicly available LIDC/IDRI Database used in this study.
17
 
 
18
  We follow the official 10-fold data splitting from LUNA16 challenge and generate data split json files using the script from [nnDetection](https://github.com/MIC-DKFZ/nnDetection/blob/main/projects/Task016_Luna/scripts/prepare.py).
19
- The resulted json files can be downloaded from https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/LUNA16_datasplit-20220615T233840Z-001.zip.
 
 
20
  In these files, the values of "box" are the ground truth boxes in world coordinate.
21
 
 
22
  The raw CT images in LUNA16 have various of voxel sizes. The first step is to resample them to the same voxel size.
23
- In this model, we resampled them into 0.703125 x 0.703125 x 1.25 mm. The code of resampling can be found in Section 3.1 of https://github.com/Project-MONAI/tutorials/tree/main/detection
 
 
24
 
25
- ## Training configuration
26
  The training was performed with at least 12GB-memory GPUs.
27
 
28
  Actual Model Input: 192 x 192 x 80
29
 
30
- ## Input and output formats
31
  Input: list of 1 channel 3D CT patches
32
 
33
  Output: dictionary of classification and box regression loss in training mode;
34
  list of dictionary of predicted box, classification label, and classification score in evaluation mode.
35
 
36
- ## Scores
37
  The script to compute FROC sensitivity value on inference results can be found in https://github.com/Project-MONAI/tutorials/tree/main/detection
38
 
39
  This model achieves the following FROC sensitivity value on the validation data (our own split from the training dataset):
@@ -46,28 +53,26 @@ This model achieves the following FROC sensitivity value on the validation data
46
 
47
  **Table 1**. The FROC sensitivity values at the predefined false positive per scan thresholds of the LUNA16 challenge.
48
 
49
- ## commands example
50
  Execute training:
51
-
52
  ```
53
  python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf
54
  ```
55
 
56
  Override the `train` config to execute evaluation with the trained model:
57
-
58
  ```
59
  python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf
60
  ```
61
 
62
- Execute inference:
63
-
64
  ```
65
  python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf
66
  ```
 
67
 
68
- Note that in inference.json, the transform "AffineBoxToWorldCoordinated" in "postprocessing" has `"affine_lps_to_ras": true`.
69
- This depends on the input images. It is possible that your inference dataset should set "affine_lps_to_ras": false.
70
- Please set it as `true` only when the original images were read by itkreader with affine_lps_to_ras=True.
71
 
72
 
73
  # Disclaimer
 
8
 
9
  Disclaimer: We are not the host of the data. Please make sure to read the requirements and usage policies of the data and give credit to the authors of the dataset!
10
 
11
+ ## 1. Data
12
+ ### 1.1 Data description
13
  The dataset we are experimenting in this example is LUNA16 (https://luna16.grand-challenge.org/Home/), which is based on [LIDC/IDRI database](https://wiki.cancerimagingarchive.net/display/Public/LIDC-IDRI) [3,4,5].
14
 
15
  LUNA16 is a public dataset of CT lung nodule detection. Using raw CT scans, the goal is to identify locations of possible nodules, and to assign a probability for being a nodule to each location.
16
 
17
  Disclaimer: We are not the host of the data. Please make sure to read the requirements and usage policies of the data and give credit to the authors of the dataset! We acknowledge the National Cancer Institute and the Foundation for the National Institutes of Health, and their critical role in the creation of the free publicly available LIDC/IDRI Database used in this study.
18
 
19
+ ### 1.2 10-fold data splitting
20
  We follow the official 10-fold data splitting from LUNA16 challenge and generate data split json files using the script from [nnDetection](https://github.com/MIC-DKFZ/nnDetection/blob/main/projects/Task016_Luna/scripts/prepare.py).
21
+
22
+ Please download the resulted json files from https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/LUNA16_datasplit-20220615T233840Z-001.zip.
23
+
24
  In these files, the values of "box" are the ground truth boxes in world coordinate.
25
 
26
+ ### 1.3 Data resampling
27
  The raw CT images in LUNA16 have various of voxel sizes. The first step is to resample them to the same voxel size.
28
+ In this model, we resampled them into 0.703125 x 0.703125 x 1.25 mm.
29
+
30
+ Please following the instruction in Section 3.1 of https://github.com/Project-MONAI/tutorials/tree/main/detection to do the resampling.
31
 
32
+ ## 2. Training configuration
33
  The training was performed with at least 12GB-memory GPUs.
34
 
35
  Actual Model Input: 192 x 192 x 80
36
 
37
+ ## 3. Input and output formats
38
  Input: list of 1 channel 3D CT patches
39
 
40
  Output: dictionary of classification and box regression loss in training mode;
41
  list of dictionary of predicted box, classification label, and classification score in evaluation mode.
42
 
43
+ ## 4. Results and Scores
44
  The script to compute FROC sensitivity value on inference results can be found in https://github.com/Project-MONAI/tutorials/tree/main/detection
45
 
46
  This model achieves the following FROC sensitivity value on the validation data (our own split from the training dataset):
 
53
 
54
  **Table 1**. The FROC sensitivity values at the predefined false positive per scan thresholds of the LUNA16 challenge.
55
 
56
+ ## 5. Commands example
57
  Execute training:
 
58
  ```
59
  python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf
60
  ```
61
 
62
  Override the `train` config to execute evaluation with the trained model:
 
63
  ```
64
  python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf
65
  ```
66
 
67
+ Execute inference on resampled LUNA16 images (resampled following Section 3.1 of https://github.com/Project-MONAI/tutorials/tree/main/detection) by setting `"whether_raw_luna16": false` in `inference.json`:
 
68
  ```
69
  python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf
70
  ```
71
+ With the same command, we can execute inference on raw LUNA16 images by setting `"whether_raw_luna16": true` in `inference.json`. Remember to also set `"data_list_file_path": "$@bundle_root + '/LUNA16_datasplit/original/dataset_fold0.json'"` and change `"data_file_base_dir"`.
72
 
73
+ Note that in inference.json, the transform "LoadImaged" in "preprocessing" and "AffineBoxToWorldCoordinated" in "postprocessing" has `"affine_lps_to_ras": true`.
74
+ This depends on the input images. LUNA16 needs `"affine_lps_to_ras": true`.
75
+ It is possible that your inference dataset should set `"affine_lps_to_ras": false`.
76
 
77
 
78
  # Disclaimer