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

interact has issues when passing a Mesh instead of image #15

Open
haesleinhuepf opened this issue Feb 4, 2023 · 0 comments
Open

interact has issues when passing a Mesh instead of image #15

haesleinhuepf opened this issue Feb 4, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@haesleinhuepf
Copy link
Owner

When using stackview.interact with something that is no image, it crashes:

import numpy as np
import stackview

surface = nppas._vedo_stanford_bunny()
mesh = nppas.to_vedo_mesh(surface)

def do_show(mesh, zoom:float = np.exp(1), azimuth:float = 0, elevation:float = 0, roll:float = 0):
    from vedo import Plotter
    plt = Plotter(offscreen=True, size=[600,400], N=2)
    plt.show(mesh, zoom=np.log(zoom), azimuth=azimuth, elevation=elevation, roll=roll)
    return plt.screenshot(asarray=True)

stackview.interact(do_show, mesh, continuous_update=True)

Error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[5], line 10
      7     plt.show(mesh, zoom=np.log(zoom), azimuth=azimuth, elevation=elevation, roll=roll)
      8     return plt.screenshot(asarray=True)
---> 10 stackview.interact(do_show, mesh, continuous_update=True)

File ~\mambaforge\envs\bio39\lib\site-packages\stackview\_interact.py:108, in interact(func, image, continuous_update, context, zoom_factor, zoom_spline_order, viewer, *args, **kwargs)
    106 viewer_was_none = viewer is None
    107 if viewer_was_none:
--> 108     viewer = _SliceViewer(image, zoom_factor=zoom_factor, zoom_spline_order=zoom_spline_order)
    109 viewer.slice_slider.continuous_update=continuous_update
    110 command_label = ipywidgets.Label(value=func_name + "()")

File ~\mambaforge\envs\bio39\lib\site-packages\stackview\_slice_viewer.py:21, in _SliceViewer.__init__(self, image, slice_number, axis, display_width, display_height, continuous_update, slider_text, zoom_factor, zoom_spline_order)
     18 self.image = image
     20 if slice_number is None:
---> 21     slice_number = int(image.shape[axis] / 2)
     23 if len(self.image.shape) == 3 and self.image.shape[-1] != 3:
     24     self.view = ImageWidget(np.take(image, slice_number, axis=axis), zoom_factor=zoom_factor, zoom_spline_order=zoom_spline_order)

AttributeError: 'Mesh' object has no attribute 'shape'
@haesleinhuepf haesleinhuepf added the enhancement New feature or request label Feb 4, 2023
@haesleinhuepf haesleinhuepf changed the title interact has issues when passing a SurfaceData instead of image interact has issues when passing a Mesh instead of image Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant