Py.Cafe

maartenbreddels/

ipyvolume-mri-head

MRI Visualization Using Ipyvolume

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import ipyvolume as ipv
import ipywidgets as widgets
import solara


fig = ipv.figure()
volume = ipv.examples.head(show=False, description="Patient X")
ipv.show()

slice_x = ipv.plot_plane('x', volume=volume, description="Slice X", description_color="black", icon="mdi-knife")
slice_y = ipv.plot_plane('y', volume=volume, description="Slice Y", description_color="black", icon="mdi-knife")
slice_z = ipv.plot_plane('z', volume=volume, description="Slice Z", description_color="black", icon="mdi-knife",
                         visible=False)

widgets.jslink((fig, 'slice_x'), (slice_x, 'x_offset'))
widgets.jslink((fig, 'slice_y'), (slice_y, 'y_offset'))
widgets.jslink((fig, 'slice_z'), (slice_z, 'z_offset'));

page = widgets.VBox([
    solara.Markdown.widget(md_text="""
    Press the scissors icon to use the slicing planes, or hold shift when you move the mouse.
    

    *NOTE: currently not behaving as expected, and the key press of shift only gets registered after clicking
    somewhere in the UI.*
    """),
    ipv.gcc()
])