Infrastructure: I/O & BIDS

File loading and BIDS mapping live under infrastructure/. Keep these modules free of Qt widgets so CLI tools and tests can reuse them.

I/O (infrastructure/io/)

Module

Role

nifti.py

NIfTI read/write via nibabel

volume_proxy.py

Lazy / full-res cache path for huge .nii.gz

dicom.py

DICOM helpers (optional extras)

mesh.py

Mesh I/O

volume_proxy policy

2D display stays native resolution; gzip may be decompressed once to an uncompressed cache for fast mmap slices

Critical path: open a large gzip volume

UI / API
   │  open path.nii.gz
   ▼
nifti / volume_proxy
   │  if huge gzip → decompress to cache .nii
   │  mmap full-res
   ▼
viewer layers (2D native)
   │
   └──► rendering may use strided / capped voxels for 3D only

Performance background for users: Performance.

BIDS (infrastructure/bids/)

Module

Role

mapper.py

BIDS files → internal data models

layout.py / loader.py

Layout discovery and loading

session.py / subject_switch.py

Session and subject switching

derivatives.py / rawimages.py

Derivative vs raw conventions

validate.py / qc_batch.py

Validation and batch QC hooks

import_convert.py

Import / conversion helpers

The presentation BIDS panel calls into these modules; do not duplicate path logic in widgets.

See also