This repository was archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 145
ENH: Publish lung segmentation model #808
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d58c721
✨ Update Lung model parameters
peterhessey b92ad8b
🚨 Fix flake8 warning
peterhessey 6b7aa6e
📝 Create doc structure
peterhessey eda5fcc
📝 Create generic pre-trained model docs
peterhessey 32e77f8
📝 Update hippocampus model card
peterhessey 50dae53
📝 Update model cards
peterhessey afb6584
📝 Fix type
peterhessey 548da05
⚡️ Fit lung model onto smaller GPUs
peterhessey c2ad815
Reduce test crop size for v100s
peterhessey 2743c42
Merge branch 'main' into phessey/train-new-lung-model
peterhessey 0336e95
Maximise test_crop_size
peterhessey 478d37b
📝 Update lung model score card
peterhessey 3292205
📝 Add model download links
peterhessey 06f9571
♻️ Address PR comments
peterhessey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Lung Segmentation Model | ||
|
|
||
| ## Purpose | ||
|
|
||
| This model is designed to perform segmentation of CT scans of human torsos. It is trained to identify 5 key structures: left lung, right lung, heart, spinalcord and esophagus. | ||
|
|
||
| ## Download | ||
|
|
||
| The lung segmentation model can be downloaded from [this release](https://github.com/microsoft/InnerEye-DeepLearning/releases/tag/v0.8). | ||
|
|
||
| ## Connected Components | ||
|
|
||
| It is possible to apply connected components as a post-processing step, and by default this is performed on the 3 largest structures: both lungs and the heart. To alter this behaviour, update the property `largest_connected_component_foreground_classes` of the Lung class in `InnerEye/ML/configs/segmentation/Lung.py`. | ||
|
|
||
| ## Model Card | ||
|
|
||
| ### Model Details | ||
|
|
||
| - Organisation: Biomedical Imaging Team at Microsoft Research, Cambridge UK. | ||
| - Model date: 31st October 2022. | ||
| - Model version: 1.0. | ||
| - Model type: ensemble of 3D UNet. Training details are as described in [this paper](https://jamanetwork.com/journals/jamanetworkopen/fullarticle/2773292). | ||
| - Training details: 5 fold ensemble model. Trained on the [LCTSC 2017 dataset](https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=24284539) (described in detail below). | ||
| - License: The model is released under MIT license as described [here](https://github.com/microsoft/InnerEye-DeepLearning/blob/main/LICENSE). | ||
| - Contact: innereyeinfo@microsoft.com. | ||
|
|
||
| ### Terms of use | ||
|
|
||
| Please note that all models provided by InnerEye-DeepLearning are intended for research purposes only. You are responsible for the performance, the necessary testing, and if needed any regulatory clearance for any of the models produced by this toolbox. | ||
|
|
||
| ### Limitations | ||
|
|
||
| The dataset used for training contains only 60 scans, 10 of which are withheld for testing. This limited amount of training data means that the model underperforms on the smaller structures (esophagus and spinalcord) and may not yet generalise well to data samples from outside the dataset. | ||
|
|
||
| Furthermore, the dataset description does not contain details on the population of patients used for creating the dataset. Therefore it is not possible to assess whether this model is suitable for use on a target population outside of the dataset. | ||
|
|
||
|
peterhessey marked this conversation as resolved.
|
||
| ### Intended Uses | ||
|
|
||
| This model is intended for research purposes only. It is intended to be used as a starting-point for more challenging segmentation tasks or training using more thorough and comprehensive segmentation tasks. | ||
|
|
||
| ### Training Data | ||
|
|
||
| This model is trained on the [LCTSC 2017 dataset](https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=24284539). For a detailed description on this data, including the contouring guidelines, see [this page](https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=24284539#242845396723d79f9909442996e4dd0af5e56a30). | ||
|
|
||
| The following steps were carrried out to create the dataset used for training this model: | ||
|
|
||
| 1. Download the DICOM dataset from the above LCTSC 2017 link. | ||
| 1. Use the [InnerEye-CreateDataset tool](https://github.com/microsoft/InnerEye-CreateDataset) to run the following command on the data: | ||
|
|
||
| ```shell | ||
| .\InnerEye.CreateDataset.Runner.exe dataset --datasetRootDirectory=<path_to_DICOM_data> --niftiDatasetDirectory=lung_nifti --dicomDatasetDirectory=LCTSC --geoNorm 1 1 3 --groundTruthDescendingPriority esophagus spinalcord lung_r lung_l heart | ||
| ``` | ||
|
|
||
| 1. Upload and register NIFTI dataset to Azure by following the [dataset creation](creating_dataset.md) guide. | ||
|
|
||
|
peterhessey marked this conversation as resolved.
|
||
| ### Metrics | ||
|
|
||
| Metrics for the withheld test data (first 10 scans in the dataset), can be seen in the following table: | ||
|
|
||
| | Structure | count | DiceNumeric_mean | DiceNumeric_std | DiceNumeric_min | DiceNumeric_max | HausdorffDistance_mm_mean | HausdorffDistance_mm_std | HausdorffDistance_mm_min | HausdorffDistance_mm_max | MeanDistance_mm_mean | MeanDistance_mm_std | MeanDistance_mm_min | MeanDistance_mm_max | | ||
| |---------------|---------|------------------|-----------------|-----------------|-----------------|---------------------------|--------------------------|--------------------------|--------------------------|----------------------|---------------------|---------------------|---------------------| | ||
| | lung_l | 10 | 0.984 | 0.009 | 0.958 | 0.990 | 11.642 | 4.868 | 6.558 | 19.221 | 0.344 | 0.266 | 0.167 | 1.027 | | ||
| | lung_r | 10 | 0.983 | 0.009 | 0.960 | 0.991 | 10.764 | 3.307 | 6.325 | 16.156 | 0.345 | 0.200 | 0.160 | 0.797 | | ||
| | spinalcord | 10 | 0.860 | 0.050 | 0.756 | 0.912 | 27.213 | 22.015 | 12.000 | 81.398 | 1.750 | 2.167 | 0.552 | 7.209 | | ||
| | heart | 10 | 0.935 | 0.015 | 0.908 | 0.953 | 17.550 | 14.796 | 9.000 | 17.550 | 2.022 | 0.661 | 1.456 | 3.299 | | ||
| | esophagus | 10 | 0.728 | 0.128 | 0.509 | 0.891 | 23.503 | 25.679 | 6.173 | 72.008 | 3.207 | 4.333 | 0.409 | 13.991 | | ||
| | | | | | | | | | | | | | | | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| Pre-Trained Models | ||
| ================== | ||
|
|
||
| InnerEye-DeepLearning currently has two pre-trained models avaiable for use | ||
| in segmentation tasks. This page describes how to set up and use these models. | ||
| For specific information on the models, please refer to the relevant model card: | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
|
|
||
| ../md/hippocampus_model.md | ||
| ../md/lung_model.md | ||
|
|
||
|
|
||
| Terms of use | ||
| ------------ | ||
|
|
||
| Please note that all models provided by InnerEye-DeepLearning are intended for | ||
| research purposes only. You are responsible for the performance, the necessary testing, | ||
| and if needed any regulatory clearance for any of the models produced by this toolbox. | ||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| The following instructions assume you have completed the preceding setup | ||
| steps in the `InnerEye | ||
| README <https://github.com/microsoft/InnerEye-DeepLearning/>`__, in | ||
| particular, `Setting up Azure Machine Learning <setting_up_aml.md>`__. | ||
|
|
||
| Create an AzureML Dataset | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| To evaluate pre-trained models on your own data, you will first need to register | ||
| an `Azure ML | ||
| Dataset <https://docs.microsoft.com/en-us/azure/machine-learning/v1/how-to-create-register-datasets>`__. | ||
| You can follow the instructions in the for `creating | ||
| datasets <creating_dataset.md>`__ in order to do this. | ||
|
|
||
| Downloading the models | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| The saved weights for each model can be found in their respective :ref:`model cards<Pre-Trained Models>`. | ||
| You will need to download the weights and source code for the model that you wish to use. | ||
|
|
||
| Registering a model in Azure ML | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| To evaluate the model in Azure ML, you must first `register an Azure ML | ||
| Model <https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.model.model?view=azure-ml-py#remarks>`__. | ||
| To register the pre-trained model in your AML Workspace, unpack the | ||
| source code downloaded in the previous step and follow InnerEye's | ||
| `instructions to upload models to Azure ML <move_model.md>`__. | ||
|
|
||
| Run the following from a folder that contains both the ``ENVIRONMENT/`` | ||
| and ``MODEL/`` folders (these exist inside the downloaded model files): | ||
|
|
||
| .. code:: shell | ||
|
|
||
| WORKSPACE="fill with your workspace name" | ||
| GROUP="fill with your resource group name" | ||
| SUBSCRIPTION="fill with your subscription ID" | ||
|
|
||
| python InnerEye/Scripts/move_model.py \ | ||
| --action upload \ | ||
| --path . \ | ||
| --workspace_name $WORKSPACE \ | ||
| --resource_group $GROUP \ | ||
| --subscription_id $SUBSCRIPTION \ | ||
| --model_id <Model Name>:<Model Version> | ||
|
|
||
| Evaluating the model | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| You can evaluate the model either in Azure ML or locally using the | ||
| downloaded checkpoint files. These 2 scenarios are described in more | ||
| detail, along with instructions in `testing an existing | ||
| model <building_models.md#testing-an-existing-model>`__. | ||
|
|
||
| For example, to evaluate the model on your Dataset in Azure ML, run the | ||
| following from within the directory ``*/MODEL/final_ensemble_model/`` | ||
|
|
||
| .. code:: shell | ||
|
|
||
| CLUSTER="fill with your cluster name" | ||
| DATASET_ID="fill with your dataset name" | ||
|
|
||
| python InnerEye/ML/runner.py \ | ||
| --azure_dataset_id $DATASET_ID \ | ||
| --model <Model Name> \ | ||
| --model_id <Model Name>:<Model Version> \ | ||
| --experiment_name <experiement name> \ | ||
| --azureml \ | ||
| --no-train \ | ||
| --cluster $CLUSTER | ||
| --restrict_subjects=0,0,+ | ||
|
|
||
| Deploy with InnerEye Gateway | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| To deploy a model using the InnerEye Gateway, see the instructions in the `Gateway Repo <https://github.com/microsoft/InnerEye-Gateway/>`__. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.