Skip to main content

Library-first toolkit for inspecting, previewing, and QA reporting imaging datasets.

Project description

VoxelKit

VoxelKit banner

Python FastAPI Formats License: MIT Status

VoxelKit helps you inspect, preview, and QA-check multidimensional imaging files from one consistent CLI and Python API.

Quick CLI Demo

# Inspect structure/metadata
python -m voxelkit.cli inspect tests/fixtures/sample_nested.h5

# Generate a PNG preview slice
python -m voxelkit.cli preview tests/fixtures/sample_3d.nii.gz --plane axial --slice 4 --output nifti_preview.png

# Run per-file QA stats + warnings
python -m voxelkit.cli report tests/fixtures/sample_nested.h5 --dataset data/subject01/run1/bold

# Run directory-level QA summary
python -m voxelkit.cli report-batch tests/fixtures --output batch_report.json

Why VoxelKit?

Low-level libraries like nibabel, h5py, and tifffile are powerful and flexible. VoxelKit does not replace them.

Instead, VoxelKit provides a unified workflow on top for day-to-day dataset triage:

  • inspect file structure and metadata quickly
  • preview representative slices as PNGs
  • generate QA stats and warnings for suspicious arrays
  • summarize QA signals across whole directories with report-batch

This keeps common inspection and QA tasks fast, scriptable, and consistent across formats.

Supported Formats

  • NIfTI (.nii, .nii.gz)
  • HDF5 (.h5, .hdf5)
  • NumPy arrays (.npy, .npz)
  • TIFF (.tif, .tiff) in format routing (full inspect/preview/report coverage is in progress)

Installation

Editable install (recommended while iterating on the project):

cd VoxelKit
pip install -e .

Optional dependencies used by demos/tests:

pip install -r requirements.txt

When a PyPI release is available, installation will be:

pip install voxelkit

Python Usage

from voxelkit import inspect_file, preview_file, report_file, report_batch

# Inspect
info = inspect_file("tests/fixtures/sample_nested.h5")

# Preview (returns PNG bytes)
png = preview_file(
    "tests/fixtures/sample_3d.nii.gz",
    plane="axial",
    slice_index=4,
)
with open("nifti_preview.png", "wb") as f:
    f.write(png)

# Single-file QA report
single_report = report_file(
    "tests/fixtures/sample_nested.h5",
    dataset_path="data/subject01/run1/bold",
)

# Batch QA report
batch = report_batch("tests/fixtures", recursive=True)

Visual Demos

Add screenshots/snippets here so visitors can see value in under 30 seconds:

  • Terminal screenshot: inspect and report output side by side
  • Preview image: one generated PNG slice (nifti_preview.png or h5_preview.png)
  • Batch report snippet: short JSON excerpt showing files_with_warnings and warning_counts

Run The API

py -m uvicorn app.main:app --reload

Open API docs:

  • Swagger UI: http://127.0.0.1:8000/docs

Optional Local GUI

VoxelKit includes an optional Streamlit prototype for local/offline inspect, report, and preview workflows. The GUI runs entirely on your machine and does not upload files to external services.

Install optional GUI extras:

pip install -e .[gui]

Launch the GUI:

voxelkit gui

If Streamlit is not installed, the CLI prints:

Install GUI extras with: pip install voxelkit[gui]

API Endpoints

  • POST /h5/inspect
  • POST /h5/slice
  • POST /nifti/metadata
  • POST /nifti/preview
  • GET /health

API Usage Examples

NIfTI Metadata

curl -X POST "http://127.0.0.1:8000/nifti/metadata" \
	-F "file=@tests/fixtures/sample_3d.nii.gz"

NIfTI Preview

curl -X POST "http://127.0.0.1:8000/nifti/preview?plane=axial&slice_index=4" \
	-F "file=@tests/fixtures/sample_3d.nii.gz" \
	--output nifti_preview.png

HDF5 Inspect

curl -X POST "http://127.0.0.1:8000/h5/inspect" \
	-F "file=@tests/fixtures/sample_nested.h5"

HDF5 Slice

curl -X POST "http://127.0.0.1:8000/h5/slice?dataset_path=data/subject01/run1/bold&axis=2&slice_index=3" \
	-F "file=@tests/fixtures/sample_nested.h5" \
	--output h5_preview.png

Project Layout

voxelkit/
  core/      # shared cross-format utilities (validation, types, errors, normalization)
  h5/        # HDF5 inspect/preview logic
  nifti/     # NIfTI metadata/preview logic

app/
  routers/   # thin FastAPI wrappers over voxelkit library functions

Test Fixtures

Generate tiny deterministic fixtures for local testing/demo:

py tests/create_fixtures.py

This creates:

  • tests/fixtures/sample_3d.nii.gz: small 3D NIfTI volume
  • tests/fixtures/sample_2d.h5: 2D HDF5 dataset at image
  • tests/fixtures/sample_3d.h5: 3D HDF5 dataset at volume
  • tests/fixtures/sample_nested.h5: nested HDF5 dataset at data/subject01/run1/bold

Running Tests

pytest -q

Extending CLI Formats

The CLI in voxelkit/cli.py is registry-based and intentionally thin.

To add a new image format later (for example, GeoTIFF):

  1. Implement library functions in a format module (inspect + preview bytes).
  2. Implement a format report function in the format module.
  3. Add small CLI adapters in voxelkit/cli.py that map CLI args into preview/report functions.
  4. Register the format in _register_builtin_formats() with register_format(FormatRoute(...)).
  5. Add any new format-specific CLI flags in build_parser() only if needed.

Minimal registration pattern:

register_format(
	FormatRoute(
		name="geotiff",
		extensions=(".tif", ".tiff"),
		inspect_fn=inspect_geotiff,
		preview_fn=_preview_geotiff,
		report_fn=_report_geotiff,
	)
)

This keeps CLI routing simple while all format behavior remains in the library layer.

Roadmap

  • multi-file request support
  • CI for tests
  • docs expansion for format-specific library usage
  • pip packaging

Contributing

Please see CONTRIBUTING.md for contribution workflow, coding standards, and pull request guidance.

Disclaimer

VoxelKit is a developer/research utility tool. It is not a clinical decision system and must not be used for diagnosis or treatment decisions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

voxelkit-0.1.2.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

voxelkit-0.1.2-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file voxelkit-0.1.2.tar.gz.

File metadata

  • Download URL: voxelkit-0.1.2.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for voxelkit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 17cf61e68011d5f2e5a37070b783c13777a72d22e32a9ae68660afe8ecbaf1c5
MD5 d9b40941f1dd57bea97d8a29d49af098
BLAKE2b-256 adccf7ddf57d06f09d95204c2ae01196ae5cccc59f19a07ae8cdeb96ec108b77

See more details on using hashes here.

File details

Details for the file voxelkit-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: voxelkit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for voxelkit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a9c80fb202737beb38d78b89443720d2481fb10acc553fc3e0af7ae08bbc02c
MD5 eb16558583c4fb7844df5f2a0b0bf0ab
BLAKE2b-256 ad96c6c2002dcf7bef51d648752236280f5cd27671a85b4853d9b603f2993e3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page