A simple array based volume renderer
Project description
vanilla-roll
vanilla-roll is volume renderer using array-api as backend.
Why vanilla-roll ?
VTK is one of the most excellent volume renderers in the world. It has good performance and many features. But I think that the installation process is not easy. So vanilla-roll is motivated to solve this problem.
Features
- IO
- MRA
- NIFTI
- DICOM
- NRRD
- Rendering Algorithm
- Sampling
- Shear-Warp
- Raycast
- Rendering Mode
- MIP
- MinP
- Average
- VolumeRendering
- Ambient
- Shading
- Backend
- numpy
- pytorch
- cupy
- jax
- numbda
Installation
$ pip install vanilla-roll
vanilla-roll supports following extras
- torch
- dicom
- mha
- nifti
Example
Code
import urllib.request
from pathlib import Path
from tempfile import TemporaryDirectory
import numpy as np
import skimage.io
import vanilla_roll as vr
# from A high-resolution 7-Tesla fMRI dataset from complex natural stimulation with an audio movie
# https://www.openfmri.org/dataset/ds000113/
MRA_FILE_URL = "https://s3.amazonaws.com/openneuro/ds000113/ds000113_unrevisioned/uncompressed/sub003/angio/angio001.nii.gz" # noqa: E501
def fetch_mra_volume() -> vr.volume.Volume:
with TemporaryDirectory() as tmpdir:
mra_file = Path(tmpdir) / "mra.nii.gz"
urllib.request.urlretrieve(MRA_FILE_URL, mra_file)
return vr.io.read_nifti(mra_file)
def save_result(ret: vr.rendering.types.RenderingResult, path: str):
img_array = vr.rendering.convert_image_to_array(ret.image)
skimage.io.imsave(path, np.from_dlpack(img_array)) # type: ignore
def main():
volume = fetch_mra_volume()
ret = vr.render(volume, mode=vr.rendering.mode.MIP())
save_result(ret, f"result.png")
if __name__ == "__main__":
main()
Output
If you need more exmplaes, please check the examples.
For development
Install Poery plugins
$ poetry self add 'poethepoet[poetry_plugin]'
Install all extra packages
$ poetry poe install-all-extras
Run tests
$ poetry poe test
Run linter and formatter
$ poetry poe check
See Also
License
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
vanilla-roll-0.2.1.tar.gz
(30.9 kB
view hashes)
Built Distribution
Close
Hashes for vanilla_roll-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c00e1e5473637f9e92555c33db4ddc6e7f71ae29d9916d38a4ccc73ea873f5d5 |
|
MD5 | 31bd6d8fbe0a3e3fcd5547bdd2b82d86 |
|
BLAKE2b-256 | 0148495edb5ec0778b5989114701963e553c5f68f553cb8b2c0abf8b0e79c890 |