# msantacesaria/ktc2023_pnpe2e architecture

> Architecture diagram of the GitHub repository msantacesaria/ktc2023_pnpe2e, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/msantacesaria/ktc2023_pnpe2e
- Repository: https://github.com/msantacesaria/ktc2023_pnpe2e

## Overview

This repository implements an EIT challenge reconstruction application: it uses measured voltage data to produce pixel-grid conductivity segmentations, combining a learned end-to-end model with a plug-and-play Gauss–Newton reconstruction and mask-based postprocessing. The README also documents graph-U-Net denoising and synthetic inclusion generation. Edges reflect the shown main/helper calls and README-described workflow; unsampled details are left unconnected where their wiring cannot be verified.

Main entry points: [`main.py`](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py) (Reconstruction entry point), [`helper_fncs.py`](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py) (End-to-end model), [`KTCMeshing.py`](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCMeshing.py) (Finite-element mesh), [`KTCFwd.py`](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCFwd.py) (EIT forward solver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Reconstruction workflow"]
  node_main["Reconstruction entry point<br/>[main.py]"]
  node_result["Segmented reconstruction"]
  node_pnp["PnP Gauss–Newton<br/>[main.py]"]
end

subgraph group_learned["Learned reconstruction"]
  node_e2e["End-to-end model<br/>[helper_fncs.py]"]
  node_inverse["Learned linear inverse<br/>[helper_fncs.py]"]
  node_interpolator["Mesh interpolator<br/>[helper_fncs.py]"]
  node_backbone["Image U-Net<br/>[main.py]"]
  node_graphdenoiser["Graph U-Net denoiser<br/>[main.py]"]
end

subgraph group_eit["EIT numerical core"]
  node_fem["EIT forward solver<br/>[KTCFwd.py]"]
  node_meshing["Finite-element mesh<br/>[KTCMeshing.py]"]
  node_meshdata["Premade mesh data<br/>[Mesh_sparse.mat]"]
  node_circmesh["Circular mesh routines<br/>[KTCcircmesh.py]"]
  node_prior["Smoothness prior"]
end

subgraph group_support["Segmentation and data"]
  node_masks["Difficulty masks<br/>[helper_fncs.py]"]
  node_segmentation["Threshold segmentation<br/>[KTCScoring.py]"]
  node_interpolation["Mesh interpolation helper<br/>[KTCAux.py]"]
  node_inclusiongen["Synthetic inclusion generator<br/>[KTCAux_luca.py]"]
  node_plotting["Reconstruction plotting<br/>[KTCPlotting.py]"]
end

node_organizer(("Challenge user"))
node_measurements["Voltage measurements"]

node_organizer -->|"runs"| node_main
node_organizer -->|"provides"| node_measurements
node_main -->|"loads"| node_measurements
node_main -->|"gets masks"| node_masks
node_main -->|"runs"| node_e2e
node_e2e -->|"applies"| node_inverse
node_e2e -->|"interpolates"| node_interpolator
node_e2e -->|"applies"| node_backbone
node_main -->|"runs"| node_pnp
node_pnp -->|"denoises with"| node_graphdenoiser
node_pnp -->|"uses forward model"| node_fem
node_main -->|"configures solver"| node_fem
node_main -->|"builds prior"| node_prior
node_main -->|"loads mesh"| node_meshing
node_meshing -->|"imports"| node_circmesh
node_main -->|"loads"| node_meshdata
node_main -->|"segments reconstruction"| node_segmentation
node_main -->|"writes"| node_result
node_main -->|"imports"| node_plotting
node_main -->|"imports"| node_interpolation
node_inclusiongen -.->|"generates shapes on"| node_meshing

click node_main "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py"
click node_e2e "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py"
click node_inverse "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py"
click node_interpolator "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py"
click node_backbone "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py"
click node_pnp "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py"
click node_graphdenoiser "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py"
click node_masks "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py"
click node_segmentation "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCScoring.py"
click node_fem "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCFwd.py"
click node_meshing "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCMeshing.py"
click node_meshdata "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/Mesh_sparse.mat"
click node_circmesh "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCcircmesh.py"
click node_prior "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCRegularization.py"
click node_interpolation "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCAux.py"
click node_inclusiongen "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCAux_luca.py"
click node_plotting "https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCPlotting.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_result,node_pnp,node_organizer toneBlue
class node_e2e,node_inverse,node_interpolator,node_backbone,node_graphdenoiser toneAmber
class node_fem,node_meshing,node_meshdata,node_circmesh,node_prior toneMint
class node_masks,node_segmentation,node_interpolation,node_inclusiongen,node_plotting toneRose
class node_measurements toneIndigo
```

## Components

### Reconstruction workflow

- [Reconstruction entry point](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py): `main.py`
- **Segmented reconstruction**
- [PnP Gauss–Newton](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py): `main.py`

### Learned reconstruction

- [End-to-end model](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py): `helper_fncs.py`
- [Learned linear inverse](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py): `helper_fncs.py`
- [Mesh interpolator](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py): `helper_fncs.py`
- [Image U-Net](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py): `main.py`
- [Graph U-Net denoiser](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/main.py): `main.py`

### EIT numerical core

- [EIT forward solver](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCFwd.py): `KTCFwd.py`
- [Finite-element mesh](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCMeshing.py): `KTCMeshing.py`
- [Premade mesh data](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/Mesh_sparse.mat): `Mesh_sparse.mat`
- [Circular mesh routines](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCcircmesh.py): `KTCcircmesh.py`
- [Smoothness prior](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCRegularization.py): `KTCRegularization.py`

### Segmentation and data

- [Difficulty masks](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/helper_fncs.py): `helper_fncs.py`
- [Threshold segmentation](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCScoring.py): `KTCScoring.py`
- [Mesh interpolation helper](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCAux.py): `KTCAux.py`
- [Synthetic inclusion generator](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCAux_luca.py): `KTCAux_luca.py`
- [Reconstruction plotting](https://github.com/msantacesaria/ktc2023_pnpe2e/blob/main/KTCPlotting.py): `KTCPlotting.py`

### Other components

- **Challenge user**
- **Voltage measurements**

## Connections

- Challenge user → Reconstruction entry point: runs (evidence: `README.md`)
- Challenge user → Voltage measurements: provides (evidence: `README.md`)
- Reconstruction entry point → Voltage measurements: loads (evidence: `main.py`)
- Reconstruction entry point → Difficulty masks: gets masks (evidence: `main.py`)
- Reconstruction entry point → End-to-end model: runs (evidence: `main.py`)
- End-to-end model → Learned linear inverse: applies (evidence: `helper_fncs.py`)
- End-to-end model → Mesh interpolator: interpolates (evidence: `helper_fncs.py`)
- End-to-end model → Image U-Net: applies (evidence: `helper_fncs.py`)
- Reconstruction entry point → PnP Gauss–Newton: runs (evidence: `main.py`)
- PnP Gauss–Newton → Graph U-Net denoiser: denoises with (evidence: `README.md`)
- PnP Gauss–Newton → EIT forward solver: uses forward model (evidence: `README.md`)
- Reconstruction entry point → EIT forward solver: configures solver (evidence: `main.py`)
- Reconstruction entry point → Smoothness prior: builds prior (evidence: `main.py`)
- Reconstruction entry point → Finite-element mesh: loads mesh (evidence: `main.py`)
- Finite-element mesh → Circular mesh routines: imports (evidence: `KTCMeshing.py`)
- Reconstruction entry point → Premade mesh data: loads (evidence: `main.py`)
- Reconstruction entry point → Threshold segmentation: segments reconstruction (evidence: `README.md`)
- Reconstruction entry point → Segmented reconstruction: writes (evidence: `README.md`)
- Reconstruction entry point → Reconstruction plotting: imports (evidence: `main.py`)
- Reconstruction entry point → Mesh interpolation helper: imports (evidence: `main.py`)
- Synthetic inclusion generator → Finite-element mesh: generates shapes on
