How pcabrales/prototwin-pet works
Project Type and Purpose
• This is a scientific, patient-specific deep learning and GPU-accelerated workflow. Its main goal is to simulate dose deviations in proton therapy and verify them using PET simulations, followed by deep learning–based prediction of dose maps and patient setup errors.
• The README clearly indicates the integration of Monte Carlo (FRED), PET simulation (MCGPU-PET), treatment planning (MatRad), and the use of a 3D deep learning model (nnFormer with a Deviation Predicting Branch).
File Structure Analysis – Key Components
• Top-level directories such as “generate-dataset”, “config-main”, “data”, “models”, “images”, and “unit-tests” indicate the separation of functionality.
• The “generate-dataset” folder contains scripts and configurations for dataset generation. It leverages submodules like “pet-simulation-reconstruction” (which holds necessary input files, material definitions, and interfaces to MCGPU-PET).
• The “models” folder, along with associated training and testing scripts (main.py, train_model.py, test_model.py), shows the deep learning part of the pipeline.
• Additional configuration files (in “config-main” and “generate-dataset/config-generate-dataset”) are used to set patient-specific and process-specific parameters.
• The presence of utilities (e.g., utils.py, utils_parallelproj.py) supports various parts of the workflow.
Insights from the README
• The README details the patient data preparation, the simulation steps (FRED for dose simulation, PET simulation and reconstruction using MCGPU-PET) and then how the dataset is used for deep learning training.
• It also emphasizes the integration with external tools (MatRad, MCGPU-PET executable, FRED) and provides instructions for environment setup, indicating that the proper hardware (GPU, CUDA) and dependencies are vital.
• There are clear step-by-step instructions: selecting or generating a patient plan, dataset generation, and model training/testing.
Main Components & Their Relationships
a. Data Ingestion & Preprocessing:
• Patient’s CT/DICOM data and treatment plan data (either provided in “data” or generated via MatRad).
• Config files (in “config-main” and “generate-dataset/config-generate-dataset”) defining simulation and deep-learning parameters.
b. Simulation and Dataset Generation Pipeline:
• FRED Monte Carlo simulation: Provides dose maps.
• MCGPU-PET simulation & reconstruction: Converts simulation outputs to PET images.
• Additional utilities and parallel projection tools (seen in the generate-dataset folder) which organize and generate the final PET–dose pairs dataset.
• Input and timing logs for each simulation step (e.g., “timings” folder) to monitor performance.
c. Deep Learning Training/Inference Pipeline:
• Main processing scripts: main.py, train_model.py, and test_model.py.
• The “models” directory hosts the deep learning model definition (nnFormer and its DPB extension), training losses, test results, and trained model outputs.
• Utility modules (e.g., utils.py) help with dataset management, plotting, and post-processing.
d. External Dependencies & Environment:
• CUDA toolkit and GPU dependencies.
• Third-party simulation software: FRED, MCGPU-PET, and even parts of MatRad for treatment planning.
• Dependencies are managed by the environment file (environment.yml).
Additional Architectural Patterns
• Pipeline nature of the workflow (pre-processing → simulation → dataset generation → deep learning).
• Principles of modularity (separate folders for config, simulation, models, tests) and reusability (utility modules, external tool integrations).
• Parallelism or timing components if relevant (for instance, the “timings” folder indicates where performance metrics are collected).