question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plotting scatterplots on a 3D surface

See original GitHub issue

I’ve been playing around with Freesurfer and the gselu for doing electrode localization in python with ecog grids. It seems to work relatively well, which is really cool.

However, once I’ve got a FS surface model of a brain, as well as electrode positions, the next step is to use them to make brain plots. The two most common ways the ecog world does this is to

A. Make a scatterplot on top of the brain (where size / color represent your effect and location is the electrode position) B. Create some sort of heatmap on the cortical surface model using the electrode positions

It seems relatively straightforward to figure out B, and if an ecog type is ever added to mne-python I think it’d be a great viz addition. However, I’m not so sure how to do “A” effectively. Right now, I’ve tried using pysurfer to read my surface model. I’ve then tried two methods for plotting, which both fail for different reasons:

  1. Using Mayavi to plot a trisurface. This creates the brain beautifully, but the only way to create a scatterplot is to create these “spheres” that are rendered in 3D and look really ugly.
  2. Using matplotlib plot_trisurf to do the same thing. In this case, it creates nice “flat” scatterplots in the 3D axis. However, the call to plot_trisurf takes a really long time, and is unusably slow when it comes to rotating etc.

So I wonder, is there some way to combine the 3D capability of mayavi with the “data plotting” capability of matplotlib? I know that packages like this exist for matlab (e.g., here). These use matlab’s version of plot_trisurf, which I guess is more usable. Any thoughts on how to make this work?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:40 (30 by maintainers)

github_iconTop GitHub Comments

1reaction
larsonercommented, Feb 14, 2017

@choldgraf I think we have this now from your PRs, so I’ll close. Feel free to reopen if I’m mistaken

0reactions
choldgrafcommented, Nov 2, 2016

The main thing I’d like to do is:

  1. Make a surface plot of electrodes on a freesurfer-style surface.
  2. Pick a “view” of the camera on that surface, then take a snapshot of the view, and the 2D location of each electrode in that view.
  3. Plot scatterplots on top of the view where each point is an electrode.
  4. Optionally also plot foci of activity on the surface itself in Mayavi (or some other tool but I haven’t found a good way to do that)

Basically all the stuff in the gif that I showed above. I’ve got that code working in my own repo but I’m wondering if it would be useful and relatively low-cost to incorporate some of that into MNE (e.g., if you call plot_sensors with ecog channel types, it does something different than just plotting them on top of an EEG style topo plot.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select display options for 3D Scatterplot and 3D Surface Plot
About 3D scatterplots and 3D surface plots; Choose data display elements; Edit the 3D box; Rotate a 3D graph; Specify the surface type;...
Read more >
Plotly - 3D Scatter and Surface Plot - Tutorialspoint
3D scatter plots are used to plot data points on three axes in an attempt to show the relationship between three variables. Each...
Read more >
MATPLOTLIB 3D PLOTS including Scatter 3D and Surface ...
Learn how to build matplotlib 3D plots in this Matplotlib Tips video including 3D scatter plots, 3D line plots, surface plots, ...
Read more >
Plot a 3D surface from {x,y,z}-scatter data in python
I'm trying to plot a 3D surface constructed to fit some {x,y,z} points in python -- ideally something like the Mathematica ListSurfacePlot3D ...
Read more >
3D Scatter Plots - Plotly
After adding data, go to the 'Traces' section under the 'Structure' menu on the left-hand side. Choose the 'Type' of trace, then choose...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found