mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.72k stars 1.32k forks source link

ENH: 3D proj of topomaps #3121

Closed kingjr closed 1 year ago

kingjr commented 8 years ago

Since the mood seems to be around sensor plotting and topo projections (https://github.com/mne-tools/mne-python/pull/3065, https://github.com/mne-tools/mne-python/issues/3078, https://github.com/mne-tools/mne-python/pull/3065), I think it would be great if we could add an option to project the sensor data onto a default head (projection, or in 3D) to get more intuitive plots: e.g.

nn 3324-f2 f3 large

I suspect this is already possible with a bit of hack.

dengemann commented 8 years ago

+1000 would be excellent for template matching across datasets and subjects.

agramfort commented 8 years ago

+1

kingjr commented 8 years ago

This is actually pretty hard to do it right for MEG, isn't it? I was thinking of using the 3D viz, do an inverse model, and apply the forward to virtual sensors made from the fsaverage mesh, but that seems a bit overkilling (and also, I don't manage to make these virtual sensors)...

Any idea how we could procede?

teonbrooks commented 8 years ago

can't you apply the dev_head_t to the MEG signal so that is on the head surface? is that what you're trying to do?

teonbrooks commented 8 years ago

or mne.forward.make_field_map to project to head might be helpful

kingjr commented 8 years ago

@teonbrooks indeed! Thanks, I'll check this out

kingjr commented 8 years ago

Seems that all the functions are already in place, I was just no aware of them:

import os.path as op
import mne
from mne.forward import make_field_map
from mne.viz import plot_evoked_field

data_path = mne.datasets.sample.data_path()
subjects_dir = data_path + '/subjects'
trans_fname = data_path + '/MEG/sample/sample_audvis_raw-trans.fif'
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True)[0]
evoked.pick_types(meg='mag')
maps = make_field_map(evoked, trans=trans_fname, subjects_dir=subjects_dir,
                      subject='sample', n_jobs=-1, meg_surf='head')
plot_evoked_field(evoked, maps, time=.1)

Shall I close?

kingjr commented 8 years ago

related to this

  1. Would it make sense to precompute the "maps" of the fsaverage subject, so as to gain time?
  2. How can I plot the gradient of magnetic field (analogous to combined grads) on the head?
agramfort commented 8 years ago
  1. Would it make sense to precompute the "maps" of the fsaverage subject, so as to gain time?

it is really that slow? we could think of a joblib based caching system.

  1. How can I plot the gradient of magnetic field (analogous to combined grads) on the head?

AFAIK currently you can't

teonbrooks commented 8 years ago

@kingjr is the plan to have a topomap with option for head-oriented topography on a cartoon head?

kingjr commented 8 years ago

@teonbrooks Well I thought the cartoon wouldn't be great. If we do it, might as well do it properly, no?

teonbrooks commented 8 years ago

what would you use other than the default model?

kingjr commented 8 years ago

what would you use other than the default model?

I would aim for having default head, but this could be then changed to average head across subjects, or subject-specific heads.

Overall, I think it would make our papers more intuitive for naive readers if we plotted heads instead of flattened sensor arrays. But if we can't plot field gradients (tangential to the head surface), it won't be as useful as I had originally hoped because one would still have to mentally visualize where the dipole is likely to be coming from (i.e. in between the red and blue patches).

larsoner commented 8 years ago

Actually thinking about it more you can project to any virtual sensors you like with the minimum norm code. So you could project to colocated orthogonal pairs of arbitrarily placed planar gradiometers and then take the norm of each pair if you want.

kingjr commented 8 years ago

@Eric89GXL so we just have to find a way to make virtual sensors from the head mesh?

larsoner commented 8 years ago

Yeah you have to choose locations and normals

kingjr commented 8 years ago

BTW, isn't the projection of sensor to scalp an ill-posed problem?

larsoner commented 8 years ago

We project to a minimum norm spherical source space and back out essentially

kingjr commented 8 years ago

Well, I'm stuck.

In _make_surface_mapping the virtual coils can still be gradiometers (at least their type matches those of neuromag grads), but I don't know where to look then. Do I need to modify _do_self_dots, _do_surface_dots and _compute_mapping_matrix. Any advice?

larsoner commented 7 years ago

In _make_surface_mapping the virtual coils can still be gradiometers

@kingjr if you're interested in coming back to this... yes the can be gradiometers, but you can also put any other sensors you want there, e.g. point magnetometers.

larsoner commented 1 year ago

I think we should be able to close this now that EvokedField is more usable and intuitive. We should open targeted issues around improving it if plotting sensor data on the head isn't good enough there