diff --git a/examples/02_meta-analyses/01_plot_cbma.py b/examples/02_meta-analyses/01_plot_cbma.py index 93cb6c403..85a89f1d1 100644 --- a/examples/02_meta-analyses/01_plot_cbma.py +++ b/examples/02_meta-analyses/01_plot_cbma.py @@ -13,6 +13,7 @@ For a more detailed introduction to the elements of a coordinate-based meta-analysis, see other stuff. """ + ############################################################################### # Load Dataset # ----------------------------------------------------------------------------- @@ -57,6 +58,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) plot_stat_map( @@ -64,6 +66,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) @@ -87,12 +90,14 @@ results.get_map("z_desc-uniformity"), draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) plot_stat_map( cres.get_map("z_desc-uniformitySize_level-cluster_corr-FWE_method-montecarlo"), draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) @@ -117,6 +122,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) plot_stat_map( @@ -124,6 +130,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) @@ -148,6 +155,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) plot_stat_map( @@ -155,6 +163,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) @@ -200,6 +209,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.1, ) diff --git a/examples/02_meta-analyses/02_plot_ibma.py b/examples/02_meta-analyses/02_plot_ibma.py index 1eac8a7c0..6d0d4458d 100644 --- a/examples/02_meta-analyses/02_plot_ibma.py +++ b/examples/02_meta-analyses/02_plot_ibma.py @@ -13,6 +13,7 @@ For a more detailed introduction to the elements of an image-based meta-analysis, see other stuff. """ + from nilearn.plotting import plot_stat_map ############################################################################### @@ -56,6 +57,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) print("Description:") @@ -74,6 +76,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) print("Description:") @@ -94,6 +97,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) print("Description:") @@ -115,6 +119,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) corrector = FWECorrector(method="montecarlo", n_iters=100, n_cores=1) @@ -125,6 +130,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) print("Description:") @@ -145,6 +151,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) print("Description:") @@ -165,6 +172,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) print("Description:") @@ -185,6 +193,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) print("Description:") diff --git a/examples/02_meta-analyses/03_plot_kernel_transformers.py b/examples/02_meta-analyses/03_plot_kernel_transformers.py index 50a162f5d..f0d3232ff 100644 --- a/examples/02_meta-analyses/03_plot_kernel_transformers.py +++ b/examples/02_meta-analyses/03_plot_kernel_transformers.py @@ -17,6 +17,7 @@ This example provides an introduction to the ``KernelTransformer`` class and a tour of available types. """ + # sphinx_gallery_thumbnail_number = 2 import os @@ -99,6 +100,7 @@ annotate=False, colorbar=False, cmap="RdBu_r", + symmetric_cbar=True, ) ############################################################################### @@ -115,6 +117,7 @@ title="MKDA", draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) ############################################################################### @@ -131,6 +134,7 @@ title="KDA", draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) ############################################################################### @@ -150,4 +154,5 @@ title="ALE", draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) diff --git a/examples/02_meta-analyses/05_plot_correctors.py b/examples/02_meta-analyses/05_plot_correctors.py index cdd1271a2..83961e0a6 100644 --- a/examples/02_meta-analyses/05_plot_correctors.py +++ b/examples/02_meta-analyses/05_plot_correctors.py @@ -8,6 +8,7 @@ Here we take a look at multiple comparisons correction in meta-analyses. """ + from pprint import pprint import matplotlib.pyplot as plt @@ -119,6 +120,7 @@ cres.get_map(map_name), draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.5, cut_coords=[0, 0, -8], figure=fig, @@ -157,6 +159,7 @@ cres.get_map("z"), draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.5, cut_coords=[0, 0, -8], figure=fig, @@ -167,6 +170,7 @@ cres.get_map("z_corr-FDR_method-indep"), draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, threshold=0.5, cut_coords=[0, 0, -8], figure=fig, diff --git a/examples/02_meta-analyses/06_plot_compare_ibma_and_cbma.py b/examples/02_meta-analyses/06_plot_compare_ibma_and_cbma.py index 433389b51..d43f01576 100644 --- a/examples/02_meta-analyses/06_plot_compare_ibma_and_cbma.py +++ b/examples/02_meta-analyses/06_plot_compare_ibma_and_cbma.py @@ -11,6 +11,7 @@ Collection of NIDM-Results packs downloaded from Neurovault collection 1425, uploaded by Dr. Camille Maumet. """ + import os import pandas as pd @@ -53,6 +54,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) ############################################################################### @@ -65,6 +67,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) ############################################################################### diff --git a/examples/02_meta-analyses/07_macm.py b/examples/02_meta-analyses/07_macm.py index 07b4a9d92..d73691320 100644 --- a/examples/02_meta-analyses/07_macm.py +++ b/examples/02_meta-analyses/07_macm.py @@ -12,6 +12,7 @@ analysis in which task-independent "connectivity" is assessed by selecting studies within a larger database based on locations of report coordinates. """ + import nibabel as nib import numpy as np from nilearn import datasets, image, plotting @@ -71,6 +72,7 @@ threshold=3.09, draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, ) ############################################################################### @@ -85,4 +87,4 @@ xyz = dset.coordinates[["x", "y", "z"]].values scale = SCALE(xyz=xyz, n_iters=10000, n_cores=1, kernel__n=20) results = scale.fit(dset_sel) -plotting.plot_stat_map(results.get_map("z"), draw_cross=False, cmap="RdBu_r") +plotting.plot_stat_map(results.get_map("z"), draw_cross=False, cmap="RdBu_r", symmetric_cbar=True) diff --git a/examples/02_meta-analyses/08_plot_cbma_subtraction_conjunction.py b/examples/02_meta-analyses/08_plot_cbma_subtraction_conjunction.py index dd6bc02c3..5f544d87a 100644 --- a/examples/02_meta-analyses/08_plot_cbma_subtraction_conjunction.py +++ b/examples/02_meta-analyses/08_plot_cbma_subtraction_conjunction.py @@ -19,6 +19,7 @@ 5. Compare the two samples with a subtraction analysis. 6. Compare the two within-sample meta-analyses with a conjunction analysis. """ + import os from pathlib import Path @@ -71,6 +72,7 @@ title="Semantic knowledge", threshold=2.326, # cluster-level p < .01, one-tailed cmap="RdBu_r", + symmetric_cbar=True, vmax=4, axes=axes[0], figure=fig, @@ -86,6 +88,7 @@ title="Semantic relatedness", threshold=2.326, # cluster-level p < .01, one-tailed cmap="RdBu_r", + symmetric_cbar=True, vmax=4, axes=axes[1], figure=fig, @@ -189,6 +192,7 @@ title="Conjunction", threshold=2.326, # cluster-level p < .01, one-tailed cmap="RdBu_r", + symmetric_cbar=True, vmax=4, ) diff --git a/examples/02_meta-analyses/10_plot_cbma_workflow.py b/examples/02_meta-analyses/10_plot_cbma_workflow.py index d153727a5..5b0bbdccf 100644 --- a/examples/02_meta-analyses/10_plot_cbma_workflow.py +++ b/examples/02_meta-analyses/10_plot_cbma_workflow.py @@ -11,6 +11,7 @@ This tutorial will walk you through using a CBMA workflow function which puts together the fundamental steps of a CBMA meta-analysis. """ + import os from pathlib import Path @@ -62,6 +63,7 @@ display_mode="z", threshold=1.65, # voxel_thresh p < .05, one-tailed cmap="RdBu_r", + symmetric_cbar=True, vmax=4, ) plt.show() diff --git a/examples/02_meta-analyses/11_plot_cbmr.py b/examples/02_meta-analyses/11_plot_cbmr.py index e3ac5e248..2740b8303 100644 --- a/examples/02_meta-analyses/11_plot_cbmr.py +++ b/examples/02_meta-analyses/11_plot_cbmr.py @@ -113,6 +113,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Schizophrenia with drug treatment", threshold=1e-4, vmax=1e-3, @@ -122,6 +123,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Schizophrenia without drug treatment", threshold=1e-4, vmax=1e-3, @@ -131,6 +133,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Depression with drug treatment", threshold=1e-4, vmax=1e-3, @@ -140,6 +143,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Depression without drug treatment", threshold=1e-4, vmax=1e-3, @@ -173,6 +177,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="SchizophreniaYes", threshold=scipy.stats.norm.isf(0.05), vmax=30, @@ -183,6 +188,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="SchizophreniaNo", threshold=scipy.stats.norm.isf(0.05), vmax=30, @@ -193,6 +199,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="DepressionYes", threshold=scipy.stats.norm.isf(0.05), vmax=30, @@ -203,6 +210,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="DepressionNo", threshold=scipy.stats.norm.isf(0.05), vmax=30, @@ -235,6 +243,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Schizophrenia with drug treatment (FDR corrected)", threshold=scipy.stats.norm.isf(0.05), vmax=30, @@ -245,6 +254,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Schizophrenia without drug treatment (FDR corrected)", threshold=scipy.stats.norm.isf(0.05), vmax=30, @@ -255,6 +265,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Depression with drug treatment (FDR corrected)", threshold=scipy.stats.norm.isf(0.05), vmax=30, @@ -265,6 +276,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Depression without drug treatment (FDR corrected)", threshold=scipy.stats.norm.isf(0.05), vmax=30, @@ -300,6 +312,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Drug Treatment Effect for Schizophrenia", threshold=scipy.stats.norm.isf(0.4), vmax=2, @@ -310,6 +323,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Untreated Schizophrenia vs. Untreated Depression", threshold=scipy.stats.norm.isf(0.4), vmax=2, @@ -320,6 +334,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="Drug Treatment Effect for Depression", threshold=scipy.stats.norm.isf(0.4), vmax=2, @@ -365,6 +380,7 @@ cut_coords=[0, 0, -8], draw_cross=False, cmap="RdBu_r", + symmetric_cbar=True, title="GLH_groups_0", threshold=scipy.stats.norm.isf(0.4), ) diff --git a/examples/02_meta-analyses/12_plot_ibma_workflow.py b/examples/02_meta-analyses/12_plot_ibma_workflow.py index a98beed41..ea0899a39 100644 --- a/examples/02_meta-analyses/12_plot_ibma_workflow.py +++ b/examples/02_meta-analyses/12_plot_ibma_workflow.py @@ -11,6 +11,7 @@ This tutorial will walk you through using a IBMA workflow function which puts together the fundamental steps of a IBMA meta-analysis. """ + import os from pathlib import Path @@ -64,6 +65,7 @@ display_mode="z", threshold=1.65, # voxel_thresh p < .05, one-tailed cmap="RdBu_r", + symmetric_cbar=True, vmax=4, ) plt.show() diff --git a/examples/03_annotation/04_plot_gclda.py b/examples/03_annotation/04_plot_gclda.py index f6da02b39..7396625fe 100644 --- a/examples/03_annotation/04_plot_gclda.py +++ b/examples/03_annotation/04_plot_gclda.py @@ -15,6 +15,7 @@ If you are interested in using GCLDA, we recommend using a large dataset like Neurosynth, and training with at least 10k iterations. """ + import os import nibabel as nib @@ -81,6 +82,7 @@ draw_cross=False, colorbar=False, annotate=False, + symmetric_cbar=True, title=f"Topic {i_topic + 1}", ) @@ -89,7 +91,7 @@ # ----------------------------------------------------------------------------- text = "dorsal anterior cingulate cortex" encoded_img, _ = decode.encode.gclda_encode(model, text) -plotting.plot_stat_map(encoded_img, draw_cross=False) +plotting.plot_stat_map(encoded_img, draw_cross=False, symmetric_cbar=True) ############################################################################### # diff --git a/nimare/reports/figures.py b/nimare/reports/figures.py index 4e896a51b..44f038d50 100644 --- a/nimare/reports/figures.py +++ b/nimare/reports/figures.py @@ -139,6 +139,7 @@ def plot_static_brain(img, out_filename, threshold=1e-06): draw_cross=False, threshold=threshold, display_mode="mosaic", + symmetric_cbar=True, ) fig.savefig(out_filename, dpi=300) fig.close() @@ -270,7 +271,13 @@ def plot_interactive_brain(img, out_filename, threshold=1e-06): _check_extention(out_filename, [".html"]) template = datasets.load_mni152_template(resolution=1) - html_view = view_img(img, bg_img=template, black_bg=False, threshold=threshold) + html_view = view_img( + img, + bg_img=template, + black_bg=False, + threshold=threshold, + symmetric_cbar=True, + ) html_view.save_as_html(out_filename) @@ -608,6 +615,7 @@ def _plot_relcov_map(maps_arr, masker, out_filename): alpha=0.7, colorbar=True, cmap="Blues", + symmetric_cbar=False, vmin=0, vmax=1, display_mode="mosaic", @@ -637,6 +645,7 @@ def _plot_dof_map(dof_map, out_filename): alpha=0.7, colorbar=True, cmap="YlOrRd", + symmetric_cbar=False, vmin=0, display_mode="mosaic", )