Run an image-based meta-analysis (IBMA) workflow

NiMARE provides a plethora of tools for performing meta-analyses on neuroimaging data. Sometimes it’s difficult to know where to start, especially if you’re new to meta-analysis. 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

import matplotlib.pyplot as plt
from nilearn.plotting import plot_stat_map

from nimare.extract import download_nidm_pain

Download data

Load Studyset

from nimare.nimads import Studyset
from nimare.utils import get_resource_path

studyset_file = os.path.join(get_resource_path(), "nidm_pain_studyset.json")
studyset = Studyset(studyset_file, target="mni152_2mm")
studyset = studyset.update_path(dset_dir)

Run IBMA Workflow

The fit method of a IBMA workflow class runs the following steps:

  1. Runs a meta-analysis using the specified method (default: Stouffers)

  2. Applies a corrector to the meta-analysis results (default: FDRCorrector, indep)

  3. Generates cluster tables and runs diagnostics on the corrected results (default: Jackknife)

All in one call!

from nimare.workflows.ibma import IBMAWorkflow

workflow = IBMAWorkflow()
result = workflow.fit(studyset)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/transforms.py:343: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/stable/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
  infinity_norm = max(-data.min(), data.max())

  0%|          | 0/21 [00:00<?, ?it/s]
  5%|▍         | 1/21 [00:01<00:33,  1.70s/it]
 10%|▉         | 2/21 [00:02<00:21,  1.16s/it]
 14%|█▍        | 3/21 [00:03<00:17,  1.05it/s]
 19%|█▉        | 4/21 [00:03<00:14,  1.17it/s]
 24%|██▍       | 5/21 [00:04<00:12,  1.25it/s]
 29%|██▊       | 6/21 [00:05<00:11,  1.31it/s]
 33%|███▎      | 7/21 [00:05<00:10,  1.35it/s]
 38%|███▊      | 8/21 [00:06<00:09,  1.37it/s]
 43%|████▎     | 9/21 [00:07<00:08,  1.39it/s]
 48%|████▊     | 10/21 [00:08<00:07,  1.41it/s]
 52%|█████▏    | 11/21 [00:08<00:06,  1.50it/s]
 57%|█████▋    | 12/21 [00:09<00:05,  1.57it/s]
 62%|██████▏   | 13/21 [00:09<00:04,  1.62it/s]
 67%|██████▋   | 14/21 [00:10<00:04,  1.67it/s]
 71%|███████▏  | 15/21 [00:10<00:03,  1.70it/s]
 76%|███████▌  | 16/21 [00:11<00:02,  1.73it/s]
 81%|████████  | 17/21 [00:12<00:02,  1.73it/s]
 86%|████████▌ | 18/21 [00:12<00:01,  1.74it/s]
 90%|█████████ | 19/21 [00:13<00:01,  1.77it/s]
 95%|█████████▌| 20/21 [00:13<00:00,  1.76it/s]
100%|██████████| 21/21 [00:14<00:00,  1.79it/s]
100%|██████████| 21/21 [00:14<00:00,  1.47it/s]

Plot Results

The fit method of the IBMA workflow class returns a MetaResult object, where you can access the corrected results of the meta-analysis and diagnostics tables.

Corrected map:

img = result.get_map("z_corr-FDR_method-indep")
plot_stat_map(
    img,
    cut_coords=4,
    display_mode="z",
    threshold=1.65,  # voxel_thresh p < .05, one-tailed
    cmap="RdBu_r",
    symmetric_cbar=True,
    vmax=4,
)
plt.show()
12 plot ibma workflow

Clusters table

