Exemple #1
0
                            title='Surface right hemisphere: fine mesh',
                            threshold=1.,
                            bg_map=big_fsaverage.sulc_right)

##############################################################################
# Plot multiple views of the 3D volume on a surface
# -------------------------------------------------
#
# :func:`~nilearn.plotting.plot_img_on_surf` takes a statistical map and
# projects it onto a surface. It supports multiple choices of orientations,
# and can plot either one or both hemispheres. If no ``surf_mesh`` is given,
# :func:`~nilearn.plotting.plot_img_on_surf` projects the images onto
# `FreeSurfer <https://surfer.nmr.mgh.harvard.edu/>`_\'s fsaverage5.

plotting.plot_img_on_surf(stat_img,
                          views=['lateral', 'medial'],
                          hemispheres=['left', 'right'],
                          colorbar=True)
plotting.show()

##############################################################################
# 3D visualization in a web browser
# ---------------------------------
#
# An alternative to :func:`nilearn.plotting.plot_surf_stat_map` is to use
# :func:`nilearn.plotting.view_surf` or
# :func:`nilearn.plotting.view_img_on_surf` that give more interactive
# visualizations in a web browser. See :ref:`interactive-surface-plotting` for
# more details.

view = plotting.view_surf(fsaverage.infl_right,
                          texture,
Exemple #2
0
files = [
    files for files in os.listdir(base_dir)
    if ('masked.nii.gz' in files) and (not '._' in files)
]
paths = [base_dir + '/' + s for s in files]

for i in range(len(paths)):
    img = load_img(paths[i])
    data = img.get_fdata()
    min_thr = min(abs(data[abs(data) > 0]))
    title = files[i].replace('_masked.nii.gz', '').replace('results_', '')
    view = plotting.view_img_on_surf(img, threshold=min_thr, title=title)
    out_file = base_dir + '/results_images/' + files[i].replace(
        '.nii.gz', '.html')
    view.save_as_html(out_file)

for i in range(len(paths)):
    img = load_img(paths[i])
    data = img.get_fdata()
    min_thr = min(abs(data[abs(data) > 0]))
    title = files[i].replace('_masked.nii.gz', '').replace('results_', '')
    out_file = base_dir + '/results_images/' + files[i].replace(
        '.nii.gz', '.svg')
    plotting.plot_img_on_surf(img,
                              views=['lateral', 'medial'],
                              hemispheres=['left', 'right'],
                              colorbar=True,
                              threshold=min_thr,
                              output_file=out_file,
                              title=title)