This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Publish lung segmentation model (#808)
This PR contains the hyperparameter updates for training and running inference on InnerEye Lung segmentation model on a Standard_NC24rs_v3 Azure cluster (4 x V100). It also includes all the documentation of the model will be released in a tagged version in the same fashion as the [hippocampus model](https://github.com/microsoft/InnerEye-DeepLearning/releases/tag/v0.5). I will tag and release the model after this PR is merged to ensure that the source code in the main branch is correct at the time of release (docs currently include a link to v0.8 which doesn't yet exist).
- Loading branch information
1 parent
12f78f3
commit 6575304
Showing
5 changed files
with
203 additions
and
91 deletions.
There are no files selected for viewing
This file contains 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 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 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 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: [email protected]. | ||
|
||
### 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. | ||
|
||
### 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. | ||
|
||
### 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 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/>`__. |