Mosaics¶

Mosaics refer to illustrating many views of images simulateously, often referred to as the lightbox mode. NiiVue allows you to specify the orientation and position for an arbitrary number of snapshots.

Mosaic coordinates are preceded by one or more labels. The first label is orientation:

  • A: axial
  • C: coronal
  • S: sagittal

Numbers after the orientation label indicate slices in the real-world coordinate system. Therefore, after spatial normalization of brain images, these refer to the distance from the anterior commissure. So the string: A 10.0 20.4 30 would indicate axial slices at 10.0, 20.4, and 30 mm superior to that landmark.

Additional labels may be used to render a volume (R) and to show the location of other slices in the mosaic (X). In the case of a volume render, the value of the coordinate is ignored and the sign indicates the view orientation.

This first example mirrors the NiiVue live demo web page. Note that this example does NOT show orientation labels.

Note that you can modify the mosaic string shown in the interactive demo to grasp the format.

In [1]:
import ipywidgets as widgets

from ipyniivue import NiiVue


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()
nv.load_volumes(volumes)


style = {"description_width": "initial"}
string_widget = widgets.Text(
    value="A -20 50 60 70 C -10 -20 -50; S R X 0 R X -0",
    description="Slice mosaic string",
    style=style,
)
string_widget.layout.width = "auto"

nv.opts.slice_mosaic_string = string_widget.value


def update_view(*args):
    """Update the mosaic according to the string in the widget."""
    nv.opts.slice_mosaic_string = string_widget.value


string_widget.observe(update_view, "value")

display(string_widget)
display(nv)
/home/runner/work/ipyniivue/ipyniivue/src/ipyniivue/widget.py:1327: UserWarning: Ignored unsupported kwargs in Volume: ['visible']
  volume_objects.append(Volume(**item))
In [ ]:
 
In [ ]: