Skip to content

Conversation

@larsoner
Copy link
Member

@larsoner larsoner commented May 5, 2020

Closes #7564.
Closes #7007.

@fleurgaudfernau can you see if it works for your use case? For example this code now runs fine:

Starter code
import mne
import os.path as op
import numpy as np

data_path = mne.datasets.testing.data_path()
subject = 'sample'
data_dir = op.join(data_path, 'MEG', subject)
subjects_dir = op.join(data_path, 'subjects')
bem_dir = op.join(subjects_dir, subject, 'bem')

fname_src = op.join(bem_dir, 'sample-oct-4-src.fif')
fname_aseg = op.join(subjects_dir, subject, 'mri', 'aseg.mgz')

labels_vol = ['Left-Cerebellum-Cortex', 'Right-Cerebellum-Cortex']

# create a mixed source space
src = mne.setup_source_space(subject, spacing='oct4',
                             add_dist=False, subjects_dir=subjects_dir)
src += mne.setup_volume_source_space(
    subject, mri=fname_aseg, pos=10.0,
    volume_label=labels_vol, subjects_dir=subjects_dir,
    add_interpolator=True, verbose=True)

src_fs = mne.read_source_spaces(
    op.join(subjects_dir, 'fsaverage', 'bem', 'fsaverage-ico-5-src.fif'))
src_fs += mne.setup_volume_source_space(
    'fsaverage', pos=5., volume_label=labels_vol,
    subjects_dir=subjects_dir, add_interpolator=False, verbose=True)

morph = mne.compute_source_morph(
    src=src, subject_from=subject, subject_to='fsaverage',
    subjects_dir=subjects_dir, niter_affine=[1, 1, 1],
    niter_sdr=[1, 1, 1], src_to=src_fs, verbose=True)

vertices = [s['vertno'] for s in src]
n_vertices = sum(len(v) for v in vertices)
data = np.ones((n_vertices, 1))
stc = mne.MixedSourceEstimate(data, vertices, 0, 1, 'sample')
stc_fs = morph.apply(stc)

@codecov
Copy link

codecov bot commented May 5, 2020

Codecov Report

Merging #7734 into master will decrease coverage by 0.13%.
The diff coverage is 99.42%.

@@            Coverage Diff             @@
##           master    #7734      +/-   ##
==========================================
- Coverage   90.36%   90.23%   -0.14%     
==========================================
  Files         459      455       -4     
  Lines       84942    84750     -192     
  Branches    13459    13429      -30     
==========================================
- Hits        76762    76477     -285     
- Misses       5321     5405      +84     
- Partials     2859     2868       +9     

@larsoner
Copy link
Member Author

Got a report from the user that this works so I'll merge once CIs are happy

@agramfort agramfort merged commit 9291482 into mne-tools:master May 29, 2020
@agramfort
Copy link
Member

thx heaps @larsoner !

@larsoner larsoner deleted the morph branch May 29, 2020 12:12
larsoner added a commit to larsoner/mne-python that referenced this pull request Jun 5, 2020
* upstream/master:
  DOC: Order
  added reference
  FIX: Working
  working version
  ENH: More efficient
  actually working csd, needs review
  MAINT: Update dataset and add constant test (mne-tools#7866)
  DOC: update link to glasser supplementary info; convert to footbib (mne-tools#7864)
  FIX: Fix subtract_evoked with decim (mne-tools#7855)
  FIX: Fix reading of old TFRs (mne-tools#7851)
  DOC: Add evoked movecomp to example (mne-tools#7852)
  Deprecate meg=True in pick_types (mne-tools#7823)
  ENH: Allow reading broken file (mne-tools#7846)
  MRG, ENH: Add mixed source estimate support to compute_source_morph (mne-tools#7734)
  FIX: Fix bug with metadata and event_repeated (mne-tools#7733)
  MRG, ENH: Add axes to plot_evoked_white (mne-tools#7831)
  MRG, ENH: Add example of projection to source space (mne-tools#7705)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

issue with volumetric source estimate morphing DOC: morph generated from src does not work because fwd exlcude some vertices

2 participants