Python library for Neurovolume. Build VDBs for scientific visualizations
Project description
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. 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!
🏗️ Building
If you are building locally, we use uv to build and test the project:
uv run python -m ziglang build && uv run pytest tests -s
This is how you could save a BOLD sequence from a .nii file
import numpy as np
import neurovolume as nv
import nibabel as nib
img = nib.load(anat)
data = np.array(img.get_fdata(), order="C", dtype=np.float32)
nv.ndarray_to_vdb(
nv.prep_ndarray(data, (0, 2, 1)),
"anat_offset",
output_dir=save_dir_path,
transform=nv.scale(img.affine, 0.01), # scaled for blender viewport
)
To use sparsity, add a prune value to your ndarray_to_vdb function call. This example gives good results for our T1 Anatomy scan:
nv.ndarray_to_vdb(
nv.prep_ndarray(data, (0, 2, 1)),
"anat_offset_0p05_prune",
output_dir=save_dir_path,
transform=_test_pattern_pos(img.affine),
prune=np.float32(0.05),
)
Higher sparsity amounts will result in better performance and lower disk space usage. However, after a certain point, they begin to degrade the VDB quality.
📀 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, sparse volumetric data structure. 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.
- pypi package presently only supports arm64. Coverage for linux and windows is in the works.
- Documentation has not been written yet. Specifically:
- Documentation for sparsity: we should establish how/when sparsity might result in a lossy compression.
- Multiple grids has yet to be implemented
🧠 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
Direct Download Link for T1 Anat test file
Direct Download Link for BOLD test file
The MNI Template can be found Here
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neurovolume-0.1.0a17.tar.gz.
File metadata
- Download URL: neurovolume-0.1.0a17.tar.gz
- Upload date:
- Size: 494.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d95ed3239f509f10bebe8bb832109bd6872a353f939fa80f677f2950cf35b9e3
|
|
| MD5 |
723e496900eb7bcc16d6b84101982b61
|
|
| BLAKE2b-256 |
bc62f6db3bee9a49b46d50c4f25dd1ae949cd537830ba7ee3a2777b9f63c0fa0
|
File details
Details for the file neurovolume-0.1.0a17-py3-none-any.whl.
File metadata
- Download URL: neurovolume-0.1.0a17-py3-none-any.whl
- Upload date:
- Size: 494.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b302943beeee0be66bfe693609fa2dcb074548d984cb63e63128379bf4bbce17
|
|
| MD5 |
22dcbd2544100471190faa409f8377f9
|
|
| BLAKE2b-256 |
3a61f103e67b45cc7c4bf722b57a007ca33c9ddf1a59e7530fb2bd5e00318842
|