niivue / ipyniivue

A WebGL-powered Jupyter Widget for Niivue based on anywidget
BSD 2-Clause "Simplified" License
25 stars 8 forks source link

Restarting the kernel fails to destroy the NiiVue object #39

Closed christian-oreilly closed 5 months ago

christian-oreilly commented 1 year ago

In a notebook with cell #1:

import ipyniivue
nv = ipyniivue.Niivue(crosshair_color=[0,1,0,1])

Cell #2:

display(nv)

Cell #3:

nv.add_volume("https://niivue.github.io/niivue/images/mni152.nii.gz")
nv.set_slice_type(nv.slice_type.render)

If I run in order cells #1, #2, #3, restart the kernel, run cells #1, #2. At this point, the display from when I ran cell #3 before restarting the kernel is still displayed and responsive.

Note, this issue is not there if I have

Cell #1:

import ipyniivue
nv = ipyniivue.Niivue(crosshair_color=[0,1,0,1])
display(nv)

Cell #2:

nv.add_volume("https://niivue.github.io/niivue/images/mni152.nii.gz")
nv.set_slice_type(nv.slice_type.render)

And run #1, #2, restart, #1