This project implements a full pipeline for working with medical images in DICOM format, using MONAI Deploy and a pretrained model for lung nodule detection on CT scans.
To use this repository, you need to set up a Python virtual environment with MONAI and all required libraries.
In your terminal:
.\your_folder_name\Scripts\python.exeThen activate the environment:
- On Command Prompt or PowerShell:
.\your_folder_name\Scripts\activate- On Git Bash:
source your_folder_name/Scripts/activateMake sure you're inside the activated environment. Then run:
pip install -r requirements.txtThe requirements.txt file should be located at the root of your project.
This project uses the LUNA16 dataset for lung CT scans. You must download it to access .mhd image files and convert them to DICOM for further processing.
🔗 Download link:
https://zenodo.org/records/3723295
After downloading, convert the .mhd files to DICOM format by running the following command:
python convert_image.py🗂️ The converted DICOM files will be saved in the /dicom folder.
We use MONAI Model Zoo’s pretrained model for lung nodule detection.
git clone https://github.com/Project-MONAI/model-zoo.gitcd model-zoo/models/lung_nodule_ct_detectioncp model.pt /path/to/your/projectMake sure model.pt is located at the root of your project directory.
Before executing the full pipeline, you need to build and start the required Docker containers.
First, create a Docker network so all containers can communicate:
docker network create lung_netThe Lung Nodule container is built from the Dockerfile provided in the project.
- Build the container:
docker build -t lung_nodule -f Dockerfile .- Start the container in the created network:
docker run -d --name lung_nodule --network lung_net lung_noduleThe Orthanc container is built from the pre-built image jodogne/orthanc.
- Pull the Orthanc image:
docker pull jodogne/orthanc- Run the Orthanc container in the created network:
docker run -d --name orthanc --network lung_net -p 8042:8042 jodogne/orthancThe MONAI Deploy container is based on the default MONAI Deploy image.
- Pull the MONAI Deploy image:
docker pull monai/monai-deploy- Run the MONAI Deploy container in the created network:
docker run -d --name monai_deploy --network lung_net monai/monai-deployOnce the containers are up and running, follow these steps to execute the full pipeline.
Before running the full pipeline, you need to upload images to the lung_nodule container. This can be done using curl.exe:
curl -X POST -F "file=@uploads/image.dcm" http://localhost:5000/upload🗂️ The images to be uploaded should be stored in the /uploads folder.
Run the app.py script inside the Lung Nodule Docker container to start the image processing pipeline.
docker exec -it lung_nodule python app.pyRun orthanc_client.py inside the Lung Nodule container to upload processed images to Orthanc:
docker exec -it lung_nodule python orthanc_client.pyOnce the images are uploaded to Orthanc and processed by MONAI, you can execute the full pipeline:
docker exec -it lung_nodule python pipeline.py🗂️ The images downloaded from Orthanc will be saved in the /downloads folder.
🗂️ The images processed by MONAI will be saved in the /infered folder.
After executing the full pipeline, you can view the processed images in Orthanc by navigating to the following URL in your browser:
http://localhost:8042/instances
This project is licensed under the MIT License - see the LICENSE file for details.