From 3eed5c4793eadb493eb0f2efa6d3422d85f70fa7 Mon Sep 17 00:00:00 2001 From: Josh Williams <48445365+jvwilliams23@users.noreply.github.com> Date: Mon, 20 Feb 2023 16:33:56 +0000 Subject: [PATCH 1/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 619dbad..38ac9a4 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ These will then be split into train and validation sets (which are saved as `tra python3 train.py ``` -### Segmenting +### Using a CNN to segment an image ## Get Help Please submit an issue to the issues panel on this repository. From a7f6506f8b4704307343db14e2a5ef8ff659dce6 Mon Sep 17 00:00:00 2001 From: Josh Williams <48445365+jvwilliams23@users.noreply.github.com> Date: Mon, 20 Feb 2023 16:36:06 +0000 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 38ac9a4..1a6f6d0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Airway and lung segmentations using convolutional neural networks +# Convolutional neural network toolkit for segmenting airways and lungs ## Overview This project aimed to train a machine learning algorithm capable of producing airway and lung segmentations from chest CT scans. From aabe00c22ee1c785a87a37a1a10eb1cb9715088a Mon Sep 17 00:00:00 2001 From: Josh Williams <48445365+jvwilliams23@users.noreply.github.com> Date: Mon, 20 Feb 2023 17:07:44 +0000 Subject: [PATCH 3/4] Update README.md --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a6f6d0..183c48b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ First, install the required dependencies (best practice is to use a virtual envi ```bash conda create --name pycnn python=3.10 conda activate pycnn -pip install hjson numpy pandas torch torchio SimpleITK sklearn vedo +pip install hjson numpy pandas torch torchio SimpleITK sklearn vedo lungmask ``` ### Retraining @@ -29,6 +29,15 @@ python3 train.py ``` ### Using a CNN to segment an image +To lower the memory consumption and inference time for segmenting the airways, we can first segment the lobes and use this as a bounding box for cropping the image +```bash +python segment_lunglobes.py -i /path/to/ct/scan.mhd -id example +``` +The airways can then be segmented by +```bash +python segment.py -i /path/to/ct/scan.mhd -o example.stl +``` +which will create three files in the current directory (`example.mhd`, `example.zraw` and `example.stl`). ## Get Help Please submit an issue to the issues panel on this repository. @@ -39,5 +48,19 @@ If you use the code or models in this repository, please cite our paper @article{TODO} ``` +Also, if you use the `segment_lunglobes.py` script, make sure to read and cite the following great paper: +``` +@article{hofmanninger2020automatic, + title={Automatic lung segmentation in routine imaging is primarily a data diversity problem, not a methodology problem}, + author={Hofmanninger, Johannes and Prayer, Forian and Pan, Jeanny and R{\"o}hrich, Sebastian and Prosch, Helmut and Langs, Georg}, + journal={European Radiology Experimental}, + volume={4}, + number={1}, + pages={1--13}, + year={2020}, + publisher={SpringerOpen} +} +``` + ## Acknowledgements The model architecture scripts [`unet.py`](https://github.com/Thvnvtos/Lung_Segmentation/blob/unet3d/model.py) and [`enet.py`](https://github.com/davidtvs/PyTorch-ENet/blob/master/models/enet.py) were taken from other repositories (see links). From a7996b7d5ea14d62457ae035a47ec09cf1e53fc0 Mon Sep 17 00:00:00 2001 From: Josh Williams <48445365+jvwilliams23@users.noreply.github.com> Date: Mon, 20 Feb 2023 17:08:29 +0000 Subject: [PATCH 4/4] Update typo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 183c48b..6e83fb4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ To retrain a CNN on some data you have available, add the paths to the images an ``` These will then be split into train and validation sets (which are saved as `train_cases.txt` and `val_cases.txt`). Also you can edit any hyperparameters defined in `trainconfig.json` and run ```bash -python3 train.py +python train.py ``` ### Using a CNN to segment an image