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

Volume from polydata (point cloud) #125

Closed
quaeritis opened this issue Feb 10, 2020 · 8 comments
Closed

Volume from polydata (point cloud) #125

quaeritis opened this issue Feb 10, 2020 · 8 comments
Labels
filtering General topics around filtering and usage of filters

Comments

@quaeritis
Copy link

quaeritis commented Feb 10, 2020

Description

Hi, I would like to render a volume from a point cloud (polydata).

I thought pv.DataSetFilters.interpolate would be the right one for this. To get a pyvista.UniformGrid which I can then plot with pn.panel (grid, sizing_mode =' stretch_both ', height = 400, display_slices = True) in jupyterlab. Unfortunately I only get an polydata object from interpolate.

I am currently using vtkplotter.interpolateToVolume but would like to switch to pyvista.
An update of the scalar values would also be very practical. I think this should be possible with the panel vtk plot.

Example Data

My starting point are numpy arrays with points and associated scalar values:

vertices = np.array([[0, 0, 1], [1, 0, 0], [1, 0.5, 0], [0, 0.5, 0.5]])
data = pv.PolyData(vertices)
data.point_arrays["values"] = [0.1, 0.5, 0.3, 0.8]

How do I get a UniformGrid from this I can plot as a vtkVolume

Other topic:

A Gitter for support would also be helpful, I think. slack is an unsightly solution (proprietary software). But the most important point is that an additional registration is necessary. Gitter can easily be used with the Github acc.

If you google a little you will find numerous articles that explain why Slack is absolutely unsuitable for open source communications here and here.
Gitter is just my suggestion but basically anything that is open source (irc, Mattermost, ...) is better than Slack.

@quaeritis
Copy link
Author

quaeritis commented Feb 10, 2020

o.k got the solution (I had used interpolate incorrectly):

import numpy as np
import pyvista as pv
from pyvista import examples
import panel as pn
pn.extension('vtk')

import os
os.environ["DISPLAY"] = ":99.0"
os.system('Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &')

grid = pv.UniformGrid()
grid.dimensions = (10, 10, 10)
grid.origin = (0, 0, 0)
grid.spacing = (1, 1, 1)

vertices = np.array([[0, 0, 3], [2, 0, 0], [5, 2, 0], [0, 3, 4]])
data = pv.PolyData(vertices)
data.point_arrays["values"] = [0.1, 0.5, 0.3, 0.8]

igrid = grid.interpolate(points=data, pass_point_arrays=True, dimensions=(10, 10, 10), radius=1)
volume = pn.panel(igrid, sizing_mode='stretch_both', height=400, display_slices=True)
pn.Row(volume.controls(jslink=True), volume)

But what is the most sensible way to update the values? So that I have a callback that I can use with ipywidget / panel to update the plot.

@akaszynski
Copy link
Member

I too don't really like slack as it's not free! Discourse was another option @banesullivan and I had discussed, but it's not free. Sounds like Gitter is the way to go. Didn't even realize that was out there.

@banesullivan, your thoughts?

@banesullivan
Copy link
Member

@quaeritis, thanks for posting your solution here so that others can later find and learn from it!


As for Slack...

I personally like Slack a lot and I'm active in over 10 workspaces, so its the place to find me... Slack with channels, integrations, markdown formatting are great and it's base features (all that we would need) are free. Very tough sell to move me towards Gitter, but I'm happy to let folks know we have it... however, we should caution to fragment our presence/communities online as that could really hinder how new users/contributors receive support/get involved.

As for using a social messaging platform for support (whether it is Gitter or Slack), I'm generally not in favor of that. I'd really like to see this support "forum" take off as it is seamless to link changes in the codebase to support tickets and all of these support topics are permanently archived with tags, well-formatted code, and a really powerful search engine built into GitHub. So that way when a new issue opens up, we can easily find similar issues and give the new user a clean way to find materials related to their topics. Having a new user search through Gitter or Slack's message threads is not ideal.

In summary: Support topics and any knowledge about PyVista should be on GitHub (either this support repo or the main PyVista repo) and social messages on Gitter/Slack should be for banter, project management/logistics nonsense, sharing cool links/demos, connecting with folks to start a new project, or one-off support items like "how do I install this package and make a sphere".

@banesullivan
Copy link
Member

banesullivan commented Feb 10, 2020

Also, @quaeritis, I see you are using a UniformGrid with panel in Jupyter notebooks. UniformGrids can be volume rendered. I'd highly recommend checking out itkwidgets as it supports volume rendering of PyVista UniformGrid directly in the notebook (I'm not aware if Panel supports that or not)

from itkwidgets import view
view(image=igrid)

Screen Shot 2020-02-10 at 10 11 11 AM

@banesullivan
Copy link
Member

banesullivan commented Feb 10, 2020

And...... our interpolation filter is super basic. If you're doing real multipoint statistics or needing better interpolation, I'd highly recommend checking out GSTools. I've been using their kriging interface with PyVista a ton lately and have been meaning to finish out the interface between PyVista and GSTools.

Perhaps this example interpolation workflow would interest you: GeoStat-Framework/GSTools#36 (comment)

@banesullivan banesullivan added the filtering General topics around filtering and usage of filters label Feb 10, 2020
@quaeritis
Copy link
Author

quaeritis commented Feb 10, 2020

Hello @banesullivan, I can easily render the UniformGrid in panel. As shown in the code above. I'm trying to get away from itkwidgets. Since it is too inflexible in comparison to the panel API what I can easily do with the GUI.

So would you still be open to creating a Gitter room? Would you put it on or would someone else have to do it? (I do not know if this can be done without rights, if so I can do that.)
That with slack is really sad, I really think that slack does more harm than good in the open source area. As far as I know, the functions you mentioned are also well provided in Gitter. It also has very good github integration. However, a grid can also be viewed without registration (including appearing in google results). So think slack is probably a bigger knowledge grave.

I can understand your concerns about communication fragmentation. I can also understand your other explanations regarding the disadvantages of a chat for support.

Another question from me is still where is the project delimitation between pyvista and PVGeo both offer e.g. filters? I think some of the PVGeo functions are general plot functions independent of geo sciences. Please don't get me wrong, I think your project is great here. I just think that many potential users don't use the great tools that PVGeo offers because they think it's primarily for the geo sciences.

(sorry for my bad English)

@akaszynski
Copy link
Member

akaszynski commented Feb 10, 2020

Ich habe ein "Gitter Room" gemacht: https://gitter.im/pyvista/community#

As for itkwidgets, I think it's great, but panel's API is more featured. We're planning on integrating panel with pyvista in the future.

@banesullivan will have to reply about the difference with PVGeo.

Also, your english is great. I lived in Germany for some time and I have a lot of respect for those who have to regularly converse in another language.

@banesullivan
Copy link
Member

banesullivan commented Feb 10, 2020

As @akaszynski mentioned, we have a Gitter room (at least I'm guessing that's what that german states). If the PyVista community wants Gitter, I'm all for it! I want the users/community to drive the decisions, so if the Gitter gets more traction than Slack, then we can re-evaluate this and perhaps migrate to Gitter in the spirit of openness. In the meantime, I really like Slack and you all can find me on there 😉


Another question from me is still where is the project delimitation between pyvista and PVGeo both offer e.g. filters? I think some of the PVGeo functions are general plot functions independent of geo sciences. Please don't get me wrong, I think your project is great here. I just think that many potential users don't use the great tools that PVGeo offers because they think it's primarily for the geo sciences.

You bring up some great points about PVGeo. It has been tough to draw a line for what should be in PVGeo vs PyVista. I believe that I am heading towards having PVGeo be a file IO module for geoscience formats and moving most of the filters over to PyVista. The thing is, some of those custom filters in PVGeo that aren't necessarily geoscientific do not all make sense to include in PyVista as we are trying to keep PyVista lean and clean as a pure interface back to VTK. Merging the two projects would produce quite a bit of maintenance overhead that I don't want to push on the other developers of PyVista, so... PVGeo has become an orphan of PyVista with some neat features that not many folks know about or are willing to try because it has some heavy dependencies and is marketed towards geoscientists.

In time, I hope to completely refactor PVGeo into a more useable Python module less focused on ParaView plugins. Perhaps then, I can migrate filters to PyVsita that make sense to be in PyVista and leave PVGeo as a file IO extension package to PyVista. and then maybe make an offshoot project that handles all the ParaView plugins totally separate by wrapping both PVGeo and PyVista filters.

Some other points:

  • some filters in PVGeo could be re-implemented with VTK code like the VoxelizePoints and ExtractTopography filters.
  • some of the general filters are there simply because PVGeo offers them as plugins to ParaView and they are totally not meant to be used in Python
  • pyvista vs pvgeo #98 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filtering General topics around filtering and usage of filters
Projects
None yet
Development

No branches or pull requests

3 participants