Skip to content

Commit 610040e

Browse files
committed
initial upload of code
0 parents  commit 610040e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+10043
-0
lines changed

.gitignore

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/
130+
131+
### JetBrains template
132+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
133+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
134+
135+
# User-specific stuff:
136+
.idea/workspace.xml
137+
.idea/tasks.xml
138+
.idea/dictionaries
139+
.idea/vcs.xml
140+
.idea/jsLibraryMappings.xml
141+
142+
# Sensitive or high-churn files:
143+
.idea/dataSources.ids
144+
.idea/dataSources.xml
145+
.idea/dataSources.local.xml
146+
.idea/sqlDataSources.xml
147+
.idea/dynamic.xml
148+
.idea/uiDesigner.xml
149+
150+
# Gradle:
151+
.idea/gradle.xml
152+
.idea/libraries
153+
154+
# Mongo Explorer plugin:
155+
.idea/mongoSettings.xml
156+
157+
.idea/
158+
159+
## File-based project format:
160+
*.iws
161+
162+
## Plugin-specific files:
163+
164+
# IntelliJ
165+
/out/
166+
167+
# mpeltonen/sbt-idea plugin
168+
.idea_modules/
169+
170+
# JIRA plugin
171+
atlassian-ide-plugin.xml
172+
173+
# Crashlytics plugin (for Android Studio and IntelliJ)
174+
com_crashlytics_export_strings.xml
175+
crashlytics.properties
176+
crashlytics-build.properties
177+
fabric.properties
178+
179+
# Mac
180+
.DS_Store
181+
182+
# own folders
183+
results

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Paul Kaftan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Sparse Keypoint Segmentation of Lung Fissures: Efficient Geometric Deep Learning for Abstracting Volumetric Images
2+
This repository contains the code for segmenting pulmonary fissures in CT images using keypoint extraction and geometric deep learning.
3+
4+
![Overview of the pipeline](overview.png)
5+
6+
# Environment
7+
Install the required packages using Anaconda and the provided environment file:
8+
```bash
9+
conda env create -f environment.yml
10+
conda activate fissure-segmentation
11+
```
12+
13+
# Data
14+
Datasets used in the evaluation are openly available for research purposes. Please refer to the original sources
15+
detailed below.
16+
17+
## Training / cross-validation data
18+
The TotalSegmentator data set is the main data set used for this work.
19+
Download it from here: https://doi.org/10.5281/zenodo.6802614 (v1.0).
20+
The data has to be preprocessed with `preprocess_totalsegmentator_dataset.py`, make sure to point to the correct data
21+
path `TS_RAW_DATA_PATH` in `constants.py`. The script selects applicable images (showing the entire thorax), extracts fissure
22+
segmentations from the lobe masks and crops the images to the thoracic region. Results will be written to
23+
`IMG_DIR_TS_PREPROC`.
24+
25+
## COPD validation data set
26+
The COPD data set can be accessed here: https://med.emory.edu/departments/radiation-oncology/research-laboratories/deformable-image-registration/downloads-and-reference-data/copdgene.html
27+
(citation: Castillo et al., Phys Med Biol 2013 https://doi.org/10.1088/0031-9155/58/9/2861)
28+
The manual fissure annotations are available from here: http://www.mpheinrich.de/research.html#COPD (citation:
29+
Rühaak et al., IEEE TMI 2017 https://doi.org/10.1109/TMI.2017.2691259).
30+
31+
The images should be named `<patid>_img_<fixed/moving>.nii.gz` and be in the same folder (`data/images/COPD`) as the
32+
fissure annotations `<patid>_fissures_<fixed/moving>.nii.gz` and lung masks `<patid>_mask_<fixed/moving>.nii.gz`.
33+
Masks can be generated automatically by, e.g., using the `lungmask` tool https://github.com/JoHof/lungmask.
34+
35+
Then, preprocessing can be applied by running `preprocess_copd_dataset.py`.
36+
37+
## Pre-computing keypoints and features
38+
Keypoints and features are pre-computed from the image data. Run the following scripts:
39+
1. `python -m data_processing.keypint_extraction`
40+
2. `python -m data_processing.point_features`
41+
Results will be written into `data/points` by default.
42+
43+
# Train models
44+
The different models can be trained using the following scripts:
45+
- Point Cloud segmentation networks (DGCNN, PointNet, PointTransformer): `train_point_segmentation.py`
46+
- Point Cloud Autoencoder (PC-AE): `train_pc_ae.py`
47+
- Keypoint CNN (MobileNetV3 + LR-ASPP): `train_keypoint_cnn.py` (pre-trained weights are available in `results/lraspp_recall_loss`)
48+
Run the scripts with the `-h` flag to see available options.
49+
50+
# Evaluate models
51+
The given training scripts already contain test functions for all models.
52+
53+
Evaluation of the PC-AE reconstruction of fissures can be done using the `evaluate_pc_ae.py` script. This will take a
54+
trained point cloud segmentation network and apply a trained PC-AE for mesh reconstruction (instead of Poisson surface
55+
reconstruction).
56+
57+
The nnU-Net baseline was evaluated using `evaluate_nnunet.py`.
58+
59+
# Citation
60+
If you used code in this repository or found it useful in any way for your research, please cite the following papers:
61+
62+
1. Journal paper for Point Cloud Autoencoder (PC-AE) and comparison of geometric segmentation networks (under review):
63+
```
64+
@article{Kaftan2024_FissureSegmentation_IJCARS,
65+
title={Sparse Keypoint Segmentation of Lung Fissures: Efficient Geometric Deep Learning for Abstracting Volumetric Images},
66+
author={Kaftan, Paul and Heinrich, Mattias P and Hansen, Lasse and Rasche, Volker and Kestler, Hans A and Bigalke, Alexander},
67+
journal={International Journal of Computer Assisted Radiology and Surgery},
68+
year={tbd},
69+
volume={tbd},
70+
number={tbd},
71+
pages={tbd},
72+
doi={tbd}
73+
}
74+
```
75+
76+
2. Conference paper for comparison of more keypoints and features:
77+
```
78+
@InProceedings{Kaftan2024_FissureSegmentation_BVM,
79+
author = {Kaftan, Paul and Heinrich, Mattias P. and Hansen, Lasse and Rasche, Volker and Kestler, Hans A. and Bigalke, Alexander},
80+
editor = {Maier, Andreas and Deserno, Thomas M. and Handels, Heinz and Maier-Hein, Klaus and Palm, Christoph and Tolxdorff, Thomas},
81+
title = {Abstracting Volumetric Medical Images with Sparse Keypoints for Efficient Geometric Segmentation of Lung Fissures with a Graph CNN},
82+
booktitle = {Bildverarbeitung f{\"u}r die Medizin 2024},
83+
year = {2024},
84+
publisher = {Springer Fachmedien Wiesbaden},
85+
address = {Wiesbaden},
86+
pages = {60--65},
87+
isbn = {978-3-658-44037-4},
88+
doi = {10.1007/978-3-658-44037-4_19}
89+
}
90+
```

cli/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)