This project aims to enable the OHIF Viewer interface to launch a deep learning algorithm designed to detect brain metastases, based on the UNETR architecture. This part of the project serves as an API to communicate between the Orthanc DICOM Web Server for retrieving/managing medical data in DICOM format and the fine-tuned UNETR deep learning model for brain metastasis segmentation.
This project is divided into two parts:
- The back-end part (this repository)
- The front-end part is accessible here.
Resource | Requirement |
---|---|
RAM | 8GB VRAM |
GPU | RTX 3050 Cuda |
The front-end of the project is responsible for the user interface and interaction. The primary code for the MetIA functionality is located in the extensions/MetIA/
directory. The structure is as follows:
modes/
- Contains the different modes of the application.extensions/MetIA/
- Houses the main code for the MetIA functionalities.routes/
- Manages the routes for the front-end components.
The back-end handles the processing, database management, and integration with external tools. The main back-end components include:
api.py
- Contains the main code along with all the routes for the back-end services.segmentation.py
- This code is responsible for launching the model.unetr/
- This directory contains the code for the UNETR model.BDD/mesures.sql/
- Stores the database and SQL scripts for the tracking.Orthanc/
- All code related to Orthanc, a DICOM Web server, is located in this directory.
Download the pre-trained weights
Place this 300 MB file in unetr/pretrained_models/
/!\ Use a new environnement with python 3.9
conda create --name=IRM-Project python=3.9
conda activate IRM-Project
pip install -r requirements.txt
If you encounter difficulties installing, try installing the libraries incrementally. Special mention for installing PyTorch:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu111
Create a network named 'pacs' with Docker if it hasn't been created:
docker network create pacs
Then, start the Docker stack by navigating to the root of the repository:
docker-compose -f Orthanc/docker-compose.yml up -d
To start the API:
python3 api.py
Ensure that the front-end and back-end repositories are in the same directory:
git checkout deploiementWindows
Specify the path of the UNETR model weights in the .env
file.
Example:
MODEL_PATH='./models/checkpoint_epoch1599_val_loss0255.cpkt'
Execute the start_services.bat
file:
# You can create a shortcut on your desktop or make it executable
Install your DICOM Web Server Orthanc here : https://www.orthanc-server.com/download-windows.php
Adapt the path of the environnemnt in the start_services.bat file line 33 (only the path of the activate.bat file and the name of the environnment)
Clean-up:
rm -rf ./Orthanc/orthanc-db/*
Alternatively, you can delete everything cleanly using the administration interface available at localhost:8042, or via OHIF on the front-end.
Login: mapdr Password: changestrongpassword
docker-compose -f Orthanc/docker-compose.yml down
And optionally, if you want to remove the pacs network:
docker network rm pacs # if you want to remove the network