Skip to content

feat(ingest): add NIfTI loader for fd5#123

Merged
gerchowl merged 1 commit intovig-os:devfrom
gerchowl:feature/111-ingest-nifti
Feb 28, 2026
Merged

feat(ingest): add NIfTI loader for fd5#123
gerchowl merged 1 commit intovig-os:devfrom
gerchowl:feature/111-ingest-nifti

Conversation

@gerchowl
Copy link
Copy Markdown
Contributor

@gerchowl gerchowl commented Feb 25, 2026

Summary

  • Adds fd5.ingest sub-package with Loader protocol, hash_source_files() helper, and NiftiLoader implementation
  • NiftiLoader reads NIfTI-1/NIfTI-2 files (.nii, .nii.gz) via nibabel, extracts volume data, affine (sform/qform), and dimension order, then produces sealed fd5 recon files via fd5.create()
  • Provenance records source file path and SHA-256 hash; optional study_metadata writes study group
  • Adds nifti optional dependency group (nibabel>=5.0) to pyproject.toml
  • 28 tests (6 base + 22 NIfTI), 95% coverage on new ingest code, 1002 total tests passing

Test plan

  • Loader protocol conformance — valid loader is instance, invalid is not
  • hash_source_files() — single file, multiple files, empty list, missing file
  • 3D NIfTI ingest — volume shape, affine, dimension order, reference frame
  • 4D NIfTI ingest — dynamic volume shape and TZYX dimension order
  • .nii.gz compressed files handled transparently
  • NIfTI-2 format support
  • Provenance — original_files compound dataset, ingest group
  • Study metadata passthrough
  • Custom and auto-generated timestamps
  • Error paths — nonexistent file, invalid file
  • NiftiLoader.ingest() method delegates correctly
  • ImportError with clear message when nibabel not installed
  • Full test suite passes (1002 tests, no regressions)

Closes #111

@gerchowl gerchowl enabled auto-merge February 28, 2026 14:08
@gerchowl gerchowl self-assigned this Feb 28, 2026
- Add fd5.ingest._base with Loader protocol, hash_source_files, discover_loaders
- Add NiftiLoader reading NIfTI-1/NIfTI-2 via nibabel into sealed fd5 recon files
- Provenance records source file path and sha256-prefixed hash
- Add _typos.toml to allow OME and tre identifiers
- Align provenance test assertions with sha256-prefixed hashes
- 28 tests covering protocol conformance, ingest, provenance, idempotency

Refs: vig-os#111
@gerchowl gerchowl force-pushed the feature/111-ingest-nifti branch from 8d6558b to 89ba415 Compare February 28, 2026 17:08
@gerchowl gerchowl merged commit 5173c21 into vig-os:dev Feb 28, 2026
4 of 5 checks passed
@gerchowl gerchowl deleted the feature/111-ingest-nifti branch February 28, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant