marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
2.05k stars 266 forks source link

Error in show() with a VTI file #285

Open aleprezervtech opened 3 years ago

aleprezervtech commented 3 years ago

Hi @marcomusy,

I would like to visualize a VTI file that correctly visualizes in Paraview in a Jypiter Notebook. I am executing the following in the Jupyter notebook:

from vedo import load, show
vol = load('file.vti') 
show(vol)

I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-7336f24d46f4> in <module>
      1 from vedo import load, show
      2 vol = load('file.vti') 
----> 3 show(vol)
      4 
      5 

~/lib/python3.8/site-packages/vedo/plotter.py in show(*actors, **options)
    300         plt.interactor.Start()
    301     else:
--> 302         _plt_to_return = plt.show(
    303             actors,
    304             at=at,

~/lib/python3.8/site-packages/vedo/plotter.py in show(self, *actors, **options)
   1633         #########################################################################
   1634         if settings.notebookBackend and settings.notebookBackend != "panel" and settings.notebookBackend != "2d":
-> 1635             return backends.getNotebookBackend(actors2show, zoom, viewup)
   1636         #########################################################################
   1637 

~/lib/python3.8/site-packages/vedo/backends.py in getNotebookBackend(actors2show, zoom, viewup)
    156                 kx, ky, kz = ia.dimensions()
    157                 arr = ia.getPointArray()
--> 158                 kimage = arr.reshape(-1, ky, kx)
    159 
    160                 colorTransferFunction = ia.GetProperty().GetRGBTransferFunction()

AttributeError: 'NoneType' object has no attribute 'reshape'

Did I do something wrong or is this a bug? Thanks!

marcomusy commented 3 years ago

Thanks @aleprezervtech for reporting the issue. Does this also give you the same error message?

from vedo import load, show
vol = load('https://vedo.embl.es/examples/data/vase.vti')
show(vol)

You can also try:

from vedo import load, show, embedWindow
embedWindow(False)
vol = load('https://vedo.embl.es/examples/data/vase.vti')
show(vol)
aleprezervtech commented 3 years ago

I tried your version. In that case the kernel unfortunately dies...

marcomusy commented 3 years ago

In both cases? Are you able to run it from a nornal python script outside jupyter? what is your operative system?

aleprezervtech commented 3 years ago

I am using the Jypiter server on Linux and MacOs as my client. I can try to run it locally on the Mac since I do not have an X server on the server.

marcomusy commented 3 years ago

Ah that's why! Try following these steps: https://github.com/marcomusy/vedo/issues/64#issuecomment-559979201 If it doesn't help give me a couple of days to test it before the next release.

aleprezervtech commented 3 years ago

Thank you. I wanted the vti image to be displayed as a standard image inside the notebook, rather than using the X11 server forwarding to my Mac. I am not sure if that is possible at this point...

marcomusy commented 3 years ago

I see - I'm not 100% if it's possible, I'll get back to you when i can.