Upload prostate_mri_anatomy version 0.3.5
Browse files- .gitattributes +1 -0
- LICENSE +201 -0
- configs/inference.json +168 -0
- configs/logging.conf +21 -0
- configs/metadata.json +88 -0
- configs/train.json +376 -0
- docs/README.md +126 -0
- models/model.pt +3 -0
- models/model.ts +3 -0
- scripts/center_crop.py +83 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
models/model.ts filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
configs/inference.json
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
"bundle_root": ".",
|
| 7 |
+
"output_dir": "$@bundle_root + '/eval'",
|
| 8 |
+
"dataset_dir": "/workspace/data/prostate158/prostate158_test/",
|
| 9 |
+
"datalist": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'test.csv').t2)",
|
| 10 |
+
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
|
| 11 |
+
"network_def": {
|
| 12 |
+
"_target_": "UNet",
|
| 13 |
+
"spatial_dims": 3,
|
| 14 |
+
"in_channels": 1,
|
| 15 |
+
"out_channels": 3,
|
| 16 |
+
"channels": [
|
| 17 |
+
16,
|
| 18 |
+
32,
|
| 19 |
+
64,
|
| 20 |
+
128,
|
| 21 |
+
256,
|
| 22 |
+
512
|
| 23 |
+
],
|
| 24 |
+
"strides": [
|
| 25 |
+
2,
|
| 26 |
+
2,
|
| 27 |
+
2,
|
| 28 |
+
2,
|
| 29 |
+
2
|
| 30 |
+
],
|
| 31 |
+
"num_res_units": 4,
|
| 32 |
+
"norm": "batch",
|
| 33 |
+
"act": "prelu",
|
| 34 |
+
"dropout": 0.15
|
| 35 |
+
},
|
| 36 |
+
"network": "$@network_def.to(@device)",
|
| 37 |
+
"preprocessing": {
|
| 38 |
+
"_target_": "Compose",
|
| 39 |
+
"transforms": [
|
| 40 |
+
{
|
| 41 |
+
"_target_": "LoadImaged",
|
| 42 |
+
"keys": "image"
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"_target_": "EnsureChannelFirstd",
|
| 46 |
+
"keys": "image"
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"_target_": "Orientationd",
|
| 50 |
+
"keys": "image",
|
| 51 |
+
"axcodes": "RAS"
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"_target_": "Spacingd",
|
| 55 |
+
"keys": "image",
|
| 56 |
+
"pixdim": [
|
| 57 |
+
0.5,
|
| 58 |
+
0.5,
|
| 59 |
+
0.5
|
| 60 |
+
],
|
| 61 |
+
"mode": "bilinear"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"_target_": "ScaleIntensityd",
|
| 65 |
+
"keys": "image",
|
| 66 |
+
"minv": 0,
|
| 67 |
+
"maxv": 1
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"_target_": "NormalizeIntensityd",
|
| 71 |
+
"keys": "image"
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"_target_": "EnsureTyped",
|
| 75 |
+
"keys": "image"
|
| 76 |
+
}
|
| 77 |
+
]
|
| 78 |
+
},
|
| 79 |
+
"dataset": {
|
| 80 |
+
"_target_": "Dataset",
|
| 81 |
+
"data": "$[{'image': i} for i in @datalist]",
|
| 82 |
+
"transform": "@preprocessing"
|
| 83 |
+
},
|
| 84 |
+
"dataloader": {
|
| 85 |
+
"_target_": "DataLoader",
|
| 86 |
+
"dataset": "@dataset",
|
| 87 |
+
"batch_size": 1,
|
| 88 |
+
"shuffle": false,
|
| 89 |
+
"num_workers": 4
|
| 90 |
+
},
|
| 91 |
+
"inferer": {
|
| 92 |
+
"_target_": "SlidingWindowInferer",
|
| 93 |
+
"roi_size": [
|
| 94 |
+
96,
|
| 95 |
+
96,
|
| 96 |
+
96
|
| 97 |
+
],
|
| 98 |
+
"sw_batch_size": 4,
|
| 99 |
+
"overlap": 0.5
|
| 100 |
+
},
|
| 101 |
+
"postprocessing": {
|
| 102 |
+
"_target_": "Compose",
|
| 103 |
+
"transforms": [
|
| 104 |
+
{
|
| 105 |
+
"_target_": "AsDiscreted",
|
| 106 |
+
"keys": "pred",
|
| 107 |
+
"argmax": true
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"_target_": "KeepLargestConnectedComponentd",
|
| 111 |
+
"keys": "pred",
|
| 112 |
+
"applied_labels": [
|
| 113 |
+
1,
|
| 114 |
+
2
|
| 115 |
+
]
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"_target_": "Invertd",
|
| 119 |
+
"keys": "pred",
|
| 120 |
+
"transform": "@preprocessing",
|
| 121 |
+
"orig_keys": "image",
|
| 122 |
+
"meta_key_postfix": "meta_dict",
|
| 123 |
+
"nearest_interp": false,
|
| 124 |
+
"to_tensor": true
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"_target_": "SaveImaged",
|
| 128 |
+
"keys": "pred",
|
| 129 |
+
"resample": false,
|
| 130 |
+
"meta_keys": "pred_meta_dict",
|
| 131 |
+
"output_dir": "@output_dir"
|
| 132 |
+
}
|
| 133 |
+
]
|
| 134 |
+
},
|
| 135 |
+
"handlers": [
|
| 136 |
+
{
|
| 137 |
+
"_target_": "CheckpointLoader",
|
| 138 |
+
"load_path": "$@bundle_root + '/models/model.pt'",
|
| 139 |
+
"map_location": {
|
| 140 |
+
"_target_": "torch.device",
|
| 141 |
+
"device": "@device"
|
| 142 |
+
},
|
| 143 |
+
"load_dict": {
|
| 144 |
+
"model": "@network"
|
| 145 |
+
}
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"_target_": "StatsHandler",
|
| 149 |
+
"iteration_log": false
|
| 150 |
+
}
|
| 151 |
+
],
|
| 152 |
+
"evaluator": {
|
| 153 |
+
"_target_": "SupervisedEvaluator",
|
| 154 |
+
"device": "@device",
|
| 155 |
+
"val_data_loader": "@dataloader",
|
| 156 |
+
"network": "@network",
|
| 157 |
+
"inferer": "@inferer",
|
| 158 |
+
"postprocessing": "@postprocessing",
|
| 159 |
+
"val_handlers": "@handlers",
|
| 160 |
+
"amp": true
|
| 161 |
+
},
|
| 162 |
+
"initialize": [
|
| 163 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 164 |
+
],
|
| 165 |
+
"run": [
|
| 166 |
+
"$@evaluator.run()"
|
| 167 |
+
]
|
| 168 |
+
}
|
configs/logging.conf
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[loggers]
|
| 2 |
+
keys=root
|
| 3 |
+
|
| 4 |
+
[handlers]
|
| 5 |
+
keys=consoleHandler
|
| 6 |
+
|
| 7 |
+
[formatters]
|
| 8 |
+
keys=fullFormatter
|
| 9 |
+
|
| 10 |
+
[logger_root]
|
| 11 |
+
level=INFO
|
| 12 |
+
handlers=consoleHandler
|
| 13 |
+
|
| 14 |
+
[handler_consoleHandler]
|
| 15 |
+
class=StreamHandler
|
| 16 |
+
level=INFO
|
| 17 |
+
formatter=fullFormatter
|
| 18 |
+
args=(sys.stdout,)
|
| 19 |
+
|
| 20 |
+
[formatter_fullFormatter]
|
| 21 |
+
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
configs/metadata.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.5",
|
| 4 |
+
"changelog": {
|
| 5 |
+
"0.3.5": "update to huggingface hosting",
|
| 6 |
+
"0.3.4": "support monai 1.4",
|
| 7 |
+
"0.3.3": "add invertd transformation",
|
| 8 |
+
"0.3.2": "add name tag",
|
| 9 |
+
"0.3.1": "fix license Copyright error",
|
| 10 |
+
"0.3.0": "update license files",
|
| 11 |
+
"0.2.0": "unify naming",
|
| 12 |
+
"0.1.1": "add torchscript model",
|
| 13 |
+
"0.1.0": "complete the model package"
|
| 14 |
+
},
|
| 15 |
+
"monai_version": "1.4.0",
|
| 16 |
+
"pytorch_version": "2.4.0",
|
| 17 |
+
"numpy_version": "1.24.4",
|
| 18 |
+
"optional_packages_version": {
|
| 19 |
+
"nibabel": "5.2.1",
|
| 20 |
+
"itk": "5.4.0",
|
| 21 |
+
"pytorch-ignite": "0.4.11",
|
| 22 |
+
"pandas": "2.2.1"
|
| 23 |
+
},
|
| 24 |
+
"name": "Prostate MRI anatomy",
|
| 25 |
+
"task": "Segmentation of peripheral zone and central gland in prostate MRI",
|
| 26 |
+
"description": "A pre-trained model for volumetric (3D) segmentation of the prostate from MRI images",
|
| 27 |
+
"authors": "Keno Bressem",
|
| 28 |
+
"copyright": "Copyright (c) Keno Bressem",
|
| 29 |
+
"data_source": "Prostate158 from 10.5281/zenodo.6481141",
|
| 30 |
+
"data_type": "nifti",
|
| 31 |
+
"image_classes": "single channel data, intensity scaled to [0, 1]",
|
| 32 |
+
"label_classes": "singe channel data, 1 central gland, 2 periheral zone, 0 is everything else",
|
| 33 |
+
"pred_classes": "3 channels OneHot data, channel 1 central gland, channel 2 is peripheral zone, channel 0 is background",
|
| 34 |
+
"eval_metrics": {
|
| 35 |
+
"mean_dice": {
|
| 36 |
+
"central gland": 0.88,
|
| 37 |
+
"peripheral zone": 0.75
|
| 38 |
+
}
|
| 39 |
+
},
|
| 40 |
+
"intended_use": "This is an example, not to be used for diagnostic purposes",
|
| 41 |
+
"references": [
|
| 42 |
+
"Adams, L. C., Makowski, M. R., Engel, G., Rattunde, M., Busch, F., Asbach, P., ... & Bressem, K. K. (2022). Prostate158-An expert-annotated 3T MRI dataset and algorithm for prostate cancer detection. Computers in Biology and Medicine, 148, 105817."
|
| 43 |
+
],
|
| 44 |
+
"network_data_format": {
|
| 45 |
+
"inputs": {
|
| 46 |
+
"image": {
|
| 47 |
+
"type": "image",
|
| 48 |
+
"format": "magnitude",
|
| 49 |
+
"modality": "MR",
|
| 50 |
+
"num_channels": 1,
|
| 51 |
+
"spatial_shape": [
|
| 52 |
+
96,
|
| 53 |
+
96,
|
| 54 |
+
96
|
| 55 |
+
],
|
| 56 |
+
"dtype": "float32",
|
| 57 |
+
"value_range": [
|
| 58 |
+
0,
|
| 59 |
+
1
|
| 60 |
+
],
|
| 61 |
+
"is_patch_data": true,
|
| 62 |
+
"channel_def": {
|
| 63 |
+
"0": "image"
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
},
|
| 67 |
+
"outputs": {
|
| 68 |
+
"pred": {
|
| 69 |
+
"type": "image",
|
| 70 |
+
"format": "labels",
|
| 71 |
+
"num_channels": 3,
|
| 72 |
+
"spatial_shape": [
|
| 73 |
+
96,
|
| 74 |
+
96,
|
| 75 |
+
96
|
| 76 |
+
],
|
| 77 |
+
"dtype": "float32",
|
| 78 |
+
"value_range": [],
|
| 79 |
+
"is_patch_data": true,
|
| 80 |
+
"channel_def": {
|
| 81 |
+
"0": "background",
|
| 82 |
+
"1": "central gland",
|
| 83 |
+
"2": "peripheral zone"
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
}
|
configs/train.json
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"imports": [
|
| 3 |
+
"$import pandas as pd",
|
| 4 |
+
"$import os",
|
| 5 |
+
"$import ignite"
|
| 6 |
+
],
|
| 7 |
+
"bundle_root": ".",
|
| 8 |
+
"ckpt_dir": "$@bundle_root + '/models'",
|
| 9 |
+
"output_dir": "$@bundle_root + '/eval'",
|
| 10 |
+
"dataset_dir": "/workspace/data/prostate158/prostate158_train/",
|
| 11 |
+
"images": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'train.csv').t2)",
|
| 12 |
+
"labels": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'train.csv').t2_anatomy_reader1)",
|
| 13 |
+
"val_images": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'valid.csv').t2)",
|
| 14 |
+
"val_labels": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'valid.csv').t2_anatomy_reader1)",
|
| 15 |
+
"val_interval": 5,
|
| 16 |
+
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
|
| 17 |
+
"network_def": {
|
| 18 |
+
"_target_": "UNet",
|
| 19 |
+
"spatial_dims": 3,
|
| 20 |
+
"in_channels": 1,
|
| 21 |
+
"out_channels": 3,
|
| 22 |
+
"channels": [
|
| 23 |
+
16,
|
| 24 |
+
32,
|
| 25 |
+
64,
|
| 26 |
+
128,
|
| 27 |
+
256,
|
| 28 |
+
512
|
| 29 |
+
],
|
| 30 |
+
"strides": [
|
| 31 |
+
2,
|
| 32 |
+
2,
|
| 33 |
+
2,
|
| 34 |
+
2,
|
| 35 |
+
2
|
| 36 |
+
],
|
| 37 |
+
"num_res_units": 4,
|
| 38 |
+
"norm": "batch",
|
| 39 |
+
"act": "prelu",
|
| 40 |
+
"dropout": 0.15
|
| 41 |
+
},
|
| 42 |
+
"network": "$@network_def.to(@device)",
|
| 43 |
+
"loss": {
|
| 44 |
+
"_target_": "DiceFocalLoss",
|
| 45 |
+
"to_onehot_y": true,
|
| 46 |
+
"softmax": true,
|
| 47 |
+
"include_background": false
|
| 48 |
+
},
|
| 49 |
+
"optimizer": {
|
| 50 |
+
"_target_": "Novograd",
|
| 51 |
+
"params": "$@network.parameters()",
|
| 52 |
+
"lr": 0.001,
|
| 53 |
+
"amsgrad": true,
|
| 54 |
+
"weight_decay": 0.01
|
| 55 |
+
},
|
| 56 |
+
"train": {
|
| 57 |
+
"deterministic_transforms": [
|
| 58 |
+
{
|
| 59 |
+
"_target_": "LoadImaged",
|
| 60 |
+
"keys": [
|
| 61 |
+
"image",
|
| 62 |
+
"label"
|
| 63 |
+
]
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"_target_": "EnsureChannelFirstd",
|
| 67 |
+
"keys": [
|
| 68 |
+
"image",
|
| 69 |
+
"label"
|
| 70 |
+
]
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"_target_": "Orientationd",
|
| 74 |
+
"keys": [
|
| 75 |
+
"image",
|
| 76 |
+
"label"
|
| 77 |
+
],
|
| 78 |
+
"axcodes": "RAS"
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"_target_": "Spacingd",
|
| 82 |
+
"keys": [
|
| 83 |
+
"image",
|
| 84 |
+
"label"
|
| 85 |
+
],
|
| 86 |
+
"pixdim": [
|
| 87 |
+
0.5,
|
| 88 |
+
0.5,
|
| 89 |
+
0.5
|
| 90 |
+
],
|
| 91 |
+
"mode": [
|
| 92 |
+
"bilinear",
|
| 93 |
+
"nearest"
|
| 94 |
+
]
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"_target_": "ScaleIntensityd",
|
| 98 |
+
"keys": "image",
|
| 99 |
+
"minv": 0,
|
| 100 |
+
"maxv": 1
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"_target_": "NormalizeIntensityd",
|
| 104 |
+
"keys": "image"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"_target_": "EnsureTyped",
|
| 108 |
+
"keys": [
|
| 109 |
+
"image",
|
| 110 |
+
"label"
|
| 111 |
+
]
|
| 112 |
+
}
|
| 113 |
+
],
|
| 114 |
+
"random_transforms": [
|
| 115 |
+
{
|
| 116 |
+
"_target_": "RandAdjustContrastd",
|
| 117 |
+
"keys": "image",
|
| 118 |
+
"prob": 0.15,
|
| 119 |
+
"gamma": 2.0
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"_target_": "RandGaussianNoised",
|
| 123 |
+
"keys": "image",
|
| 124 |
+
"prob": 0.15,
|
| 125 |
+
"mean": 0.1,
|
| 126 |
+
"std": 0.25
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"_target_": "RandAffined",
|
| 130 |
+
"keys": [
|
| 131 |
+
"image",
|
| 132 |
+
"label"
|
| 133 |
+
],
|
| 134 |
+
"prob": 0.15,
|
| 135 |
+
"rotate_range": 5,
|
| 136 |
+
"shear_range": 0.5,
|
| 137 |
+
"translate_range": 25
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"_target_": "RandBiasFieldd",
|
| 141 |
+
"keys": "image",
|
| 142 |
+
"prob": 0.15,
|
| 143 |
+
"coeff_range": [
|
| 144 |
+
0.0,
|
| 145 |
+
0.01
|
| 146 |
+
],
|
| 147 |
+
"degree": 10
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
"_target_": "Rand3DElasticd",
|
| 151 |
+
"keys": [
|
| 152 |
+
"image",
|
| 153 |
+
"label"
|
| 154 |
+
],
|
| 155 |
+
"prob": 0.15,
|
| 156 |
+
"magnitude_range": [
|
| 157 |
+
0.5,
|
| 158 |
+
1.5
|
| 159 |
+
],
|
| 160 |
+
"rotate_range": 5,
|
| 161 |
+
"shear_range": 0.5,
|
| 162 |
+
"sigma_range": [
|
| 163 |
+
0.5,
|
| 164 |
+
1.5
|
| 165 |
+
],
|
| 166 |
+
"translate_range": 25
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"_target_": "RandZoomd",
|
| 170 |
+
"keys": [
|
| 171 |
+
"image",
|
| 172 |
+
"label"
|
| 173 |
+
],
|
| 174 |
+
"prob": 0.15,
|
| 175 |
+
"max": 1.1,
|
| 176 |
+
"min": 0.9
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"_target_": "RandCropByPosNegLabeld",
|
| 180 |
+
"keys": [
|
| 181 |
+
"image",
|
| 182 |
+
"label"
|
| 183 |
+
],
|
| 184 |
+
"label_key": "label",
|
| 185 |
+
"spatial_size": [
|
| 186 |
+
96,
|
| 187 |
+
96,
|
| 188 |
+
96
|
| 189 |
+
],
|
| 190 |
+
"pos": 1,
|
| 191 |
+
"neg": 1,
|
| 192 |
+
"num_samples": 4,
|
| 193 |
+
"image_key": "image",
|
| 194 |
+
"image_threshold": 0
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"_target_": "RandShiftIntensityd",
|
| 198 |
+
"keys": "image",
|
| 199 |
+
"prob": 0.15,
|
| 200 |
+
"offsets": 0.2
|
| 201 |
+
}
|
| 202 |
+
],
|
| 203 |
+
"preprocessing": {
|
| 204 |
+
"_target_": "Compose",
|
| 205 |
+
"transforms": "$@train#deterministic_transforms + @train#random_transforms"
|
| 206 |
+
},
|
| 207 |
+
"dataset": {
|
| 208 |
+
"_target_": "PersistentDataset",
|
| 209 |
+
"data": "$[{'image': i, 'label': l} for i, l in zip(@images, @labels)]",
|
| 210 |
+
"transform": "@train#preprocessing",
|
| 211 |
+
"cache_dir": "$@bundle_root + '/cache'"
|
| 212 |
+
},
|
| 213 |
+
"dataloader": {
|
| 214 |
+
"_target_": "DataLoader",
|
| 215 |
+
"dataset": "@train#dataset",
|
| 216 |
+
"batch_size": 2,
|
| 217 |
+
"shuffle": true,
|
| 218 |
+
"num_workers": 4
|
| 219 |
+
},
|
| 220 |
+
"inferer": {
|
| 221 |
+
"_target_": "SimpleInferer"
|
| 222 |
+
},
|
| 223 |
+
"postprocessing": {
|
| 224 |
+
"_target_": "Compose",
|
| 225 |
+
"transforms": [
|
| 226 |
+
{
|
| 227 |
+
"_target_": "Activationsd",
|
| 228 |
+
"keys": "pred",
|
| 229 |
+
"softmax": true
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"_target_": "AsDiscreted",
|
| 233 |
+
"keys": [
|
| 234 |
+
"pred",
|
| 235 |
+
"label"
|
| 236 |
+
],
|
| 237 |
+
"argmax": [
|
| 238 |
+
true,
|
| 239 |
+
false
|
| 240 |
+
],
|
| 241 |
+
"to_onehot": 3
|
| 242 |
+
}
|
| 243 |
+
]
|
| 244 |
+
},
|
| 245 |
+
"handlers": [
|
| 246 |
+
{
|
| 247 |
+
"_target_": "ValidationHandler",
|
| 248 |
+
"validator": "@validate#evaluator",
|
| 249 |
+
"epoch_level": true,
|
| 250 |
+
"interval": "@val_interval"
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"_target_": "StatsHandler",
|
| 254 |
+
"tag_name": "train_loss",
|
| 255 |
+
"output_transform": "$monai.handlers.from_engine(['loss'], first=True)"
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"_target_": "TensorBoardStatsHandler",
|
| 259 |
+
"log_dir": "@output_dir",
|
| 260 |
+
"tag_name": "train_loss",
|
| 261 |
+
"output_transform": "$monai.handlers.from_engine(['loss'], first=True)"
|
| 262 |
+
}
|
| 263 |
+
],
|
| 264 |
+
"key_metric": {
|
| 265 |
+
"train_dice": {
|
| 266 |
+
"_target_": "MeanDice",
|
| 267 |
+
"include_background": false,
|
| 268 |
+
"output_transform": "$monai.handlers.from_engine(['pred', 'label'])"
|
| 269 |
+
}
|
| 270 |
+
},
|
| 271 |
+
"trainer": {
|
| 272 |
+
"_target_": "SupervisedTrainer",
|
| 273 |
+
"max_epochs": 100,
|
| 274 |
+
"device": "@device",
|
| 275 |
+
"train_data_loader": "@train#dataloader",
|
| 276 |
+
"network": "@network",
|
| 277 |
+
"loss_function": "@loss",
|
| 278 |
+
"optimizer": "@optimizer",
|
| 279 |
+
"inferer": "@train#inferer",
|
| 280 |
+
"postprocessing": "@train#postprocessing",
|
| 281 |
+
"key_train_metric": "@train#key_metric",
|
| 282 |
+
"train_handlers": "@train#handlers",
|
| 283 |
+
"amp": true
|
| 284 |
+
}
|
| 285 |
+
},
|
| 286 |
+
"validate": {
|
| 287 |
+
"preprocessing": {
|
| 288 |
+
"_target_": "Compose",
|
| 289 |
+
"transforms": "%train#deterministic_transforms"
|
| 290 |
+
},
|
| 291 |
+
"dataset": {
|
| 292 |
+
"_target_": "PersistentDataset",
|
| 293 |
+
"data": "$[{'image': i, 'label': l} for i, l in zip(@val_images, @val_labels)]",
|
| 294 |
+
"transform": "@validate#preprocessing",
|
| 295 |
+
"cache_dir": "$@bundle_root + '/cache'"
|
| 296 |
+
},
|
| 297 |
+
"dataloader": {
|
| 298 |
+
"_target_": "DataLoader",
|
| 299 |
+
"dataset": "@validate#dataset",
|
| 300 |
+
"batch_size": 1,
|
| 301 |
+
"shuffle": false,
|
| 302 |
+
"num_workers": 4
|
| 303 |
+
},
|
| 304 |
+
"inferer": {
|
| 305 |
+
"_target_": "SlidingWindowInferer",
|
| 306 |
+
"roi_size": [
|
| 307 |
+
96,
|
| 308 |
+
96,
|
| 309 |
+
96
|
| 310 |
+
],
|
| 311 |
+
"sw_batch_size": 16,
|
| 312 |
+
"overlap": 0.5
|
| 313 |
+
},
|
| 314 |
+
"postprocessing": "%train#postprocessing",
|
| 315 |
+
"handlers": [
|
| 316 |
+
{
|
| 317 |
+
"_target_": "StatsHandler",
|
| 318 |
+
"iteration_log": false
|
| 319 |
+
},
|
| 320 |
+
{
|
| 321 |
+
"_target_": "TensorBoardStatsHandler",
|
| 322 |
+
"log_dir": "@output_dir",
|
| 323 |
+
"iteration_log": false
|
| 324 |
+
},
|
| 325 |
+
{
|
| 326 |
+
"_target_": "CheckpointSaver",
|
| 327 |
+
"save_dir": "@ckpt_dir",
|
| 328 |
+
"save_dict": {
|
| 329 |
+
"model": "@network"
|
| 330 |
+
},
|
| 331 |
+
"save_key_metric": true,
|
| 332 |
+
"key_metric_filename": "model.pt"
|
| 333 |
+
}
|
| 334 |
+
],
|
| 335 |
+
"key_metric": {
|
| 336 |
+
"val_mean_dice": {
|
| 337 |
+
"_target_": "MeanDice",
|
| 338 |
+
"include_background": false,
|
| 339 |
+
"output_transform": "$monai.handlers.from_engine(['pred', 'label'])"
|
| 340 |
+
}
|
| 341 |
+
},
|
| 342 |
+
"additional_metrics": {
|
| 343 |
+
"val_hausdorff_distance": {
|
| 344 |
+
"_target_": "HausdorffDistance",
|
| 345 |
+
"include_background": false,
|
| 346 |
+
"reduction": "mean",
|
| 347 |
+
"output_transform": "$monai.handlers.from_engine(['pred', 'label'])"
|
| 348 |
+
},
|
| 349 |
+
"val_surface_distance": {
|
| 350 |
+
"_target_": "SurfaceDistance",
|
| 351 |
+
"include_background": false,
|
| 352 |
+
"reduction": "mean",
|
| 353 |
+
"output_transform": "$monai.handlers.from_engine(['pred', 'label'])"
|
| 354 |
+
}
|
| 355 |
+
},
|
| 356 |
+
"evaluator": {
|
| 357 |
+
"_target_": "SupervisedEvaluator",
|
| 358 |
+
"device": "@device",
|
| 359 |
+
"val_data_loader": "@validate#dataloader",
|
| 360 |
+
"network": "@network",
|
| 361 |
+
"inferer": "@validate#inferer",
|
| 362 |
+
"postprocessing": "@validate#postprocessing",
|
| 363 |
+
"key_val_metric": "@validate#key_metric",
|
| 364 |
+
"additional_metrics": "@validate#additional_metrics",
|
| 365 |
+
"val_handlers": "@validate#handlers",
|
| 366 |
+
"amp": true
|
| 367 |
+
}
|
| 368 |
+
},
|
| 369 |
+
"initialize": [
|
| 370 |
+
"$monai.utils.set_determinism(seed=321)",
|
| 371 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 372 |
+
],
|
| 373 |
+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model Description**
|
| 12 |
+
This model was trained with the UNet architecture [1] and is used for 3D volumetric segmentation of the anatomical prostate zones on T2w MRI images. The segmentation of the anatomical regions is formulated as a voxel-wise classification. Each voxel is classified as either central gland (1), peripheral zone (2), or background (0). The model is optimized using a gradient descent method that minimizes the focal soft-dice loss between the predicted mask and the actual segmentation.
|
| 13 |
+
|
| 14 |
+
## **Data**
|
| 15 |
+
The model was trained in the prostate158 training data, which is available at https://doi.org/10.5281/zenodo.6481141. Only T2w images were used for this task.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
### **Preprocessing**
|
| 19 |
+
MRI images in the prostate158 dataset were preprocessed, including center cropping and resampling. When applying the model to new data, this preprocessing should be repeated.
|
| 20 |
+
|
| 21 |
+
#### **Center cropping**
|
| 22 |
+
T2w images were acquired with a voxel spacing of 0.47 x 0.47 x 3 mm and an axial FOV size of 180 x 180 mm. However, the prostate rarely exceeds an axial diameter of 100 mm, and for zonal segmentation, the tissue surrounding the prostate is not of interest and only increases the image size and thus the computational cost. Center-cropping can reduce the image size without sacrificing information.
|
| 23 |
+
|
| 24 |
+
The script `center_crop.py` allows to reproduce center-cropping as performed in the prostate158 paper.
|
| 25 |
+
|
| 26 |
+
```bash
|
| 27 |
+
python scripts/center_crop.py --file_name path/to/t2_image --out_name cropped_t2
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
#### **Resampling**
|
| 31 |
+
DWI and ADC sequences in prostate158 were resampled to the orientation and voxel spacing of the T2w sequence. As the zonal segmentation uses T2w images, no additional resampling is nessecary. However, the training script will perform additonal resampling automatically.
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
## **Performance**
|
| 35 |
+
The model achives the following performance on the prostate158 test dataset:
|
| 36 |
+
|
| 37 |
+
<table border=1 frame=void rules=rows>
|
| 38 |
+
<thead>
|
| 39 |
+
<tr>
|
| 40 |
+
<td></td>
|
| 41 |
+
<td colspan = 3><b><center>Rater 1</center></b></td>
|
| 42 |
+
<td> </td>
|
| 43 |
+
<td colspan = 3><b><center>Rater 2</center></b></td>
|
| 44 |
+
</tr>
|
| 45 |
+
<tr>
|
| 46 |
+
<th>Metric</th>
|
| 47 |
+
<th>Transitional Zone</th>
|
| 48 |
+
<th>Peripheral Zone</th>
|
| 49 |
+
<th> </th>
|
| 50 |
+
<th>Transitional Zone</th>
|
| 51 |
+
<th>Peripheral Zone</th>
|
| 52 |
+
</tr>
|
| 53 |
+
</thead>
|
| 54 |
+
<tbody>
|
| 55 |
+
<tr>
|
| 56 |
+
<td><a href='https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient'>Dice Coefficient </a></td>
|
| 57 |
+
<td> 0.877</td>
|
| 58 |
+
<td> 0.754</td>
|
| 59 |
+
<td> </td>
|
| 60 |
+
<td> 0.875</td>
|
| 61 |
+
<td> 0.730</td>
|
| 62 |
+
</tr>
|
| 63 |
+
<tr>
|
| 64 |
+
<td><a href='https://en.wikipedia.org/wiki/Hausdorff_distance'>Hausdorff Distance </a></td>
|
| 65 |
+
<td> 18.3</td>
|
| 66 |
+
<td> 22.8</td>
|
| 67 |
+
<td> </td>
|
| 68 |
+
<td> 17.5</td>
|
| 69 |
+
<td> 33.2</td>
|
| 70 |
+
</tr>
|
| 71 |
+
<tr>
|
| 72 |
+
<td><a href='https://github.com/deepmind/surface-distance'>Surface Distance </a></td>
|
| 73 |
+
<td> 2.19</td>
|
| 74 |
+
<td> 1.95</td>
|
| 75 |
+
<td> </td>
|
| 76 |
+
<td> 2.59</td>
|
| 77 |
+
<td> 1.88</td>
|
| 78 |
+
</tr>
|
| 79 |
+
</tbody>
|
| 80 |
+
</table>
|
| 81 |
+
|
| 82 |
+
For more details, please see the original [publication](https://doi.org/10.1016/j.compbiomed.2022.105817) or official [GitHub repository](https://github.com/kbressem/prostate158)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
## **System Configuration**
|
| 86 |
+
The model was trained for 100 epochs on a workstaion with a single Nvidia RTX 3080 GPU. This takes approximatly 8 hours.
|
| 87 |
+
|
| 88 |
+
## **Limitations** (Optional)
|
| 89 |
+
|
| 90 |
+
This training and inference pipeline was developed for research purposes only. This research use only software that has not been cleared or approved by FDA or any regulatory agency. The model is for research/developmental purposes only and cannot be used directly for clinical procedures.
|
| 91 |
+
|
| 92 |
+
## **Citation Info** (Optional)
|
| 93 |
+
|
| 94 |
+
```
|
| 95 |
+
@article{ADAMS2022105817,
|
| 96 |
+
title = {Prostate158 - An expert-annotated 3T MRI dataset and algorithm for prostate cancer detection},
|
| 97 |
+
journal = {Computers in Biology and Medicine},
|
| 98 |
+
volume = {148},
|
| 99 |
+
pages = {105817},
|
| 100 |
+
year = {2022},
|
| 101 |
+
issn = {0010-4825},
|
| 102 |
+
doi = {https://doi.org/10.1016/j.compbiomed.2022.105817},
|
| 103 |
+
url = {https://www.sciencedirect.com/science/article/pii/S0010482522005789},
|
| 104 |
+
author = {Lisa C. Adams and Marcus R. Makowski and Günther Engel and Maximilian Rattunde and Felix Busch and Patrick Asbach and Stefan M. Niehues and Shankeeth Vinayahalingam and Bram {van Ginneken} and Geert Litjens and Keno K. Bressem},
|
| 105 |
+
keywords = {Prostate cancer, Deep learning, Machine learning, Artificial intelligence, Magnetic resonance imaging, Biparametric prostate MRI}
|
| 106 |
+
}
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
## **References**
|
| 110 |
+
|
| 111 |
+
[1] Sakinis, Tomas, et al. "Interactive segmentation of medical images through fully convolutional neural networks." arXiv preprint arXiv:1903.08205 (2019).
|
| 112 |
+
|
| 113 |
+
# License
|
| 114 |
+
Copyright (c) MONAI Consortium
|
| 115 |
+
|
| 116 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 117 |
+
you may not use this file except in compliance with the License.
|
| 118 |
+
You may obtain a copy of the License at
|
| 119 |
+
|
| 120 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 121 |
+
|
| 122 |
+
Unless required by applicable law or agreed to in writing, software
|
| 123 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 124 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 125 |
+
See the License for the specific language governing permissions and
|
| 126 |
+
limitations under the License.
|
models/model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3c18e4c658bb088f551b1d63219ef8340fe6256d016c75fc140d3da49dda696d
|
| 3 |
+
size 152810901
|
models/model.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0e94ea2e06465470827bd8167234feedccb0d4eb716e2bb423e5223e774c1d96
|
| 3 |
+
size 152903191
|
scripts/center_crop.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 - 2022 MONAI Consortium
|
| 2 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 3 |
+
# you may not use this file except in compliance with the License.
|
| 4 |
+
# You may obtain a copy of the License at
|
| 5 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 6 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 7 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 8 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 9 |
+
# See the License for the specific language governing permissions and
|
| 10 |
+
# limitations under the License.
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
import argparse
|
| 14 |
+
from typing import Union
|
| 15 |
+
|
| 16 |
+
import SimpleITK as sitk # noqa N813
|
| 17 |
+
|
| 18 |
+
parser = argparse.ArgumentParser(description="Center crop a 3d volume")
|
| 19 |
+
parser.add_argument("--file_name", type=str, required=True, help="Path to the input file to center crop.")
|
| 20 |
+
parser.add_argument(
|
| 21 |
+
"--margin",
|
| 22 |
+
type=Union[int, float],
|
| 23 |
+
required=False,
|
| 24 |
+
default=0.2,
|
| 25 |
+
help="Crop margins applied to EACH side in the axial plane. "
|
| 26 |
+
"If given a float value, will perform percentage crop. "
|
| 27 |
+
"If given an int value, will perform absolute crop.",
|
| 28 |
+
)
|
| 29 |
+
parser.add_argument("--out_name", type=str, required=True, help="Path and filename for the cropped volume")
|
| 30 |
+
|
| 31 |
+
args = parser.parse_args()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def _flatten(t):
|
| 35 |
+
return [item for sublist in t for item in sublist]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def crop(image: sitk.Image, margin: Union[int, float], interpolator=sitk.sitkLinear):
|
| 39 |
+
"""
|
| 40 |
+
Crops a sitk.Image while retaining correct spacing. Negative margins will lead to zero padding
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
image: a sitk.Image
|
| 44 |
+
margin: margins to crop. Single integer or float (percentage crop),
|
| 45 |
+
lists of int/float or nestes lists are supported.
|
| 46 |
+
"""
|
| 47 |
+
if isinstance(margin, (list, tuple)):
|
| 48 |
+
assert len(margin) == 3, "expected margin to be of length 3"
|
| 49 |
+
else:
|
| 50 |
+
assert isinstance(margin, (int, float)), "expected margin to be a float value"
|
| 51 |
+
margin = [margin, margin, margin]
|
| 52 |
+
|
| 53 |
+
margin = [m if isinstance(m, (tuple, list)) else [m, m] for m in margin]
|
| 54 |
+
old_size = image.GetSize()
|
| 55 |
+
|
| 56 |
+
# calculate new origin and new image size
|
| 57 |
+
if all([isinstance(m, float) for m in _flatten(margin)]):
|
| 58 |
+
assert all([m >= 0 and m < 0.5 for m in _flatten(margin)]), "margins must be between 0 and 0.5"
|
| 59 |
+
to_crop = [[int(sz * _m) for _m in m] for sz, m in zip(old_size, margin)]
|
| 60 |
+
elif all([isinstance(m, int) for m in _flatten(margin)]):
|
| 61 |
+
to_crop = margin
|
| 62 |
+
else:
|
| 63 |
+
raise ValueError("Wrong format of margins.")
|
| 64 |
+
|
| 65 |
+
new_size = [sz - sum(c) for sz, c in zip(old_size, to_crop)]
|
| 66 |
+
|
| 67 |
+
# origin has Index (0,0,0)
|
| 68 |
+
# new origin has Index (to_crop[0][0], to_crop[2][0], to_crop[2][0])
|
| 69 |
+
new_origin = image.TransformIndexToPhysicalPoint([c[0] for c in to_crop])
|
| 70 |
+
|
| 71 |
+
# create reference plane to resample image
|
| 72 |
+
ref_image = sitk.Image(new_size, image.GetPixelIDValue())
|
| 73 |
+
ref_image.SetSpacing(image.GetSpacing())
|
| 74 |
+
ref_image.SetOrigin(new_origin)
|
| 75 |
+
ref_image.SetDirection(image.GetDirection())
|
| 76 |
+
|
| 77 |
+
return sitk.Resample(image, ref_image, interpolator=interpolator)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
if __name__ == "__main__":
|
| 81 |
+
image = sitk.ReadImage(args.file_name)
|
| 82 |
+
cropped = crop(image, [args.margin, args.margin, 0.0])
|
| 83 |
+
sitk.WriteImage(cropped, args.out_name)
|