Image Segmentation For 3-D Images
An example of how to use Deep Learning Studio for performing segmentation in 3-D images such as CT scans.
In this example, we will create an AI app module for the segmentation of Spleen in CT scans. This project aims to determine where the spleen is located in the scans of the abdomen region, the final result will a 3-D representation similar to the CT scan but with only the spleen being highlighted in each and every 2-D slice of the CT scan in which the spleen is present.
Note: The Plugin used in this example is only available for the Business version of the Deep Learning Studio.
The dataset used for this task has been provided by the medical decathlon and can be downloaded from here.
The dataset consists of CT scans which are 3-D representations of a patients body, CT scans or Computed Tomography scans use a combination of multiple X-ray measurements taken from different angles to produce a 3-D view of the body so that physicians can study the patients without any invasive procedure.

A sample slice and its corresponding lable
Once the data has been downloaded create a zip such that it is in the following format:
root
├── imagesTr
├── labelsTr
once the .zip has been created in the given format it is ready to be uploaded.
Follow the steps below to upload the dataset
1) Go to the Datasets tab and click on the upload button.

2) Drag and drop the dataset in the upload area and select 3DSegmentationDataset from the select Dataset format dropdown list.

3) Click on start upload to upload the dataset to the DLS.
Follow the steps given below:
1) Go to the Plugins tab and select the 3D medical Segmentation.
2) Click on install to start installing the AI plugin.
Follow the steps given below:
1) Go to the projects tab and click on the create the project button.
2) Enter the name of the project and select AI app module from the project type dropdown menu. Description of the project is optional.
1) Select the project just created, and select task Specification
2) select 3D Medical Segmentation from AI App Module dropdown list, and set other values in the form as shown in the image below.

Task specification settings
3) Select the spleen dataset from the dropdown in the data tab.
4) go to the Training tab, select the device on which has to be used for training, and then click on start training to start the training process.
1) For taking inference on the best fit model click on the inference/Deploy tab.
2) upload the file you want to take the inference on.
3) click on the start inference button to start inference.
4) After the inference is completed, the path to the output folder is displayed.

1) Trained model and supporting files can be downloaded by clicking on the download tab and select the download Trained model with inference code button.
structure of the downloaded folder is as follows
root
├── test.py (for inference)
├── best_metric_model.pth (model weights)
├── test_environmnet.yaml (for creating a conda environment )
2) create a conda environment by running the following command.
conda env create -f <path to yaml file>
3) activate the conda environment.
conda activate monai_segmentation
4) run the following command for running inference.
python test.py --input <path to the input image> --run_dir <path to the folder where model is stored>
--result_dir <path for the output dir>
Congratulations!
We have successfully created and trained Spleen segmentation AI App