result.tables["z_corr-FDR_method-indep_tab-clust"]
Cluster ID X Y Z Peak Stat Cluster Size (mm3)
0 PositiveTail 1 36.0 2.0 6.0 16.710714 1061856
1 PositiveTail 1a 54.0 -30.0 20.0 16.214466
2 PositiveTail 1b 54.0 2.0 2.0 16.098345
3 PositiveTail 1c 42.0 12.0 -6.0 15.925786
4 PositiveTail 2 18.0 -4.0 -44.0 2.974257 336
5 PositiveTail 3 16.0 20.0 -24.0 2.902997 272
6 PositiveTail 4 40.0 -22.0 -34.0 2.550179 128
7 PositiveTail 5 -26.0 -8.0 -44.0 2.318065 120
8 NegativeTail 9 -4.0 36.0 -20.0 -9.574484 99400
9 NegativeTail 9a 2.0 30.0 -22.0 -9.047873
10 NegativeTail 9b -4.0 52.0 -14.0 -9.004929
11 NegativeTail 9c 2.0 50.0 -20.0 -8.973850
12 NegativeTail 10 -8.0 -56.0 8.0 -8.171700 22960
13 NegativeTail 10a 8.0 -54.0 8.0 -5.422620
14 NegativeTail 10b 22.0 -82.0 36.0 -4.259807
15 NegativeTail 10c 48.0 -66.0 22.0 -4.258718
16 NegativeTail 11 -24.0 -12.0 -28.0 -8.151698 11776
17 NegativeTail 11a -32.0 -36.0 -20.0 -7.748513
18 NegativeTail 12 20.0 -10.0 -28.0 -7.593386 13816
19 NegativeTail 12a 26.0 -42.0 -18.0 -6.360453
20 NegativeTail 12b 32.0 -46.0 -4.0 -4.242728
21 NegativeTail 12c 26.0 -40.0 6.0 -3.246375
22 NegativeTail 13 60.0 -4.0 22.0 -7.280138 16512
23 NegativeTail 13a 48.0 -24.0 52.0 -6.637193
24 NegativeTail 13b 58.0 -10.0 34.0 -6.139315
25 NegativeTail 13c 46.0 -18.0 44.0 -5.735124
26 NegativeTail 14 60.0 -6.0 -28.0 -7.008846 13912
27 NegativeTail 14a 58.0 -10.0 -12.0 -5.147785
28 NegativeTail 14b 66.0 -24.0 -2.0 -4.921708
29 NegativeTail 14c 56.0 2.0 -34.0 -4.714153
30 NegativeTail 15 -56.0 -14.0 -22.0 -6.957302 30408
31 NegativeTail 15a -52.0 12.0 -36.0 -6.559181
32 NegativeTail 15b -46.0 32.0 -18.0 -6.060843
33 NegativeTail 15c -54.0 -2.0 -30.0 -5.893809
34 NegativeTail 16 -50.0 -10.0 28.0 -6.665865 17496
35 NegativeTail 16a -44.0 -24.0 56.0 -5.773709
36 NegativeTail 16b -40.0 -22.0 64.0 -4.916386
37 NegativeTail 16c -66.0 -6.0 20.0 -4.629650
38 NegativeTail 17 -48.0 -66.0 26.0 -6.495798 8896
39 NegativeTail 17a -26.0 -80.0 38.0 -2.462854
40 NegativeTail 18 4.0 -28.0 60.0 -3.683875 1864
41 NegativeTail 18a 8.0 -32.0 68.0 -3.133207
42 NegativeTail 18b -6.0 -26.0 56.0 -2.093511
43 NegativeTail 19 0.0 8.0 -30.0 -3.209842 80
44 NegativeTail 20 26.0 12.0 -34.0 -2.739914 336
45 NegativeTail 20a 24.0 18.0 -28.0 -2.168240
46 NegativeTail 20b 24.0 18.0 -40.0 -2.126635
47 NegativeTail 21 28.0 26.0 -24.0 -2.736057 304
48 NegativeTail 21a 34.0 32.0 -22.0 -2.685497
49 NegativeTail 22 26.0 -64.0 60.0 -2.577298 224
50 NegativeTail 23 -20.0 -84.0 24.0 -2.560723 352
51 NegativeTail 23a -12.0 -86.0 26.0 -1.982633


