Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does k3d-jupyter support to render a time series of 3D volume? #444

Closed
tfunatomi opened this issue Jan 5, 2024 · 4 comments
Closed

Does k3d-jupyter support to render a time series of 3D volume? #444

tfunatomi opened this issue Jan 5, 2024 · 4 comments
Assignees

Comments

@tfunatomi
Copy link
Contributor

  • K3D version: 2.16.0
  • Python version: 3.10.12
  • Operating System: Ubuntu22.04

Description

I want to render a time series of a 3D volume.
It seems that the animation for the time series works, but the rendering result looks strange.

What I Did

When I try to render a time series of a 3D volume by passing a dictionary to k3d.mip or k3d.volume, there is no error but the rendering result becomes very different from the one when rendering a time step.

import k3d
import numpy as np
import SimpleITK as sitk

im_sitk = sitk.ReadImage('./heart.mhd')
img = sitk.GetArrayFromImage(im_sitk)

plot = k3d.plot()
plt_mip_o = k3d.mip(img.astype(np.float32), name='MIP of one timestep')
plt_mip_o.visible = False # Just for comparison
plot += plt_mip_o
plt_mip_t = k3d.mip({0:img.astype(np.float32)}, name='MIP of a time series')
plot += plt_mip_t
plot.display()

I would be grateful if you could help me.

@artur-trzesiok artur-trzesiok self-assigned this Jan 6, 2024
@artur-trzesiok
Copy link
Collaborator

Hi @tfunatomi !

k3d.volume and k3d.mip have important parameter called "color_range". For static data it is calculated authomatically if user will not pass it. For time series data that automation is disabled. So if you will pass color_range like that:

plt_mip_t = k3d.mip({0:img.astype(np.float32)}, 
                    color_range = [0.0, 1000.0], 
                    name='MIP of a time series')

everything will be fine. Thanks for spoting that problem. I should either add infomation about that constraint to docs or implement feature to calculate color_range for timeseries data.

btw. Please remember that in animation parameters are interpolated using js. So in your case you will try to interpolate 317x 512 x 512 floats number in pure js. That will be slow. Animation in k3d have special rule that if time == exactly a keypoint interpolation will be avoided.

btw. I have in my mind idea to do interpolation for k3d.volume and k3d.mip on shader level.

@artur-trzesiok
Copy link
Collaborator

Thanks @tfunatomi . Fix is on devel

@artur-trzesiok
Copy link
Collaborator

Hi! Please check https://pypi.org/project/k3d/2.16.1/ :)

@tfunatomi
Copy link
Contributor Author

I appreciate your quick response!
It's so helpful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants