You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
picking vertex in brain object to see time course #7235
a suggestion from @SophieHerbst is also to have a short cut to pick automatically the vertex with the highest amplitude in the current view.
I'm actually not sure the extent to which this will be possible. Picking with the mouse is usually done by rendering tricks or casting a ray (I think VTK does the latter). I'm not sure there is a way to ask for "all mesh vertices currently visible). And given a non-zero alpha, this isn't even necessarily well defined. So for a first pass I say we just make it so that clicking on a point in the mesh does mesh vertex picking and does a vtkChart plot of the time course. (If off the mesh, don't change the point currently used. This way clicking always will show the time course, and if you don't want it to change, click in the empty space around the mesh. Either that or use ctrl-click for picking or something.)
I leave it as an exercise to @GuillaumeFavelier to figure out where this plot should live :) Maybe a show_timecourse=True would make a new full-width (regardless of views) plot area at the bottom reserved for a time course chart like our volume viewer:
+10 to embedding a mpl figure rather than figuring out vtkChartXY, it gives us more flexibility going forward, e.g., including showing time-frequency images eventually, and will unify the user experience of 2D plots around MPL and its standard interactions (like zooming and view resetting). The "only" tricky parts of this approach will be:
setting up our own Qt window instead of relying on PyVista and MPL to do it for us, and then also
eventually making sure that when in a notebook we embed the canvases properly rather than creating a Qt window
@larsoner Why would we have to set up our own Qt window? At least in interactive matplotlib mode - it might be easier and more flexible to open a separate matplotlib window per click/interaction.
I don't think that would work as well. The design I'm advocating is basically a variant of what we already do in the volume plotter. You could apply your argument to that as well -- that we shouldn't render the time trace(s) in the same window as the brain volume rendering -- and I don't think it would be as nice as experience as having them contained in the same window.
Yes, that's true - separate window can feel more clunky, but the benefit is that the user can place it however he wants. And although volume source plotter shows traces in the same window - many other mne interfaces open separate windows (time-frequency - when interacting with topomap [also tfr heatmap IIRC], evokeds - when selecting time window, ica source signal viewer when clicking on ic label, ica plot components opens properties windows). With separate windows you can also compare various traces without the need to implement specific option for that - you click on two vertices / channels and see corresponding signals in two separate windows.
In general I agree that it might be nicer to have everyting in one plot - my previous comment was mostly motivated by perceived difficulity of this goal. It seems easier to spawn a separate matplotlib window. But the one-window approach may be easier than I think - and the user experience may be worth it. :)
show_traces='separate' or something. But let's figure this API out separately as there are additional questions we'll want to sort out (e.g., should each click open a new window, should we close the windows when clicking just like we remove traces from the all-one plot in the joint mode, etc.)
Activity
larsoner commentedon Jan 21, 2020
At least in principle there is vtkChart:
I'm actually not sure the extent to which this will be possible. Picking with the mouse is usually done by rendering tricks or casting a ray (I think VTK does the latter). I'm not sure there is a way to ask for "all mesh vertices currently visible). And given a non-zero alpha, this isn't even necessarily well defined. So for a first pass I say we just make it so that clicking on a point in the mesh does mesh vertex picking and does a vtkChart plot of the time course. (If off the mesh, don't change the point currently used. This way clicking always will show the time course, and if you don't want it to change, click in the empty space around the mesh. Either that or use ctrl-click for picking or something.)
I leave it as an exercise to @GuillaumeFavelier to figure out where this plot should live :) Maybe a
show_timecourse=Truewould make a new full-width (regardless ofviews) plot area at the bottom reserved for a time course chart like our volume viewer:https://mne.tools/dev/auto_examples/inverse/plot_lcmv_beamformer_volume.html#plot-source-space-activity
jasmainak commentedon Jan 21, 2020
why not extend the functionality of 4D viewer with cortical ribbon first?
larsoner commentedon Jan 21, 2020
It's nicer to view surface source estimate data on the surface
GuillaumeFavelier commentedon Jan 21, 2020
That's a nice idea and thank you so much for the pointers @larsoner, I have somewhere to start now.
larsoner commentedon Jan 21, 2020
And for mouse click vertex picking in mayavi (so you can translate to PyVista) see
https://github.com/mne-tools/mne-python/blob/master/mne/gui/_fiducials_gui.py#L359
GuillaumeFavelier commentedon Jan 23, 2020
Vertex picking is available by default in PyVista:
SophieHerbst commentedon Jan 23, 2020
Would this allow to spit out MNI coordinates at the pick (or the label of a pre-defined atlas)?
SophieHerbst commentedon Jan 23, 2020
Also, a very small add-on: labels for the 3 clim-scales would be helpful.
GuillaumeFavelier commentedon Jan 23, 2020
I think any data associated to the point data/vertex id could be retrieved that way in theory.
GuillaumeFavelier commentedon Jan 23, 2020
I discovered
vertex_to_mni()to take care of the conversion.GuillaumeFavelier commentedon Jan 23, 2020
fmax/fmid/fmin labels were present in previous version but were dropped in favour of a more compact UI.
GuillaumeFavelier commentedon Jan 24, 2020
ToDo (suggested in #7247 (comment))
show_traces=TruevtkChartXYin split view or embed the MPL figs in a Qt framemax(abs(t))by default (suggested in MRG: Enable point picking in _TimeViewer #7247 (comment))pto trigger picking (suggested in MRG: Enable point picking in _TimeViewer #7247 (comment))cellpicking instead ofpointpicking (expecting better precision)hemi=bothorhemi=splitshow_traces=separateto detach the matplotlib canvas (suggested in picking vertex in brain object to see time course #7235 (comment))views(suggested in MRG: Enable point picking in _TimeViewer #7247 (comment))larsoner commentedon Jan 27, 2020
+10 to embedding a mpl figure rather than figuring out vtkChartXY, it gives us more flexibility going forward, e.g., including showing time-frequency images eventually, and will unify the user experience of 2D plots around MPL and its standard interactions (like zooming and view resetting). The "only" tricky parts of this approach will be:
mmagnuski commentedon Jan 28, 2020
@larsoner Why would we have to set up our own Qt window? At least in interactive matplotlib mode - it might be easier and more flexible to open a separate matplotlib window per click/interaction.
larsoner commentedon Jan 28, 2020
I don't think that would work as well. The design I'm advocating is basically a variant of what we already do in the volume plotter. You could apply your argument to that as well -- that we shouldn't render the time trace(s) in the same window as the brain volume rendering -- and I don't think it would be as nice as experience as having them contained in the same window.
mmagnuski commentedon Jan 28, 2020
Yes, that's true - separate window can feel more clunky, but the benefit is that the user can place it however he wants. And although volume source plotter shows traces in the same window - many other mne interfaces open separate windows (time-frequency - when interacting with topomap [also tfr heatmap IIRC], evokeds - when selecting time window, ica source signal viewer when clicking on ic label, ica plot components opens properties windows). With separate windows you can also compare various traces without the need to implement specific option for that - you click on two vertices / channels and see corresponding signals in two separate windows.
In general I agree that it might be nicer to have everyting in one plot - my previous comment was mostly motivated by perceived difficulity of this goal. It seems easier to spawn a separate matplotlib window. But the one-window approach may be easier than I think - and the user experience may be worth it. :)
GuillaumeFavelier commentedon Jan 29, 2020
Honestly I thought the same at first but it seems only a few lines of code were necessary to add this:
mmagnuski commentedon Jan 29, 2020
@GuillaumeFavelier - that's cool!
So maybe it wouldn't be difficult to add an option to detach the matplotlib figure? 😈
GuillaumeFavelier commentedon Jan 29, 2020
It's possible too. How would you pass this option though? We already use
show_traces=Trueinplot_source_estimates().larsoner commentedon Jan 29, 2020
show_traces='separate'or something. But let's figure this API out separately as there are additional questions we'll want to sort out (e.g., should each click open a new window, should we close the windows when clicking just like we remove traces from the all-one plot in the joint mode, etc.)mmagnuski commentedon Jan 29, 2020
@larsoner Sure!