How vendenix/brainmetasegmentatorui-back works
Main Components
• API Layer – Represented by api.py which exposes Flask routes. This layer acts as the main entry point for segmentation requests from the front-end.
• Segmentation Engine – This includes segmentation.py and the UNETR module housed in the unetr/ directory. This module is responsible for launching the deep learning model against incoming data.
• DICOM Integration – The Orthanc directory contains configuration (docker-compose.yml, orthanc.json) and proxy settings (nginx.conf) to integrate with the Orthanc DICOM Web Server. This server retrieves/manages the medical images.
• Database (BDD) – Contains MesuresSQLite.py and mesures.db to track measurements or logs from segmentation requests.
• Utilities & Supporting Modules – The meta and rt_utils directories provide auxiliary functions for data management, image processing, and handling of RT structs.
• Testing & Experimentation – The Testing directory contains notebooks and scripts which, while not part of the production flow, help understand data flow and verify component operations.
• External Dependencies – Docker (via docker-compose) for Orthanc, and PyTorch (as per requirements) for deep learning inference.
Relationships and Interactions
• The Front-end (a separate repository) sends segmentation requests to the API.
• The API (api.py) receives requests and may preprocess inputs before invoking the segmentation logic.
• Segmentation logic (segmentation.py) calls the UNETR deep learning model for brain metastasis segmentation. It interfaces with the UNETR modules and utilities.
• The API forwards DICOM image retrieval requests to Orthanc. Orthanc, running in Docker, fetches imaging studies and may also forward data back for anonymization or post-processing.
• Processed segmentation results or logs are stored in the SQLite database (BDD/mesures.db) and possibly further processed using utilities in meta/ and rt_utils/.
• The overall flow is supported by configuration files, environment settings, and deployment scripts which manage the production and development mode (e.g., start_services.bat for Windows).
Architectural Patterns and Design Principles
• Separation of Concerns: Clear division between API request handling, model execution, DICOM integration, and database management.
• Modular Design: Functional modules are segregated into their respective directories (e.g., unetr for deep learning, Orthanc for DICOM).
• Containerization: Orthanc and its proxy via Docker are used to encapsulate and deploy the medical image management server.
• Reusability: Utility libraries (in meta/ and rt_utils/) provide reusable functions and helpers that abstract common tasks.
Relevant Technologies and Frameworks
• Flask for the API layer (api.py).
• PyTorch/PyTorch Lightning for deep learning (as indicated by the unetr folder and instructions for installing PyTorch).
• Docker for containerizing Orthanc and ensuring consistency in the DICOM server deployment.
• SQLite for lightweight database management.
• Nginx acting as a proxy for Orthanc (see Orthanc/nginx.conf).
Final Steps
• Every component is labeled with its purpose (for instance, “Flask API (api.py)”, “Deep Learning Model (UNETR - unetr/)”, “DICOM Server (Orthanc)”).