Exemple #1
0
qe = mv.SurfaceQueryEngine(surf, radius=radii, distance_metric='dijkstra')
sl = mv.Searchlight(cv, queryengine=qe, roi_ids=cortical_vertices)
sl_q2 = sl(ds_q2)

# 4. save output _______________________________________________________________________
if not os.path.exists(
        os.path.join(main_dir, 'analysis', 'searchlight', sub_name)):
    os.makedirs(os.path.join(main_dir, 'analysis', 'searchlight', sub_name))

# save as NIML dataset
niml_q1_filename = os.path.join(
    main_dir, 'analysis', 'searchlight', sub_name, sub_name + '_ques-02_' +
    hemisphere + '_searchlight_radii-' + str(radii) + '.niml.dset')
mv.niml.write(niml_q1_filename, sl_q2)

# save as GIFTI sub-rid000001_ques-01_lh_searchlight_radii-10
searchlight_q1_filename = os.path.join(
    main_dir, 'analysis', 'searchlight', sub_name, sub_name + '_ques-02_' +
    hemisphere + '_searchlight_radii-' + str(radii) + '.gii')
nimg = mv.map2gifti(sl_q2,
                    filename,
                    encoding='GIFTI_ENCODING_B64GZ',
                    surface=surf)

# **** helpful resources _______________________________________________________________
# generating dataset:
# http://www.pymvpa.org/tutorial_mappers.html
# saving output:
# http://www.pymvpa.org/examples/searchlight_surf.html
#
assert sl_final.shape == (1, n_vertices)

# 4. save output _______________________________________________________________________
if not os.path.exists(
        os.path.join(main_dir, 'analysis', 'searchlight', sub_name)):
    os.makedirs(os.path.join(main_dir, 'analysis', 'searchlight', sub_name))

# save as NIML dataset
niml_q3_filename = os.path.join(
    main_dir, 'analysis', 'searchlight', sub_name,
    sub_name + '_ques-03_task-' + task_name + '_' + hemisphere +
    '_searchlight_radii-' + str(radii) + '.niml.dset')
mv.niml.write(niml_q3_filename, sl_final)

# save as GIFTI sub-rid000001_ques-01_task-beh_lh_searchlight_radii-10
searchlight_q3_filename = os.path.join(
    main_dir, 'analysis', 'searchlight', sub_name,
    sub_name + '_ques-03_task-' + task_name + '_' + hemisphere +
    '_searchlight_radii-' + str(radii) + '.gii')
nimg = mv.map2gifti(sl_final,
                    searchlight_q3_filename,
                    encoding='GIFTI_ENCODING_B64GZ',
                    surface=surf)

# **** helpful resources _______________________________________________________________
# generating dataset:
# http://www.pymvpa.org/tutorial_mappers.html
# saving output:
# http://www.pymvpa.org/examples/searchlight_surf.html
#