def test_fetch_parcellations(tmpdir): """Test fetching parcellations.""" this_subjects_dir = str(tmpdir) os.mkdir(op.join(this_subjects_dir, 'fsaverage')) os.mkdir(op.join(this_subjects_dir, 'fsaverage', 'label')) os.mkdir(op.join(this_subjects_dir, 'fsaverage', 'surf')) for hemi in ('lh', 'rh'): shutil.copyfile( op.join(subjects_dir, 'fsaverage', 'surf', '%s.white' % hemi), op.join(this_subjects_dir, 'fsaverage', 'surf', '%s.white' % hemi)) # speed up by prenteding we have one of them with open(op.join(this_subjects_dir, 'fsaverage', 'label', 'lh.aparc_sub.annot'), 'wb'): pass datasets.fetch_aparc_sub_parcellation(subjects_dir=this_subjects_dir) with ArgvSetter(('--accept-hcpmmp-license',)): datasets.fetch_hcp_mmp_parcellation(subjects_dir=this_subjects_dir) for hemi in ('lh', 'rh'): assert op.isfile(op.join(this_subjects_dir, 'fsaverage', 'label', '%s.aparc_sub.annot' % hemi)) # test our annot round-trips here kwargs = dict(subject='fsaverage', hemi='both', sort=False, subjects_dir=this_subjects_dir) labels = read_labels_from_annot(parc='HCPMMP1', **kwargs) write_labels_to_annot( labels, parc='HCPMMP1_round', table_name='./left.fsaverage164.label.gii', **kwargs) orig = op.join(this_subjects_dir, 'fsaverage', 'label', 'lh.HCPMMP1.annot') first = hashfunc(orig) new = orig[:-6] + '_round.annot' second = hashfunc(new) assert first == second
def test_fetch_parcellations(tmpdir): """Test fetching parcellations.""" this_subjects_dir = str(tmpdir) os.mkdir(op.join(this_subjects_dir, 'fsaverage')) os.mkdir(op.join(this_subjects_dir, 'fsaverage', 'label')) os.mkdir(op.join(this_subjects_dir, 'fsaverage', 'surf')) for hemi in ('lh', 'rh'): shutil.copyfile( op.join(subjects_dir, 'fsaverage', 'surf', '%s.white' % hemi), op.join(this_subjects_dir, 'fsaverage', 'surf', '%s.white' % hemi)) # speed up by prenteding we have one of them with open( op.join(this_subjects_dir, 'fsaverage', 'label', 'lh.aparc_sub.annot'), 'wb'): pass datasets.fetch_aparc_sub_parcellation(subjects_dir=this_subjects_dir) try: sys.argv.append('--accept-hcpmmp-license') datasets.fetch_hcp_mmp_parcellation(subjects_dir=this_subjects_dir) finally: sys.argv.pop(-1) for hemi in ('lh', 'rh'): assert op.isfile( op.join(this_subjects_dir, 'fsaverage', 'label', '%s.aparc_sub.annot' % hemi))
def test_fetch_parcellations(tmpdir): """Test fetching parcellations.""" this_subjects_dir = str(tmpdir) os.mkdir(op.join(this_subjects_dir, 'fsaverage')) os.mkdir(op.join(this_subjects_dir, 'fsaverage', 'label')) os.mkdir(op.join(this_subjects_dir, 'fsaverage', 'surf')) for hemi in ('lh', 'rh'): shutil.copyfile( op.join(subjects_dir, 'fsaverage', 'surf', '%s.white' % hemi), op.join(this_subjects_dir, 'fsaverage', 'surf', '%s.white' % hemi)) # speed up by prenteding we have one of them with open(op.join(this_subjects_dir, 'fsaverage', 'label', 'lh.aparc_sub.annot'), 'wb'): pass datasets.fetch_aparc_sub_parcellation(subjects_dir=this_subjects_dir) with ArgvSetter(('--accept-hcpmmp-license',)): datasets.fetch_hcp_mmp_parcellation(subjects_dir=this_subjects_dir) for hemi in ('lh', 'rh'): assert op.isfile(op.join(this_subjects_dir, 'fsaverage', 'label', '%s.aparc_sub.annot' % hemi))
import numpy as np import matplotlib.pyplot as plt import mne from mne.datasets import sample, fetch_hcp_mmp_parcellation from mne.minimum_norm import apply_inverse, read_inverse_operator from mne import read_evokeds data_path = sample.data_path() sample_dir = op.join(data_path, 'MEG', 'sample') subjects_dir = op.join(data_path, 'subjects') fname_evoked = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif') fname_stc = op.join(sample_dir, 'sample_audvis-meg') fetch_hcp_mmp_parcellation(subjects_dir) # %% # Then, we read the stc from file. stc = mne.read_source_estimate(fname_stc, subject='sample') # %% # This is a :class:`SourceEstimate <mne.SourceEstimate>` object. print(stc) # %% # The SourceEstimate object is in fact a *surface* source estimate. MNE also # supports volume-based source estimates but more on that later. # # We can plot the source estimate using the # :func:`stc.plot <mne.SourceEstimate.plot>` just as in other MNE