Canvas size¶

This notebook sets a fixed canvas width and height to ensure that all generated images are reproducible, regardless of the notebook’s display size.

This notebook mirrors the fixed size NiiVue notebook

In [1]:
from ipywidgets import VBox, Layout
from ipyniivue import NiiVue
from IPython.display import display

# ---- constants ----
NV_WIDTH  = 256   # pixels
NV_HEIGHT = 1024  # pixels

# ---- widget setup ----
nv = NiiVue(height=NV_HEIGHT)
nv.load_volumes([{'path': '../images/mni152.nii.gz'}])

# ---- layout using constants ----
box = VBox(
    [nv],
    layout=Layout(
        width=f"{NV_WIDTH}px",
        min_width=f"{NV_WIDTH}px",
        max_width=f"{NV_WIDTH}px",
        height=f"{NV_HEIGHT}px",
        overflow="hidden"
    )
)

display(box)
In [ ]:
 
In [ ]: