# selvakarna/dicomviewer architecture

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

- Interactive diagram: https://gitdiagram.com/selvakarna/dicomviewer
- Repository: https://github.com/selvakarna/dicomviewer

## Overview

This is a small script for loading DICOM image slices and displaying them as a 3D contour. Its workflow discovers matching files in a hard-coded directory, reads and collects each pixel array, converts the collected slices to a NumPy array, and passes that array to Mayavi for visualization. The source shows no user interface or saved output. Although OpenCV and Nilearn are imported, the excerpt shows no runtime use of them.

Main entry points: [`dcmtest.py`](https://github.com/selvakarna/dicomviewer/blob/main/dcmtest.py) (Decode and stack)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_input_files["DICOM files"]
node_discovery["File discovery<br/>[dcmtest.py]"]
node_decode_stack["Decode and stack<br/>[dcmtest.py]"]
node_pydicom["pydicom reader"]
node_numpy["NumPy array"]
node_contour["3D contour<br/>[dcmtest.py]"]
node_mayavi["Mayavi display"]
node_viewer(("Image viewer"))

node_input_files -->|"matches pattern"| node_discovery
node_discovery -->|"passes files"| node_decode_stack
node_decode_stack -->|"reads slices"| node_pydicom
node_decode_stack -->|"converts stack"| node_numpy
node_decode_stack -->|"provides array"| node_contour
node_contour -->|"creates contour"| node_mayavi
node_contour -->|"shows result"| node_viewer

click node_discovery "https://github.com/selvakarna/dicomviewer/blob/main/dcmtest.py"
click node_decode_stack "https://github.com/selvakarna/dicomviewer/blob/main/dcmtest.py"
click node_contour "https://github.com/selvakarna/dicomviewer/blob/main/dcmtest.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_input_files,node_pydicom,node_numpy,node_mayavi toneIndigo
class node_discovery,node_decode_stack,node_contour toneTeal
class node_viewer toneBlue
```

## Components

### Other components

- **DICOM files**
- [File discovery](https://github.com/selvakarna/dicomviewer/blob/main/dcmtest.py): `dcmtest.py`
- [Decode and stack](https://github.com/selvakarna/dicomviewer/blob/main/dcmtest.py): `dcmtest.py`
- **pydicom reader**
- **NumPy array**
- [3D contour](https://github.com/selvakarna/dicomviewer/blob/main/dcmtest.py): `dcmtest.py`
- **Mayavi display**
- **Image viewer**

## Connections

- DICOM files → File discovery: matches pattern (evidence: `dcmtest.py`)
- File discovery → Decode and stack: passes files (evidence: `dcmtest.py`)
- Decode and stack → pydicom reader: reads slices (evidence: `dcmtest.py`)
- Decode and stack → NumPy array: converts stack (evidence: `dcmtest.py`)
- Decode and stack → 3D contour: provides array (evidence: `dcmtest.py`)
- 3D contour → Mayavi display: creates contour (evidence: `dcmtest.py`)
- 3D contour → Image viewer: shows result (evidence: `dcmtest.py`)
