# joeoliverevans/comptoncamera architecture

> Architecture diagram of the GitHub repository joeoliverevans/comptoncamera, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joeoliverevans/comptoncamera
- Repository: https://github.com/joeoliverevans/comptoncamera

## Overview

##### Project type and purpose
- This is a scientific-computing/research project (not a web or enterprise app). Its two pillars are:
a) Monte Carlo modelling of Compton scattering (“Monte Carlo” folder)
b) Image reconstruction from simulated/experimental data (“Image Reconstruction” folder)
- The README confirms: “Workspace for Compton Camera project. Will likely contain solutions for Monte Carlo modelling and Image Reconstruction.”

##### File structure
- Top-level directories:
- Image Reconstruction – data directories (Data_Raw → Data → Final Data), scripts for voxelization, geometry, reconstruction, and saved outputs.
- Monte Carlo – simulation scripts organized into “Old Sims” and “Python Work,” plus a main.py for orchestrating new runs.
- Under Image Reconstruction:
- Data_Raw – initial CSV/parquet dumps from simulations/experiments
- Data – cleaned/combined datasets in CSV and Parquet
- Final Data – curated, final Parquet datasets ready for voxelization
- SavedVoxelCubes – exported voxel-grid text files after PolarsToVoxels step
- Scripts – ErosionAndDialation.py, LoadingVoxelCube.py, PolarsToVoxels.py, RotationMatrix.py, Trying3DGeometry.py, ThickCones.py, VoxelstoRotation.py, plus helper modules (conesbyapex2, positiondistributions, eventpairspositiondistributions, etc.)
- main.py – orchestrator for the reconstruction pipeline
- Under Monte Carlo:
- Old Sims – prior/archived simulation variants
- Python Work – current design of scattering, data extraction, histogramming, variance reduction
- main.py – top-level entrypoint for new Monte Carlo runs
- There are also notebooks (totalerror.ipynb) and a TODO list.

##### README for additional insights
- The README is minimal but confirms the dual focus on Monte Carlo modelling and reconstruction.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Orchestrator
    RecMain["Reconstruction Orchestrator\nmain.py"]:::process

    %% Monte Carlo Engine
    subgraph "Monte Carlo Simulation Engine"
        MCMain["main.py"]:::sim
        MCOld["Old Sims/"]:::sim
        MCPython["Python Work/"]:::sim
    end

    %% Data Stores
    RawData[(Data_Raw)]:::storage
    IntermediateData[(Data)]:::storage
    FinalData[(Final Data)]:::storage
    VoxelStore[(SavedVoxelCubes)]:::storage

    %% Data Processing Pipeline
    subgraph "Data Processing Pipeline"
        Erode["ErosionAndDialation.py"]:::process
        LoadVoxel["LoadingVoxelCube.py"]:::process
        SaveArrays["saving arrays.py"]:::process
    end

    %% Voxelization Module
    Polars["PolarsToVoxels.py"]:::process

    %% Geometry & Reconstruction Modules
    subgraph "Geometry & Reconstruction"
        RotMat["RotationMatrix.py"]:::process
        Geo3D["Trying3DGeometry.py"]:::process
        ThickCones["ThickCones.py"]:::process
        VoxRot["VoxelstoRotation.py"]:::process
    end

    %% Analysis & Visualization
    subgraph "Analysis & Visualization"
        Plots["Plots/"]:::analysis
        PosDist["positiondistributions.py"]:::analysis
        PairDist["eventpairspositiondistributions.py"]:::analysis
        TotalErr["totalerror.ipynb"]:::analysis
    end

    %% Data Flow
    RecMain --> MCMain
    MCMain --> RawData
    RawData --> Erode
    Erode --> LoadVoxel
    LoadVoxel --> SaveArrays
    SaveArrays --> IntermediateData
    IntermediateData --> FinalData
    FinalData --> Polars
    Polars --> VoxelStore
    VoxelStore --> RotMat
    RotMat --> Geo3D
    Geo3D --> ThickCones
    ThickCones --> VoxRot
    VoxRot --> Plots
    VoxRot --> PosDist
    VoxRot --> PairDist
    VoxRot --> TotalErr

    %% Orchestrator control arrows
    RecMain --> Erode
    RecMain --> Polars
    RecMain --> RotMat
    RecMain --> Plots

    %% Click Events
    click MCMain "https://github.com/joeoliverevans/comptoncamera/blob/main/Monte Carlo/main.py"
    click MCOld "https://github.com/joeoliverevans/comptoncamera/tree/main/Monte Carlo/Old Sims/"
    click MCPython "https://github.com/joeoliverevans/comptoncamera/tree/main/Monte Carlo/Python Work/"
    click RawData "https://github.com/joeoliverevans/comptoncamera/tree/main/Image Reconstruction/Data_Raw/"
    click IntermediateData "https://github.com/joeoliverevans/comptoncamera/tree/main/Image Reconstruction/Data/"
    click FinalData "https://github.com/joeoliverevans/comptoncamera/tree/main/Image Reconstruction/Final Data/"
    click VoxelStore "https://github.com/joeoliverevans/comptoncamera/tree/main/Image Reconstruction/SavedVoxelCubes/"
    click Erode "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/ErosionAndDialation.py"
    click LoadVoxel "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/LoadingVoxelCube.py"
    click SaveArrays "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/saving arrays.py"
    click Polars "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/PolarsToVoxels.py"
    click RotMat "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/RotationMatrix.py"
    click Geo3D "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/Trying3DGeometry.py"
    click ThickCones "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/ThickCones.py"
    click VoxRot "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/VoxelstoRotation.py"
    click RecMain "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/main.py"
    click Plots "https://github.com/joeoliverevans/comptoncamera/tree/main/Image Reconstruction/Plots/"
    click PosDist "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/positiondistributions.py"
    click PairDist "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/eventpairspositiondistributions.py"
    click TotalErr "https://github.com/joeoliverevans/comptoncamera/blob/main/Image Reconstruction/totalerror.ipynb"

    %% Styles
    classDef storage fill:#BBDEFB,stroke:#1E88E5;
    classDef process fill:#C8E6C9,stroke:#388E3C;
    classDef sim fill:#FFE0B2,stroke:#F57C00;
    classDef analysis fill:#E1BEE7,stroke:#8E24AA;
```
