randlab / geone

DeeSse interface, utilities and examples
Other
37 stars 11 forks source link

drawImage3D_surface and origin of the grid #9

Closed alecomunian closed 2 years ago

alecomunian commented 2 years ago

Hello Julien, I tried to used the function gn.imgplot3d.drawImage3D_surface to plot one of my 3D images, but there might be an issue related to how the origin is handled. The issue can be easily reproduced by using:

ti3dj = gn.img.readImageGslib("ti_3d.gslib")
gn.imgplot3d.drawImage3D_surface(ti3dj, text='TI', scalar_bar_kwargs={'vertical':True})

with the TI provided in the examples directory. The line above works fine if the origin in the GSLIB file is set to 0.5 0.5 0.5. However, if I try with 0.0 0.0 0.0 as origin nothing is shown in the plot. Actually, an image is shown as long as I choose values different from 0.0, but it looks like the scaling is somehow affected instead of the origin. Hope this helps. Cheers,

julien-straubhaar commented 2 years ago

Hello Alessandro, I did not reproduce this issue on my side. Are you sure you modify the "origin" and not the "spacing" (i.e. "cell size") in the file. In geone, the first line of the GSLIB file (for an image) is: nx ny nz sx sy sz ox oy oz that is there are 9 entries: the number of cells along each axis, then the cell size along each axis and finally the origin. The cell sizes must be positive. Try to print the origin ti3dj.ox, ti3dj.oy, ti3dj.oz and the spacing (cell size) ti3dj.sx, ti3dj.sy, ti3dj.sz to see the values in your case. Cheers, Julien

alecomunian commented 2 years ago

Hi Julien, the problem now seems to be solved :-) It was probably due to a different version of PyVista I had installed, because it printed out the following deprecation warning:

PyvistaDeprecationWarning: Behavior of pyvista.UniformGrid has changed. Use keyword arguments to specify dimensions, spacing, and origin. For example:

    >>> grid = pyvista.UniformGrid(
    ...              dims=(10, 10, 10),
    ...              spacing=(2, 1, 5),
    ...              origin=(10, 35, 50),
)

I solved this issue by explicitly calling the arguments of pv.UniformGrid as recalled in the warning. I made the updates in the imgplot3d.py in my fork and asked you for a merge. Best, Alessandro