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))