DICOM viewer for brain imaging. Loads a folder of DICOM slices, reconstructs a 3D volume, and shows it in a four-panel layout: one 3D ray-cast render plus axial, sagittal, and coronal slice views. The panels stay synced -- scroll one, the crosshairs update in the others.
PyQt6 for the UI, VTK for the 3D rendering, numpy and pydicom for the heavy lifting.
You can also place markers (click in the 3D view or on any slice), adjust window/level for contrast, and export screenshots.
core/
volume_loader.py -- reads DICOM folders into a numpy array + geometry metadata
slice_engine.py -- extracts 2D slices from the volume, applies windowing
coordinate_transform.py -- voxel <-> world <-> slice-pixel math
marker_manager.py -- thread-safe marker store with pub/sub events
event_bus.py -- generic publish/subscribe system
rendering/
renderer_3d.py -- VTK volume renderer + marker sphere actors
slice_renderer.py -- 2D slice display
ui/
main_window.py -- four-panel layout, wires everything together
panel_3d.py -- 3D view widget
panel_slice.py -- 2D slice view widget with scroll/click
toolbar.py -- open, markers, screenshot buttons
styles.py -- dark theme stylesheet
sync/
slice_sync.py -- keeps slice panels in sync when markers move
demo/
generate_synthetic_dicom.py -- creates fake brain DICOM data for testing
tests/
test_event_bus.py
test_coordinate_transform.py
test_marker_manager.py
test_slice_engine.py
test_brain_data.py
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtpython main.py --demoThis generates synthetic DICOM slices on first run, then loads them automatically.
python main.py /path/to/dicom/folderOr just run python main.py and use the toolbar to open a folder.
- PyQt6 >= 6.5
- VTK >= 9.2
- pydicom >= 2.4
- numpy >= 1.24
- scipy >= 1.10
pytest tests/DICOMVolumeLoader reads .dcm files from a folder, sorts by slice position, applies rescale slope/intercept, and hands back a uint16 numpy array with a VolumeGeometry (spacing, origin, orientation matrix).
SliceEngine does the 2D extraction -- give it a plane and an index, it returns a windowed grayscale image. It can also composite crosshairs on top.
The panels don't talk to each other directly. SliceSync subscribes to marker events on the EventBus and pushes the right slice + crosshair position to each panel callback. MarkerRegistry is the source of truth for markers -- it's thread-safe and fires events on create/select/move/delete. The 3D renderer listens and adds or moves sphere actors accordingly.
TBD