8.2.8. Controling the contrast of the background when plottingΒΆ

The dim argument controls the contrast of the background.

dim modifies the contrast of this image: dim=0 leaves the image unchanged, negative values of dim enhance it, and positive values decrease it (dim the background).

This dim argument may also be useful for the plot_roi function used to display ROIs on top of a background image.

  • ../../_images/sphx_glr_plot_dim_plotting_001.png
  • ../../_images/sphx_glr_plot_dim_plotting_002.png
  • ../../_images/sphx_glr_plot_dim_plotting_003.png
  • ../../_images/sphx_glr_plot_dim_plotting_004.png
# Retrieve the data: the localizer dataset with contrast maps

from nilearn import datasets

localizer_dataset = datasets.fetch_localizer_button_task(get_anats=True)
localizer_anat_filename = localizer_dataset.anats[0]
localizer_tmap_filename = localizer_dataset.tmaps[0]

# Plotting: vary the 'dim' of the background
from nilearn import plotting

plotting.plot_stat_map(localizer_tmap_filename,
                       bg_img=localizer_anat_filename,
                       cut_coords=(36, -27, 66),
                       threshold=3, title="dim=-.5",
                       dim=-.5)

plotting.plot_stat_map(localizer_tmap_filename,
                       bg_img=localizer_anat_filename,
                       cut_coords=(36, -27, 66),
                       threshold=3, title="dim=0",
                       dim=0)

plotting.plot_stat_map(localizer_tmap_filename,
                       bg_img=localizer_anat_filename,
                       cut_coords=(36, -27, 66),
                       threshold=3, title="dim=.5",
                       dim=.5)

plotting.plot_stat_map(localizer_tmap_filename,
                       bg_img=localizer_anat_filename,
                       cut_coords=(36, -27, 66),
                       threshold=3, title="dim=1",
                       dim=1)

plotting.show()

Total running time of the script: ( 0 minutes 3.277 seconds)

Generated by Sphinx-Gallery