Run a coordinate-based meta-analysis (CBMA) 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 CBMA workflow function which puts together the fundamental steps of a CBMA meta-analysis.

import os
from pathlib import Path

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

from nimare.dataset import Dataset
from nimare.reports.base import run_reports
from nimare.utils import get_resource_path
from nimare.workflows.cbma import CBMAWorkflow

Load Dataset

Run CBMA Workflow

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

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

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

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

All in one call!

result = CBMAWorkflow().fit(dset)

For this example, we use an FDR correction because the default corrector (FWE correction with Monte Carlo simulation) takes a long time to run due to the high number of iterations that are required

workflow = CBMAWorkflow(corrector="fdr")
result = workflow.fit(dset)
  0%|          | 0/21 [00:00<?, ?it/s]
  5%|▍         | 1/21 [00:02<00:42,  2.13s/it]
 10%|▉         | 2/21 [00:04<00:40,  2.14s/it]
 14%|█▍        | 3/21 [00:06<00:38,  2.14s/it]
 19%|█▉        | 4/21 [00:08<00:36,  2.15s/it]
 24%|██▍       | 5/21 [00:10<00:34,  2.15s/it]
 29%|██▊       | 6/21 [00:12<00:32,  2.15s/it]
 33%|███▎      | 7/21 [00:15<00:30,  2.15s/it]
 38%|███▊      | 8/21 [00:17<00:27,  2.13s/it]
 43%|████▎     | 9/21 [00:19<00:25,  2.12s/it]
 48%|████▊     | 10/21 [00:21<00:23,  2.10s/it]
 52%|█████▏    | 11/21 [00:23<00:21,  2.11s/it]
 57%|█████▋    | 12/21 [00:25<00:18,  2.10s/it]
 62%|██████▏   | 13/21 [00:27<00:16,  2.10s/it]
 67%|██████▋   | 14/21 [00:29<00:14,  2.11s/it]
 71%|███████▏  | 15/21 [00:31<00:12,  2.10s/it]
 76%|███████▌  | 16/21 [00:33<00:10,  2.09s/it]
 81%|████████  | 17/21 [00:35<00:08,  2.09s/it]
 86%|████████▌ | 18/21 [00:38<00:06,  2.09s/it]
 90%|█████████ | 19/21 [00:40<00:04,  2.08s/it]
 95%|█████████▌| 20/21 [00:42<00:02,  2.08s/it]
100%|██████████| 21/21 [00:44<00:00,  2.08s/it]
100%|██████████| 21/21 [00:44<00:00,  2.11s/it]

Plot Results

The fit method of the CBMA 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()
10 plot cbma 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 38.0 4.0 2.0 4.837038 6912
1 PositiveTail 1a 38.0 14.0 -6.0 4.138394
2 PositiveTail 1b 34.0 20.0 0.0 3.978528
3 PositiveTail 1c 38.0 -10.0 -6.0 2.873938
4 PositiveTail 2 54.0 -28.0 20.0 4.309257 1736
5 PositiveTail 3 -34.0 14.0 0.0 4.138394 1280
6 PositiveTail 4 2.0 4.0 52.0 3.719572 5760
7 PositiveTail 4a -6.0 8.0 42.0 3.428444
8 PositiveTail 4b 2.0 -4.0 64.0 2.994763
9 PositiveTail 4c -8.0 14.0 34.0 2.952426
10 PositiveTail 5 -32.0 -60.0 -34.0 3.470566 2880
11 PositiveTail 5a -26.0 -66.0 -38.0 2.693224
12 PositiveTail 5b -28.0 -58.0 -46.0 2.268818
13 PositiveTail 6 -62.0 -22.0 20.0 2.968374 1832
14 PositiveTail 6a -54.0 -32.0 22.0 2.840638
15 PositiveTail 6b -64.0 -22.0 28.0 2.299591
16 PositiveTail 7 -36.0 4.0 -16.0 2.809475 552
17 PositiveTail 8 20.0 -102.0 -4.0 2.716632 496
18 PositiveTail 9 -6.0 -48.0 54.0 2.462465 576
19 PositiveTail 10 -4.0 -70.0 50.0 2.228337 168
20 PositiveTail 11 -36.0 -22.0 10.0 2.228337 208
21 PositiveTail 12 -46.0 -58.0 -54.0 2.213906 128
22 PositiveTail 13 36.0 -18.0 12.0 2.205878 112
23 PositiveTail 14 -34.0 -90.0 -12.0 2.194827 152
24 PositiveTail 15 -54.0 -66.0 2.0 2.135190 248
25 PositiveTail 16 -52.0 -8.0 6.0 2.106963 88
26 PositiveTail 17 10.0 -68.0 36.0 2.087058 176
27 PositiveTail 18 36.0 40.0 30.0 1.973495 88


Contribution table

