Saving images¶

NiiVue offers several ways to save a scene. The simplest is exporting a static bitmap in the widely supported PNG format, producing a small, easily shared image suitable for publications—though it is no longer interactive. A more powerful option is NiiVue’s ability to fully document the current scene, including all settings, images, and meshes. These can be saved as a .nvd file, which can be reopened by dragging it onto a NiiVue web page, or as a self-contained .html file that embeds both the scene and the viewer, allowing others to interactively explore it.

In [1]:
from ipyniivue import NiiVue, SliceType

volumes = [
    {
        "path": "../images/mni152.nii.gz",
        "colormap": "gray",
        "visible": True,
        "opacity": 1.0,
    },
    {
        "path": "../images/hippo.nii.gz",
        "colormap": "red",
        "visible": True,
        "opacity": 1,
    },
]
nv = NiiVue(slice_type=SliceType.MULTIPLANAR)
nv.load_volumes(volumes)
nv
/home/runner/work/ipyniivue/ipyniivue/src/ipyniivue/widget.py:1327: UserWarning: Ignored unsupported kwargs in Volume: ['visible']
  volume_objects.append(Volume(**item))
Out[1]:
In [2]:
nv.save_document("test.nvd")
In [3]:
nv.save_html("test.html")
In [4]:
nv.save_image()
In [5]:
nv.save_scene("test.png")