lyroi 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lyroi-0.1.0/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 [2025] [HZDR and contributors]
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.
lyroi-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: lyroi
3
+ Version: 0.1.0
4
+ Summary: LyROI - nnU-Net-based Lymphoma Total Metabolic Tumor Volume Segmentation
5
+ Author-email: Pavel Nikulin <p.nikulin@hzdr.de>, Jens Maus <j.maus@hzdr.de>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/hzdr-MedImaging/LyROI
8
+ Project-URL: Documentation, https://github.com/hzdr-MedImaging/LyROI/blob/main/README.md
9
+ Project-URL: Source, https://github.com/hzdr-MedImaging/LyROI
10
+ Keywords: deep learning,ai,lymphoma,pet,petct,tmtv,mtv,nnunet,lyroi,delineations,segmentation,cancer
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Healthcare Industry
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Operating System :: Unix
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
19
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: torch>=2.1.2
24
+ Requires-Dist: numpy
25
+ Requires-Dist: acvl-utils==0.2
26
+ Requires-Dist: nnunetv2>=2.5.2
27
+ Requires-Dist: requests
28
+ Requires-Dist: nibabel
29
+ Requires-Dist: packaging
30
+ Requires-Dist: psutil
31
+ Dynamic: license-file
32
+
33
+ # LyROI – nnU-Net-based Lymphoma Total Metabolic Tumor Volume Delineation
34
+
35
+ > [!IMPORTANT]
36
+ > **Regulatory status:** This software and the bundled model are intended **solely for research and development (R&D)**.
37
+ > They are **not** intended for primary diagnosis, therapy, or any other clinical decision-making and must **not** be used
38
+ > as a medical device.
39
+
40
+ ## Overview
41
+
42
+ **Ly**mphoma **ROI** prediction framework (**LyROI**) is a collection of neural network models and support tools for
43
+ metabolic tumor volume delineation in (Non-Hodgkin) lymphoma patients in FDG-PET/CT images.
44
+
45
+ A comprehensive description of development and evaluation of the models is given in the respective [paper](DOI:XXX).
46
+ Briefly, the models were trained with the [nnU-Net](https://github.com/MIC-DKFZ/nnUNet) software package. A total of
47
+ 1192 FDG-PET/CT scans from 716 patients with Non-Hodgkin
48
+ lymphoma participating in the [PETAL](https://doi.org/10.1200/jco.2017.76.8093) trial comprised the training dataset.
49
+ The ground truth delineation included all lesions (irrespective of size or uptake) that were clinically considered as
50
+ lymphoma manifestations by an experienced observer. It was developed iteratively with the assistance of intermediate CNN
51
+ models. Accurate contouring of each lesion was achieved by selecting the most appropriate semi-automated delineation
52
+ algorithm, manually adjusting its settings, and performing manual corrections when necessary.
53
+
54
+ Training and testing were performed following a 5-fold cross-validation scheme. Three configurations of the nnU-Net were
55
+ used for training: regular U-Net, residual encoder U-Net (8 GB GPU memory target), and large residual encoder U-Net
56
+ (24 GB GPU memory target).
57
+ They can be installed as described below and used separately, however, their use in an ensemble (merging individual
58
+ outputs via union operation) is recommended to maximize lesion detection sensitivity.
59
+
60
+ The collection of the trained models can be found here:
61
+
62
+ [![DOI: 10.14278/rodare.4160](https://zenodo.org/badge/DOI/10.14278/rodare.4160.svg)](https://doi.org/10.14278/rodare.4160)
63
+
64
+ List of available models:
65
+ - `LyROI_Orig.zip`: regular U-Net
66
+ - `LyROI_ResM.zip`: residual encoder U-Net (medium)
67
+ - `LyROI_ResL.zip`: residual encoder U-Net (large)
68
+
69
+
70
+
71
+ [Scripts](scripts/) subfolder
72
+ provides example code snippets to execute the prediction with each model and merge the resulting delineations when using
73
+ directly within existing nnU-Net installation. See [manual installation](#manual-installation-and-use) section for more
74
+ details.
75
+ For simplified workflow, LyROI is also available as a stand-alone tool, see [quick start](#quick-start) section for
76
+ usage and installation instructions.
77
+
78
+ Please cite [nnU-Net](https://www.nature.com/articles/s41592-020-01008-z) and the [following paper](DOI:XXX) when using
79
+ LyROI:
80
+
81
+ ```
82
+ XXX
83
+ ```
84
+
85
+ Special thanks to the PETAL study group for the access to the [PETAL](https://doi.org/10.1200/jco.2017.76.8093) trial dataset
86
+ for the network training and agreeing to share the resulting models.
87
+
88
+ ## Quick Start
89
+
90
+ > [!IMPORTANT]
91
+ > Working within a dedicated virtual environment (`venv` or `conda`) is highly recommended.
92
+
93
+ > **Requirements**
94
+ > - `python` (>= 3.9)
95
+ > - [`pytorch`](https://pytorch.org/get-started/locally/) (>= 2.1.2)
96
+
97
+ 1. Install `python` and `pytorch` (see requirements list above).
98
+
99
+ **Note: As of now, torch >=2.9.0 leads to severe performance
100
+ reduction. Earlier versions are recommended.**
101
+ 2. Install `lyroi` as a package (recommended):
102
+ ```
103
+ pip install lyroi
104
+ ```
105
+ or as modifiable copy (for experienced users):
106
+ ```
107
+ git clone https://github.com/hzdr-MedImaging/LyROI.git
108
+ cd LyROI
109
+ pip install -e .
110
+ ```
111
+ 3. (OPTIONAL) To change the default model installation directory (default: `$HOME/.lyroi`), set the environment variable
112
+ `LYROI_DIR` to the desired location. See, e.g.
113
+ [here](https://www.freecodecamp.org/news/how-to-set-an-environment-variable-in-linux/) for guidance.
114
+ 4. Download and install the model files:
115
+ ```
116
+ lyroi_install
117
+ ```
118
+ 5. Run LyROI for
119
+ - all images in the `input_folder` (see [below](#data-format) for input data format) and output delineation in
120
+ `output_folder`:
121
+ ```
122
+ lyroi -i input_folder -o output_folder
123
+ ```
124
+ - a single patient with CT image `ct.nii.gz` and PET image `pet.nii.gz` (must be coregistered and have the same
125
+ matrix and voxel sizes) and output delineation to `roi.nii.gz`:
126
+ ```
127
+ lyroi -i ct.nii.gz pet.nii.gz -o roi.nii.gz
128
+ ```
129
+ Execution on a GPU-equipped workstation is highly recommended. In case if no GPU is available, use a flag `-d cpu` to force
130
+ run on CPU (can be **VERY** slow). Flag `-d cpu-max` can help with cpu performance by using all available
131
+ computational resources (may slow down other programs). `nnUNet_def_n_proc` environment variable can be set to limit
132
+ the number of utilized cpu cores in `cpu-max` mode.
133
+
134
+ ## Manual Installation and Use
135
+
136
+ > **Requirements**
137
+ > - `python` (>= 3.9)
138
+ > - [`pytorch`](https://pytorch.org/get-started/locally/) (>= 2.1.2)
139
+ > - [`nnU-Net`](https://github.com/MIC-DKFZ/nnUNet/blob/dev/documentation/installation_instructions.md) (>= 2.5.2)
140
+
141
+ 1. To download and install the models for each used nnU-Net configuration, execute:
142
+ ```
143
+ nnUNetv2_install_pretrained_model_from_zip https://rodare.hzdr.de/record/4177/files/LyROI_Orig.zip
144
+ nnUNetv2_install_pretrained_model_from_zip https://rodare.hzdr.de/record/4177/files/LyROI_ResM.zip
145
+ nnUNetv2_install_pretrained_model_from_zip https://rodare.hzdr.de/record/4177/files/LyROI_ResL.zip
146
+ ```
147
+ 2. By default, the models will be installed in the folder ``$nnUNet_results/Dataset001_LyROI/``. This might create
148
+ conflicts if you already have a project with the number 001 in your ``$nnUNet_results`` folder. In this case, please
149
+ choose an unoccupied index ``XXX`` for the dataset and rename the LyROI folder to ``DatasetXXX_LyROI``.
150
+ 3. Download all files in [scripts](scripts/) folder and put them in the same folder. If you changed the dataset index of
151
+ LyROI, edit the [predict.sh](scripts/predict.sh) file and change the ``dataset_id="001"`` line to
152
+ ``dataset_id="XXX"``, where XXX is the new dataset index you selected.
153
+ 4. Prepare the input data according to the instructions [below](#data-format).
154
+ 5. Execute ``./predict.sh /path/to/your/folder/input_folder`` and wait for the process to complete. The resulting
155
+ delineations can be found in ``input_folder/pred/`` subfolder. If you want to keep the outputs of the intermediate
156
+ networks, comment out the last line in [predict.sh](scripts/predict.sh). Execution on a GPU-equipped workstation is
157
+ highly recommended. In case if no GPU is available, add a flag `-device cpu` to `nnUNetv2_predict` calls within the
158
+ script (can be **VERY** slow). Set `nnUNet_def_n_proc` environment variable to specify the number of cpu cores to use
159
+ for inference (set to the number of physical cpu cores for max performance).
160
+
161
+ ## Data Format
162
+
163
+ The input data for batch processing should be presented in the nnU-Net compatible format
164
+ (see [here](https://github.com/MIC-DKFZ/nnUNet/blob/master/documentation/dataset_format_inference.md) for details).
165
+ Only compressed NIfTI (`.nii.gz`) images are currently supported. Corresponding CT and PET volumes must be coregistered
166
+ and have the same matrix and voxel sizes.
167
+
168
+ Input channels:
169
+ - `0000` is CT
170
+ - `0001` is PET
171
+
172
+ Here is an example of how the input folder can look like:
173
+
174
+ ```
175
+ input_folder
176
+ ├── lymph_20250101_0000.nii.gz
177
+ ├── lymph_20250101_0001.nii.gz
178
+ ├── pat01_0000.nii.gz
179
+ ├── pat01_0001.nii.gz
180
+ ├── rchop001_0000.nii.gz
181
+ ├── rchop001_0001.nii.gz
182
+ ├── ...
183
+ ```
184
+
185
+ ## Intended Purpose (Non-Medical)
186
+
187
+ - The software is intended for **algorithmic research, benchmarking, and method exploration** in lymphoma delineation.
188
+ - It is **not intended** to provide information for diagnostic or therapeutic purposes and **must not** be used in
189
+ clinical workflows.
190
+ - Do **not** deploy or advertise this software as a medical product or service.
191
+
192
+ ## Disclaimer (Research Use Only – Not a Medical Device)
193
+
194
+ This software and any bundled or referenced model weights are provided **exclusively for research and development
195
+ purposes**. They are **not intended** for use in the diagnosis, cure, mitigation, treatment, or prevention of disease,
196
+ or for any other clinical decision-making.
197
+
198
+ - The software is **not** a medical device and is **not** CE-marked.
199
+ - No clinical performance, safety, or effectiveness is claimed or implied.
200
+ - Any results must not be used to guide patient management.
201
+ - Users are responsible for compliance with all applicable laws, regulations, and data protection requirements when
202
+ processing data.
203
+
204
+ THE SOFTWARE AND MODELS ARE PROVIDED “AS IS”, WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED.
205
+
206
+ ## Licenses
207
+
208
+ The **code** in this repository is licensed under **Apache-2.0** (see [`LICENSE`](LICENSE)).
209
+ The **model weights** are licensed under **CC-BY-SA-4.0** (see [`MODEL_LICENSE.md`](MODEL_LICENSE.md)).
210
+
211
+ ## Third-Party Licenses
212
+
213
+ This project uses or interoperates with the following third-party components:
214
+
215
+ - **nnU-Net v2** – Copyright © respective authors.
216
+ - License: **Apache-2.0**
217
+ - **PyTorch**, **NumPy**, **Nibabel**, etc.
218
+ - Licensed under their respective open-source licenses.
219
+
220
+ Each third-party component is the property of its respective owners and is provided under its own license terms. Copies
221
+ of these licenses are available from the upstream projects.
lyroi-0.1.0/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # LyROI – nnU-Net-based Lymphoma Total Metabolic Tumor Volume Delineation
2
+
3
+ > [!IMPORTANT]
4
+ > **Regulatory status:** This software and the bundled model are intended **solely for research and development (R&D)**.
5
+ > They are **not** intended for primary diagnosis, therapy, or any other clinical decision-making and must **not** be used
6
+ > as a medical device.
7
+
8
+ ## Overview
9
+
10
+ **Ly**mphoma **ROI** prediction framework (**LyROI**) is a collection of neural network models and support tools for
11
+ metabolic tumor volume delineation in (Non-Hodgkin) lymphoma patients in FDG-PET/CT images.
12
+
13
+ A comprehensive description of development and evaluation of the models is given in the respective [paper](DOI:XXX).
14
+ Briefly, the models were trained with the [nnU-Net](https://github.com/MIC-DKFZ/nnUNet) software package. A total of
15
+ 1192 FDG-PET/CT scans from 716 patients with Non-Hodgkin
16
+ lymphoma participating in the [PETAL](https://doi.org/10.1200/jco.2017.76.8093) trial comprised the training dataset.
17
+ The ground truth delineation included all lesions (irrespective of size or uptake) that were clinically considered as
18
+ lymphoma manifestations by an experienced observer. It was developed iteratively with the assistance of intermediate CNN
19
+ models. Accurate contouring of each lesion was achieved by selecting the most appropriate semi-automated delineation
20
+ algorithm, manually adjusting its settings, and performing manual corrections when necessary.
21
+
22
+ Training and testing were performed following a 5-fold cross-validation scheme. Three configurations of the nnU-Net were
23
+ used for training: regular U-Net, residual encoder U-Net (8 GB GPU memory target), and large residual encoder U-Net
24
+ (24 GB GPU memory target).
25
+ They can be installed as described below and used separately, however, their use in an ensemble (merging individual
26
+ outputs via union operation) is recommended to maximize lesion detection sensitivity.
27
+
28
+ The collection of the trained models can be found here:
29
+
30
+ [![DOI: 10.14278/rodare.4160](https://zenodo.org/badge/DOI/10.14278/rodare.4160.svg)](https://doi.org/10.14278/rodare.4160)
31
+
32
+ List of available models:
33
+ - `LyROI_Orig.zip`: regular U-Net
34
+ - `LyROI_ResM.zip`: residual encoder U-Net (medium)
35
+ - `LyROI_ResL.zip`: residual encoder U-Net (large)
36
+
37
+
38
+
39
+ [Scripts](scripts/) subfolder
40
+ provides example code snippets to execute the prediction with each model and merge the resulting delineations when using
41
+ directly within existing nnU-Net installation. See [manual installation](#manual-installation-and-use) section for more
42
+ details.
43
+ For simplified workflow, LyROI is also available as a stand-alone tool, see [quick start](#quick-start) section for
44
+ usage and installation instructions.
45
+
46
+ Please cite [nnU-Net](https://www.nature.com/articles/s41592-020-01008-z) and the [following paper](DOI:XXX) when using
47
+ LyROI:
48
+
49
+ ```
50
+ XXX
51
+ ```
52
+
53
+ Special thanks to the PETAL study group for the access to the [PETAL](https://doi.org/10.1200/jco.2017.76.8093) trial dataset
54
+ for the network training and agreeing to share the resulting models.
55
+
56
+ ## Quick Start
57
+
58
+ > [!IMPORTANT]
59
+ > Working within a dedicated virtual environment (`venv` or `conda`) is highly recommended.
60
+
61
+ > **Requirements**
62
+ > - `python` (>= 3.9)
63
+ > - [`pytorch`](https://pytorch.org/get-started/locally/) (>= 2.1.2)
64
+
65
+ 1. Install `python` and `pytorch` (see requirements list above).
66
+
67
+ **Note: As of now, torch >=2.9.0 leads to severe performance
68
+ reduction. Earlier versions are recommended.**
69
+ 2. Install `lyroi` as a package (recommended):
70
+ ```
71
+ pip install lyroi
72
+ ```
73
+ or as modifiable copy (for experienced users):
74
+ ```
75
+ git clone https://github.com/hzdr-MedImaging/LyROI.git
76
+ cd LyROI
77
+ pip install -e .
78
+ ```
79
+ 3. (OPTIONAL) To change the default model installation directory (default: `$HOME/.lyroi`), set the environment variable
80
+ `LYROI_DIR` to the desired location. See, e.g.
81
+ [here](https://www.freecodecamp.org/news/how-to-set-an-environment-variable-in-linux/) for guidance.
82
+ 4. Download and install the model files:
83
+ ```
84
+ lyroi_install
85
+ ```
86
+ 5. Run LyROI for
87
+ - all images in the `input_folder` (see [below](#data-format) for input data format) and output delineation in
88
+ `output_folder`:
89
+ ```
90
+ lyroi -i input_folder -o output_folder
91
+ ```
92
+ - a single patient with CT image `ct.nii.gz` and PET image `pet.nii.gz` (must be coregistered and have the same
93
+ matrix and voxel sizes) and output delineation to `roi.nii.gz`:
94
+ ```
95
+ lyroi -i ct.nii.gz pet.nii.gz -o roi.nii.gz
96
+ ```
97
+ Execution on a GPU-equipped workstation is highly recommended. In case if no GPU is available, use a flag `-d cpu` to force
98
+ run on CPU (can be **VERY** slow). Flag `-d cpu-max` can help with cpu performance by using all available
99
+ computational resources (may slow down other programs). `nnUNet_def_n_proc` environment variable can be set to limit
100
+ the number of utilized cpu cores in `cpu-max` mode.
101
+
102
+ ## Manual Installation and Use
103
+
104
+ > **Requirements**
105
+ > - `python` (>= 3.9)
106
+ > - [`pytorch`](https://pytorch.org/get-started/locally/) (>= 2.1.2)
107
+ > - [`nnU-Net`](https://github.com/MIC-DKFZ/nnUNet/blob/dev/documentation/installation_instructions.md) (>= 2.5.2)
108
+
109
+ 1. To download and install the models for each used nnU-Net configuration, execute:
110
+ ```
111
+ nnUNetv2_install_pretrained_model_from_zip https://rodare.hzdr.de/record/4177/files/LyROI_Orig.zip
112
+ nnUNetv2_install_pretrained_model_from_zip https://rodare.hzdr.de/record/4177/files/LyROI_ResM.zip
113
+ nnUNetv2_install_pretrained_model_from_zip https://rodare.hzdr.de/record/4177/files/LyROI_ResL.zip
114
+ ```
115
+ 2. By default, the models will be installed in the folder ``$nnUNet_results/Dataset001_LyROI/``. This might create
116
+ conflicts if you already have a project with the number 001 in your ``$nnUNet_results`` folder. In this case, please
117
+ choose an unoccupied index ``XXX`` for the dataset and rename the LyROI folder to ``DatasetXXX_LyROI``.
118
+ 3. Download all files in [scripts](scripts/) folder and put them in the same folder. If you changed the dataset index of
119
+ LyROI, edit the [predict.sh](scripts/predict.sh) file and change the ``dataset_id="001"`` line to
120
+ ``dataset_id="XXX"``, where XXX is the new dataset index you selected.
121
+ 4. Prepare the input data according to the instructions [below](#data-format).
122
+ 5. Execute ``./predict.sh /path/to/your/folder/input_folder`` and wait for the process to complete. The resulting
123
+ delineations can be found in ``input_folder/pred/`` subfolder. If you want to keep the outputs of the intermediate
124
+ networks, comment out the last line in [predict.sh](scripts/predict.sh). Execution on a GPU-equipped workstation is
125
+ highly recommended. In case if no GPU is available, add a flag `-device cpu` to `nnUNetv2_predict` calls within the
126
+ script (can be **VERY** slow). Set `nnUNet_def_n_proc` environment variable to specify the number of cpu cores to use
127
+ for inference (set to the number of physical cpu cores for max performance).
128
+
129
+ ## Data Format
130
+
131
+ The input data for batch processing should be presented in the nnU-Net compatible format
132
+ (see [here](https://github.com/MIC-DKFZ/nnUNet/blob/master/documentation/dataset_format_inference.md) for details).
133
+ Only compressed NIfTI (`.nii.gz`) images are currently supported. Corresponding CT and PET volumes must be coregistered
134
+ and have the same matrix and voxel sizes.
135
+
136
+ Input channels:
137
+ - `0000` is CT
138
+ - `0001` is PET
139
+
140
+ Here is an example of how the input folder can look like:
141
+
142
+ ```
143
+ input_folder
144
+ ├── lymph_20250101_0000.nii.gz
145
+ ├── lymph_20250101_0001.nii.gz
146
+ ├── pat01_0000.nii.gz
147
+ ├── pat01_0001.nii.gz
148
+ ├── rchop001_0000.nii.gz
149
+ ├── rchop001_0001.nii.gz
150
+ ├── ...
151
+ ```
152
+
153
+ ## Intended Purpose (Non-Medical)
154
+
155
+ - The software is intended for **algorithmic research, benchmarking, and method exploration** in lymphoma delineation.
156
+ - It is **not intended** to provide information for diagnostic or therapeutic purposes and **must not** be used in
157
+ clinical workflows.
158
+ - Do **not** deploy or advertise this software as a medical product or service.
159
+
160
+ ## Disclaimer (Research Use Only – Not a Medical Device)
161
+
162
+ This software and any bundled or referenced model weights are provided **exclusively for research and development
163
+ purposes**. They are **not intended** for use in the diagnosis, cure, mitigation, treatment, or prevention of disease,
164
+ or for any other clinical decision-making.
165
+
166
+ - The software is **not** a medical device and is **not** CE-marked.
167
+ - No clinical performance, safety, or effectiveness is claimed or implied.
168
+ - Any results must not be used to guide patient management.
169
+ - Users are responsible for compliance with all applicable laws, regulations, and data protection requirements when
170
+ processing data.
171
+
172
+ THE SOFTWARE AND MODELS ARE PROVIDED “AS IS”, WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED.
173
+
174
+ ## Licenses
175
+
176
+ The **code** in this repository is licensed under **Apache-2.0** (see [`LICENSE`](LICENSE)).
177
+ The **model weights** are licensed under **CC-BY-SA-4.0** (see [`MODEL_LICENSE.md`](MODEL_LICENSE.md)).
178
+
179
+ ## Third-Party Licenses
180
+
181
+ This project uses or interoperates with the following third-party components:
182
+
183
+ - **nnU-Net v2** – Copyright © respective authors.
184
+ - License: **Apache-2.0**
185
+ - **PyTorch**, **NumPy**, **Nibabel**, etc.
186
+ - Licensed under their respective open-source licenses.
187
+
188
+ Each third-party component is the property of its respective owners and is provided under its own license terms. Copies
189
+ of these licenses are available from the upstream projects.
@@ -0,0 +1,41 @@
1
+ from datetime import datetime
2
+ from importlib.metadata import version, PackageNotFoundError, metadata
3
+ import re
4
+ import sys
5
+ import signal
6
+
7
+ __package__ = "lyroi"
8
+ creation_date = datetime(2025, 11, 26)
9
+
10
+ try:
11
+ __version__ = version(__package__)
12
+ except PackageNotFoundError:
13
+ __version__ = "0.0.0"
14
+
15
+ meta = metadata(__package__)
16
+ email_list = meta.get("Author-email", "")
17
+ author_str = re.sub(r"<[^>]*>", "", email_list).strip()
18
+ now_date = datetime.now()
19
+ date_str = now_date.strftime("%Y") if creation_date.year == now_date.year else creation_date.strftime("%Y") + "-" + now_date.strftime("%Y")
20
+ __copyright__ = "Copyright (c) " + date_str + " " + author_str + ", www.hzdr.de"
21
+ __license__ = meta.get("License-Expression")
22
+
23
+ __legal__ = ("Disclaimer:\n"
24
+ "This software is intended for research use only.\n"
25
+ "It is not a medical device and must not be used for clinical decisions.\n\n"
26
+ f"{__package__} {__version__}\n"
27
+ f"{__copyright__}\n"
28
+ f"License: {__license__}; models are licensed separately")
29
+
30
+ def error_handler(exctype, value, traceback):
31
+ print()
32
+ print("Error:", value, file=sys.stderr)
33
+ sys.exit(1)
34
+
35
+ def exit_handler(signal, frame):
36
+ print()
37
+ print("User abort (CTRL-C) received.")
38
+ sys.exit(0)
39
+
40
+ signal.signal(signal.SIGINT, exit_handler)
41
+ sys.excepthook = error_handler