Skip to main content

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

Project description

VoxelKit

VoxelKit banner

Python PyPI version DOI 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.5.tar.gz (37.2 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.5-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: voxelkit-0.1.5.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for voxelkit-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8e6db892960b2e55712bccc632f3ac23110d2d88cf124a7541d5acd6179346bc
MD5 b8c48b9f0ba55fd6c8ec81159f6d22c7
BLAKE2b-256 5889cfe3f6c5b6d2c151b4ea9a5777e98ae1376db3db110a4666ef01c7470d2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for voxelkit-0.1.5.tar.gz:

Publisher: publish.yml on ArsalaanAhmad/VoxelKit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: voxelkit-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 41.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for voxelkit-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 05c3e55a6cdcda39f450c32964980714b9acde09f1559651db1d93d1bb69e86c
MD5 0ed666a2bd578161670fa2c664a45961
BLAKE2b-256 c69b1b01921b44effa7f7b3ac19b18b333da820ffa70e9c9bc15a70f7d82abdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for voxelkit-0.1.5-py3-none-any.whl:

Publisher: publish.yml on ArsalaanAhmad/VoxelKit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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