-
Notifications
You must be signed in to change notification settings - Fork 236
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
base: master
Are you sure you want to change the base?
Conversation
…stead of the volume rendering.
…enience function.
…ther than a single volume or the list of volumes.
There was a problem hiding this 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') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is best to look at this implementation:
https://github.com/maartenbreddels/ipyvolume/blob/9b7801b41bc3d77d96c01ef774854008b06b5353/ipyvolume/transferfunction.py#L79
https://github.com/maartenbreddels/ipyvolume/blob/9b7801b41bc3d77d96c01ef774854008b06b5353/js/src/tf.js#L57
And base it on that. Does that help?
@@ -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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.
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) |
Has this been abandoned? |
e861e87
to
6dead3f
Compare
Extending volume rendering code to accomodate multi-dimensional data. Accepts either 3D or 4D data (3 spatial dimensions, plus color channels).
Example:
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