result.tables["z_corr-FDR_method-indep_diag-Jackknife_tab-counts_tail-positive"]
id PositiveTail 1 PositiveTail 2 PositiveTail 3 PositiveTail 4 PositiveTail 5 PositiveTail 6 PositiveTail 7 PositiveTail 8 PositiveTail 9 PositiveTail 10 PositiveTail 11 PositiveTail 12 PositiveTail 13 PositiveTail 14 PositiveTail 15 PositiveTail 16 PositiveTail 17 PositiveTail 18
0 pain_01.nidm-1 0.034983 0.0 0.0 0.0 0.071489 0.0 0.0 0.062549 0.0 0.0 0.0 0.000003 0.000075 0.0 0.117396 0.0 0.0 0.0
1 pain_02.nidm-1 0.000005 0.141261 0.00003 0.0 0.0 0.0 0.317441 0.000014 0.0 0.0 0.0 0.0 0.526 0.0 0.0 0.0 0.0 0.548724
2 pain_03.nidm-1 0.025369 0.0 0.0 0.137756 0.1153 0.0 0.0 0.383157 0.0 0.0 0.0 0.0 0.0 0.488295 0.0 0.000005 0.0 0.0
3 pain_04.nidm-1 0.08195 0.231971 0.194216 0.112993 0.079311 0.0 0.276962 0.396489 0.0 0.0 0.0 0.0 0.470476 0.445865 0.0 0.0 0.0 0.0
4 pain_05.nidm-1 0.093247 0.0 0.038346 0.084423 0.123392 0.0 0.087439 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
5 pain_06.nidm-1 0.0 0.0 0.000068 0.038829 0.0 0.0 0.01977 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.01921
6 pain_07.nidm-1 0.0 0.0 0.0 0.0 0.016125 0.0 0.0 0.0 0.000017 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
7 pain_08.nidm-1 0.000006 0.148582 0.0 0.043043 0.111489 0.0 0.0 0.0 0.206307 0.48905 0.000097 0.50184 0.0 0.0 0.0 0.0 0.015779 0.14146
8 pain_09.nidm-1 0.001841 0.0 0.0 0.0 0.06279 0.0 0.0 0.0 0.129468 0.000042 0.0 0.494551 0.0 0.0 0.0 0.0 0.0 0.28749
9 pain_10.nidm-1 0.076135 0.141862 0.0 0.021402 0.116449 0.055756 0.0 0.0 0.000088 0.364769 0.0 0.000654 0.000001 0.0 0.0 0.0 0.000003 0.0
10 pain_11.nidm-1 0.0 0.0 0.0 0.0 0.0 0.000001 0.0 0.0 0.303851 0.0 0.41431 0.0 0.0 0.0 0.0 0.000002 0.0 0.0
11 pain_12.nidm-1 0.052411 0.120187 0.193765 0.0 0.0 0.0 0.000093 0.0 0.0 0.142476 0.0 0.0 0.0 0.0 0.0 0.0 0.488879 0.0
12 pain_13.nidm-1 0.118661 0.0 0.173124 0.0 0.0 0.168279 0.000378 0.0 0.0 0.0 0.0 0.0 0.000016 0.0 0.0 0.0 0.0 0.0
13 pain_14.nidm-1 0.070428 0.0 0.0 0.0 0.114381 0.0 0.0 0.153891 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
14 pain_15.nidm-1 0.03615 0.0 0.0 0.056854 0.0 0.128406 0.0 0.0 0.0 0.0 0.0 0.0 0.000002 0.0 0.0 0.000003 0.0 0.0
15 pain_16.nidm-1 0.052685 0.099472 0.186338 0.055696 0.000342 0.111119 0.001262 0.0 0.356352 0.000281 0.000019 0.0 0.000527 0.0 0.13379 0.0 0.492489 0.0
16 pain_17.nidm-1 0.0 0.0 0.0 0.0 0.080154 0.216049 0.0 0.0 0.0 0.0 0.171132 0.000065 0.0 0.0 0.32642 0.438329 0.0 0.0
17 pain_18.nidm-1 0.091356 0.110608 0.000316 0.0 0.0 0.206111 0.0 0.0 0.0 0.0 0.411024 0.0 0.0 0.0 0.0 0.000132 0.0 0.0
18 pain_19.nidm-1 0.129286 0.0 0.0 0.152358 0.103874 0.0 0.0 0.0 0.0 0.0 0.000002 0.0 0.0 0.000102 0.0 0.558612 0.0 0.0
19 pain_20.nidm-1 0.084771 0.0 0.0 0.114932 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.001997 0.418881 0.0 0.0 0.0
20 pain_21.nidm-1 0.044402 0.0 0.208044 0.176658 0.0 0.109986 0.292581 0.0 0.0 0.0 0.0 0.0 0.0 0.060755 0.0 0.0 0.0 0.0


Report

Finally, a NiMARE report is generated from the MetaResult. 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" / "10_plot_cbma_workflow"
html_dir.mkdir(parents=True, exist_ok=True)

run_reports(result, html_dir)

Total running time of the script: (1 minutes 13.238 seconds)

Gallery generated by Sphinx-Gallery