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!
This is how you could save a BOLD sequence from a .niii 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=vdb_out,
transform=nv.scale(img.affine, 0.01), # scaled for blender viewport
)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- 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!
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.
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.
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
