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

[WIP] FEATURE: Multivolume rendering for multi-dimensional data #186

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

GenevieveBuckley
Copy link
Contributor

Extending volume rendering code to accomodate multi-dimensional data. Accepts either 3D or 4D data (3 spatial dimensions, plus color channels).

Example:

import numpy as np
import ipyvolume as ipv

aquarius = ipv.datasets.aquariusA2.fetch() # 3D data
data = np.moveaxis(np.array([aquarius.data, aquarius.data.T]), 0, -1) # pseudo-4D data

ipv.quickvolshow(data)

ipyvolume_multivolshow

Unlike the existing brightness and opacity sliders, the colorpicker widget uses a python callback. This means the colorpicker widget won't work if there isn't a live python kernel (eg: if the ipyvolume widget is embedded in a html document). This is a disadvantage - is it possible to implement in javascript? I've seen this previous discussion but am unsure if there's been progress there.

Note: Any comments about the code generating the linear ramp transfer functions should go in the discussion at #178

Copy link
Collaborator

@maartenbreddels maartenbreddels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, nice work!
What is the reason for doing this in volshow, why not simply a loop/multiple calls? I think it may make volshow's behaviour too complex, and maybe less flexible even. What do you think?

ipywidgets.jslink((vol, 'brightness'), (widget_brightness, 'value'))
def change_transfer_function(vol, color):
vol.tf = linear_transfer_function(color.new)
widget_colorpicker.observe(lambda x, vol=vol: change_transfer_function(vol, x), names='value')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would create a new widget for each color picked, I think this is a good reason to make this happen on the javascript side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to do that. What's the javascript equivalent of observe?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -675,67 +674,71 @@ def volshow(data, lighting=False, data_min=None, data_max=None,
:param float data_min: minimum value to consider for data, if None, computed using np.nanmin
:param float data_max: maximum value to consider for data, if None, computed using np.nanmax
:parap int max_shape: maximum shape for the 3d cube, if larger, the data is reduced by skipping/slicing (data[::N]), set to None to disable.
:param tf: transfer function (or a default one)
:param tf_colornames: transfer function (or a default one)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about letting tf be a string or tuple, like in this PR where the icon can be a string or Icon widget.


fig.volumes = fig.volumes + [vol]

return fig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm against returning figure, since it does not follow conventions/intuition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return the full list of volumes, then? I'll do that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, check my above comment, why would volshow do this? Why not repeatedly call volshow?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, for a quick chat, https://gitter.im/maartenbreddels/ipyvolume may be useful, and we could also do a videochat if that speeds things up.

@GenevieveBuckley
Copy link
Contributor Author

What is the reason for doing this in volshow, why not simply a loop/multiple calls?

Because it's a pain in the butt, that's why. I want to write a single funciton call, rather than a bunch of boilerplate every time I need to visualize an array. I'm generally working with multidimensional data in a 4D or 5D numpy array. That's also true for most other people working with microscopy images, hyperspectral astronomical data, medical imaging, etc. So there are a lot of use cases for extending this.

I think it may make volshow's behaviour too complex, and maybe less flexible even.

What flexibility do you think is lost? You can still pass in a single 3D arrray and have it work the same as before. (In fairness, this PR mucks around with the default transfer function, but that's the only change, and even that might not stay like that for long)

@evolu8
Copy link

evolu8 commented Mar 4, 2020

Has this been abandoned?

@GenevieveBuckley
Copy link
Contributor Author

Hi @evolu8, this fell off my radar after the discussion about the different types of transfer function widgets in #178. Did you want to take a crack at this?

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

Successfully merging this pull request may close these issues.

None yet

3 participants