Skip to main content

Python library for Neurovolume. Build VDBs for scientific visualizations

Project description

Render of a non-skull stripped MNI Template

Neurovolume is a Python library for manipulating and visualizing volumetric data. It includes a custom-built, scientific data-focused, VDB writer. The VDB writer is written in Zig with no external dependencies.

While this project focuses on neuroscience, it includes ndarray to VDB to support virtually any volumetric data pipeline.

This project is under active development and might not have everything you need (particularly if you are working with very large datasets). Please reference the "Missing Features" section.

This project is available as a pre-release alpha on pypi. Presently it is only available for arm64. More operating systems coming soon!

🏗️ Usage

The Python library is a bit verbose. We hope to pair it down to something more manageable. In the meantime, this is how you could save a BOLD sequence from a .niii file

img = nib.load(bold)
data = np.array(img.get_fdata(), order="C", dtype=np.float32)
prepped_data = nv.prep_ndarray(data, (3, 0, 2, 1))
dims = prepped_data.shape

seq_out = os.path.join(vdb_out, "bold_test_fade")  # LLM:
os.makedirs(seq_out, exist_ok=True)
vol = nv.init_four_dim(
    base_name="bold_test_fade",
    save_folder=seq_out,
    overwrite=True,
    data=prepped_data,
    transform=np.eye(4),  # 4x4 affine float64
    source_fps=1.0,
    playback_fps=24.0,
    speed=1.0,
    dims=dims,  # (x, z, y, t)
)
nv.save_four_dim(vol, 1) # 1 indicates a cross-dissolve frame interpolation
nv.deinit_four_dim(vol)

If you are building locally, we use uv to build and test the project:

uv run python -m ziglang build && uv run pytest tests

📀 Projects

  • BoldViz: a Blender plugin for fMRI and MRI visualizations. It was used to create the renders in this README. A great place to start if you don't want to deal with writing any Python.
  • Neurovolume Examples and Physarum include some good starting points for how one might use this library with numpy.
  • The nibabel example shows how to use an external NIfTI parser, which could be of use for not-yet-supported filetypes. We're moving away from native file parsing as everyone seems to use numpy, but please reach out if this is something that you'd want!

☁️ Why VDB?

VDBs are a highly performant, art-directable, volumetric data structure that supports animations. Our volume-based approach aims to provide easy access to the original density data throughout the visualization and analysis pipeline. Unlike the openVDB repo, our smaller version is much more readable and does not need to be run in a docker container.

🛠️ Missing Features

While a comprehensive road-map will be published soon, there are a few important considerations to take into account now.

  • Presently the VDB writer isn't sparse nor does it support multiple grids. Tiles and multiple grids are in development.
  • Documentation has not been written yet.
  • pypi package presently only supports arm64. Coverage for linux and windows is in the works.

🧠 Dataset Citation

This software was tested using the following datasets.

Isaac David and Victor Olalde-Mathieu and Ana Y. Martínez and Lluviana Rodríguez-Vidal and Fernando A. Barrios (2021). Emotion Category and Face Perception Task Optimized for Multivariate Pattern Analysis. OpenNeuro. [Dataset] doi: 10.18112/openneuro.ds003548.v1.0.1

OpenNeuro Study Link

Direct Download Link for T1 Anat test file

Direct Download Link for BOLD test file

The MNI Template can be found Here

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

neurovolume-0.1.0a12.tar.gz (464.3 kB view details)

Uploaded Source

Built Distribution

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

neurovolume-0.1.0a12-py3-none-any.whl (463.6 kB view details)

Uploaded Python 3

File details

Details for the file neurovolume-0.1.0a12.tar.gz.

File metadata

  • Download URL: neurovolume-0.1.0a12.tar.gz
  • Upload date:
  • Size: 464.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for neurovolume-0.1.0a12.tar.gz
Algorithm Hash digest
SHA256 de6a9bd1a2d70495f9d59b12bd9c4f6a2de34386d6f5552a640a2a86f542a409
MD5 3cb83b3d5891b6fd4eb287b05e0e592e
BLAKE2b-256 94e676f01f07623b6ec0f304a81d1dd2853a9b4aef4d2436e12f8325506e0a22

See more details on using hashes here.

File details

Details for the file neurovolume-0.1.0a12-py3-none-any.whl.

File metadata

  • Download URL: neurovolume-0.1.0a12-py3-none-any.whl
  • Upload date:
  • Size: 463.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for neurovolume-0.1.0a12-py3-none-any.whl
Algorithm Hash digest
SHA256 a8b85e4c9c54b95ca59ad564edbcda3b313998fcf4add6485c0d9837ccdbb7c6
MD5 f21dde09bf8066ad860a5c8841992eb0
BLAKE2b-256 df709b62f74e964c10bb14208234255ca4d4d74ae807fdca2b0f636c0e4c3d4e

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