aws-samples / annotate-medical-images-in-dicom-server-and-build-ml-models-on-amazon-sagemaker

MIT No Attribution
19 stars 15 forks source link

Annotate Medical Images in DICOM Server and Build ML models using Amazon SageMaker

Overview Architecture

Architecture

Deployment Steps

Pre-requisite

You will need two public subnets and two private subnets in a given Virtual Private Cloud (VPC). You can either follow this blog post to deploy the network infrastructure first, or deploy the VPC network infrastructure using this CloudFormation template (Optional)

Deploy Orthanc DICOM Server on AWS ECS

To deploy the CloudFormation (CFN) on AWS console, using 1-click deployment button:
launchstackbutton

The required information will be EC2 Key pair and network infrastructure.

After the CFN stack is successfully created, the Orthanc endpoint URL will be available in the Outputs tab like:
this

Upload DICOM images to Orthanc

Orthanc supports WADO-RS with its RESTful API. You can upload a DICOM image from local folder:

curl -u orthanc:orthanc -X POST https://<Orthanc URL>/instances --data-binary @<DICOM Image>.dcm -k

After uploaded, check the instance id assigned: curl -u orthanc:orthanc https://<Orthanc URL>/instances -k

Then put instance IDs in source field of manifest.json. Assuming here is the output of the previous command (list of DICOM instances): [ "502b0a4b-5cb43965-7f092716-bd6fe6d6-4f7fc3ce", "af163634-5f8009c8-a941f2a2-4d108bea-119181b5", "3e9562ab-3bd7b304-e003d1f8-0fe2e8f5-e6af3f36" ]
The manifest.json file will look at this.

Deploy the SageMaker Labeling and Notebook Resources

click the button below to deploy lambda functions, S3 bucket, and Notebook instance with appropriate IAM roles:
launchstackbutton

Fill the parameter PreLabelLambdaSourceEndpointURL with the Orthanc endpoint URL from previous step.

Take a note of the outputs of CFN deployment, including SMGTLabelingExecutionRole and SageMakerAnnotationS3Bucket names:
smcfnoutputs

The manifest.json file generated earlier will be uploaded the the SageMakerAnnotationS3Bucket.

Create Custom Label Job in SageMaker GroundTruth

After configuring the custom labeling task, click on the Preview button, you will see the following preview smgtpreview

If you created a private workforce, you can go to the Labeling Workforces tab and find the annotation console link there as shown earlier. The annotator will be able to see the task created like:
startworking

Train and deploy model using SageMaker Notebook Instance

The CFN deployment earlier also create a SageMaker notebook instance, open the Jupyter notebook to train and deploy machine learning models using the annotated datasets from SageMaker GroundTruth labeling job:
smnotebook

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.