Contribution table

result.tables["z_corr-FDR_method-indep_diag-Jackknife_tab-counts"]
id PositiveTail 1 PositiveTail 2 PositiveTail 3 PositiveTail 4 PositiveTail 5 NegativeTail 1 NegativeTail 2 NegativeTail 3 NegativeTail 4 NegativeTail 5 NegativeTail 6 NegativeTail 7 NegativeTail 8 NegativeTail 9 NegativeTail 10 NegativeTail 11 NegativeTail 12 NegativeTail 13 NegativeTail 14 NegativeTail 15
0 pain_01.nidm-1 0.037702 -0.002321 0.170707 0.083456 -0.030523 -0.05103 0.02644 -0.021098 -0.007002 -0.090168 -0.045255 -0.053274 -0.059515 -0.017933 -0.140079 -0.035688 0.075437 -0.155716 -0.122055 -0.198683
1 pain_02.nidm-1 0.032257 0.078942 0.253983 0.057438 0.058141 -0.071588 -0.083544 -0.077157 -0.066125 -0.122484 -0.09464 -0.058429 -0.134813 -0.042824 -0.145981 -0.034273 0.058662 -0.088369 -0.117006 -0.233129
2 pain_03.nidm-1 0.02838 0.023786 0.150012 -0.04117 -0.123129 -0.07293 0.02984 0.004297 0.009281 0.035356 -0.056233 -0.081246 -0.073559 0.019033 -0.000768 -0.036754 -0.04324 -0.176276 -0.130693 0.091747
3 pain_04.nidm-1 -0.025585 0.040985 -0.002044 0.088042 -0.117824 -0.005459 0.097036 0.062403 0.058625 0.108342 0.010716 0.012863 0.027043 0.136092 0.053912 -0.036641 0.087825 -0.138881 0.006323 0.21312
4 pain_05.nidm-1 0.025307 -0.006174 0.024448 -0.033631 0.084559 -0.013106 -0.036647 -0.036442 -0.025266 -0.082886 -0.015853 -0.016036 -0.033943 -0.084869 -0.012022 0.112066 -0.057792 0.051314 -0.069776 0.041376
5 pain_06.nidm-1 0.050093 -0.018995 -0.029478 -0.066757 0.062807 -0.045397 -0.120061 -0.050577 -0.036651 -0.111979 -0.040202 -0.084707 -0.080674 -0.162844 -0.16973 -0.038218 0.06206 -0.117627 -0.075649 -0.019389
6 pain_07.nidm-1 0.032829 -0.135447 -0.036717 0.065454 -0.155733 -0.037382 -0.165921 -0.083702 -0.099395 -0.077899 -0.027086 -0.046114 -0.091848 -0.11303 -0.212314 -0.05395 0.058369 0.039826 -0.106714 -0.300477
7 pain_08.nidm-1 0.00367 -0.028549 -0.084927 -0.04528 -0.022939 0.110727 0.140988 0.078716 0.07518 0.139969 0.085293 0.097335 0.131552 0.065949 -0.025456 0.133535 0.212785 0.191002 0.099196 0.319061
8 pain_09.nidm-1 0.005541 0.074238 -0.048318 0.027936 0.084793 0.087108 0.090306 0.043164 0.045494 0.164992 0.106973 0.119762 0.165479 0.036086 0.03842 0.146956 -0.01373 0.071557 -0.014304 0.344982
9 pain_10.nidm-1 -0.000495 0.038081 0.010147 -0.007008 -0.047505 0.126262 0.159605 0.109278 0.078003 0.119073 0.174125 0.135353 0.115972 0.115357 0.057379 0.145701 0.135157 0.254549 0.170313 0.250734
10 pain_11.nidm-1 0.046699 -0.083713 -0.069433 0.000852 -0.029381 -0.013649 -0.050737 -0.003914 -0.007507 0.007086 -0.020742 0.005894 -0.023801 -0.070214 -0.125942 0.055166 0.000549 0.005611 -0.103143 -0.057497
11 pain_12.nidm-1 0.04417 0.210972 0.116982 0.104871 0.230345 0.032431 0.090525 0.047509 0.072702 0.052657 0.086524 0.062406 0.04597 0.096261 0.193968 0.08838 0.008848 -0.073786 0.074773 0.134344
12 pain_13.nidm-1 0.007562 -0.059168 -0.041623 -0.099792 -0.018643 0.163787 0.23263 0.180297 0.129013 0.159725 0.198071 0.205265 0.229911 0.258383 0.293326 0.021038 0.137491 0.214641 0.361255 0.221756
13 pain_14.nidm-1 0.084724 0.057086 -0.025736 -0.095017 -0.028848 0.033356 -0.004088 0.022402 0.011864 0.101467 -0.002955 -0.013644 0.072163 0.034369 0.190402 -0.007873 -0.205688 0.072748 -0.069458 -0.067954
14 pain_15.nidm-1 0.025091 0.078256 0.017476 0.120519 0.228948 0.058013 0.07303 0.101392 0.122722 0.065152 0.065605 0.081342 0.041947 0.079765 0.081738 0.0 0.050296 0.116316 0.279218 -0.035744
15 pain_16.nidm-1 0.014416 0.039934 0.004747 0.124582 0.115977 0.091991 0.066204 0.133499 0.143566 0.054568 0.098076 0.10439 0.055154 0.109161 0.175938 0.006828 0.052642 0.169448 0.272253 -0.070279
16 pain_17.nidm-1 0.044687 0.024318 0.035326 -0.015338 0.19009 -0.03029 -0.046245 -0.033792 -0.044069 -0.060472 -0.027704 -0.017195 -0.087937 -0.055395 -0.118726 0.00349 -0.057193 -0.121039 -0.087791 0.094566
17 pain_18.nidm-1 -0.021305 0.065969 -0.003564 0.026746 0.021808 0.025059 0.03141 0.02637 0.040584 0.023917 0.001983 0.020814 0.027843 -0.015927 -0.009159 0.0 -0.032395 0.056859 -0.011262 -0.013015
18 pain_19.nidm-1 0.012699 0.071969 0.030551 0.096083 0.011731 0.066879 0.111472 0.044436 0.065974 0.000253 0.040533 0.045047 0.122527 0.129918 0.223884 0.049031 0.053487 0.032499 0.266334 0.020492
19 pain_20.nidm-1 0.051316 0.045315 0.056967 0.121528 0.033221 -0.02662 -0.111797 -0.054318 -0.053412 -0.041898 -0.084007 -0.059971 -0.03492 -0.059678 -0.026156 0.0 -0.05758 -0.004282 -0.147054 -0.154455
20 pain_21.nidm-1 0.006431 -0.009265 -0.022976 -0.007414 -0.04035 0.07799 -0.024349 0.013339 -0.007483 0.061334 0.052922 0.046273 0.09155 0.048442 0.183465 -0.010056 -0.019736 0.105706 0.031338 -0.075458


Report

Finally, a NiMARE report is generated from the MetaResult.

from nimare.reports.base import run_reports

# root_dir = Path(os.getcwd()).parents[1] / "docs" / "_build"
# Use the previous root to run the documentation locally.
root_dir = Path(os.getcwd()).parents[1] / "_readthedocs"
html_dir = root_dir / "html" / "auto_examples" / "02_meta-analyses" / "12_plot_ibma_workflow"
html_dir.mkdir(parents=True, exist_ok=True)

run_reports(result, html_dir)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/stable/nimare/reports/figures.py:688: UserWarning: kwargs['alpha']=0.7 detected in parameters.
Overriding with transparency=None.
To suppress this warning pass your 'alpha' value via the 'transparency' parameter.
  fig = plot_img(

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

Gallery generated by Sphinx-Gallery