widgetti / ipyvolume

3d plotting for Python in the Jupyter notebook based on IPython widgets using WebGL
MIT License
1.94k stars 234 forks source link

Volumetric time series #157

Open RealPolitiX opened 6 years ago

RealPolitiX commented 6 years ago

It looks like the 4D animation (3D positions + 1D time) is only possible with the quiver plot. Are there plans to implement something similar for the volshow, such that with a time slider, one can look through a volumetric time series? Thanks.

maartenbreddels commented 6 years ago

Dear Patrick,

There are no concrete plans now, but support for this is trickling in (now that Volume is its own widget). I am a bit worried that the amount of data is too large, but if you use small cubes (256^3) and say max 100 timesteps it should be feasible. If you want to contribute, you are welcome.

cheers,

Maarten

griffinmilsap commented 5 years ago

Ah.. bummed to hear this isn't implemented. The documentation doesn't effectively point out that this isn't possible yet.

griffinmilsap commented 5 years ago

Hey, anybody who needs a quick hack to make this work -- With ipyvolume 0.5+

import ipyvolume as ipv
import numpy as np
import scipy

# Generate some random data to animate
nx, ny, nz, nt = 16, 16, 16, 10
randvol = np.random.rand( nt, nx, ny, nz )
for i_t, vol in enumerate( randvol ): 
    randvol[ i_t, ... ] = scipy.ndimage.gaussian_filter( vol, 4 )

fig = ipv.pylab.figure()
ipv.pylab.style.box_off()
ipv.pylab.style.axes_off()

# Plot the first frame
v = ipv.pylab.volshow( randvol[ 0, ... ], opacity = 0.03, level_width = 0.1 )
ipv.pylab.show()

The widget should show up -- now you can "animate it" by just feeding it new data in a loop with a sleep in the middle

import time
for i_t in range( nt ):
    v.data = randvol[ i_t, ... ]
    time.sleep( 0.5 )