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.nimads import Studyset
from nimare.reports.base import run_reports
from nimare.utils import get_resource_path
from nimare.workflows.cbma import CBMAWorkflow

Load Studyset

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

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(studyset)

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(studyset)
  0%|          | 0/21 [00:00<?, ?it/s]
 10%|▉         | 2/21 [00:00<00:01, 13.36it/s]
 19%|█▉        | 4/21 [00:00<00:01, 13.38it/s]
 29%|██▊       | 6/21 [00:00<00:01, 13.43it/s]
 38%|███▊      | 8/21 [00:00<00:00, 13.49it/s]
 48%|████▊     | 10/21 [00:00<00:00, 13.54it/s]
 57%|█████▋    | 12/21 [00:00<00:00, 13.46it/s]
 67%|██████▋   | 14/21 [00:01<00:00, 13.44it/s]
 76%|███████▌  | 16/21 [00:01<00:00, 13.46it/s]
 86%|████████▌ | 18/21 [00:01<00:00, 13.50it/s]
 95%|█████████▌| 20/21 [00:01<00:00, 13.48it/s]
100%|██████████| 21/21 [00:01<00:00, 13.46it/s]

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.820054 6880
1 PositiveTail 1a 38.0 14.0 -6.0 4.123436
2 PositiveTail 1b 34.0 20.0 0.0 3.962785
3 PositiveTail 1c 38.0 -10.0 -6.0 2.860361
4 PositiveTail 2 54.0 -28.0 20.0 4.291998 1736
5 PositiveTail 3 -34.0 14.0 0.0 4.123436 1264
6 PositiveTail 4 2.0 4.0 52.0 3.704488 5656
7 PositiveTail 4a -6.0 8.0 42.0 3.412244
8 PositiveTail 4b 2.0 -4.0 64.0 2.980164
9 PositiveTail 4c -8.0 14.0 34.0 2.937338
10 PositiveTail 5 -32.0 -60.0 -34.0 3.456367 2816
11 PositiveTail 5a -26.0 -66.0 -38.0 2.679304
12 PositiveTail 5b -28.0 -58.0 -46.0 2.254643
13 PositiveTail 6 -62.0 -22.0 20.0 2.954772 1768
14 PositiveTail 6a -54.0 -32.0 22.0 2.825722
15 PositiveTail 6b -64.0 -22.0 28.0 2.284424
16 PositiveTail 7 -36.0 4.0 -16.0 2.794111 528
17 PositiveTail 8 20.0 -102.0 -4.0 2.702625 480
18 PositiveTail 9 -6.0 -48.0 54.0 2.447808 544
19 PositiveTail 10 -36.0 -22.0 10.0 2.213612 208
20 PositiveTail 11 -4.0 -70.0 50.0 2.211987 136
21 PositiveTail 12 -46.0 -58.0 -54.0 2.198758 128
22 PositiveTail 13 36.0 -18.0 12.0 2.187521 112
23 PositiveTail 14 -34.0 -90.0 -12.0 2.175705 144
24 PositiveTail 15 -54.0 -66.0 2.0 2.121178 240
25 PositiveTail 16 10.0 -68.0 36.0 2.069842 160
26 PositiveTail 17 36.0 40.0 30.0 1.959734 80


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
0 pain_01.nidm-1 0.034813 0.0 0.0 0.0 0.072717 0.0 0.0 0.058134 0.0 0.0 0.0 0.000003 0.000075 0.0 0.118825 0.0 0.0
1 pain_02.nidm-1 0.000005 0.141261 0.00003 0.0 0.0 0.0 0.327321 0.000014 0.0 0.0 0.0 0.0 0.526 0.0 0.0 0.0 0.566185
2 pain_03.nidm-1 0.025472 0.0 0.0 0.136886 0.114062 0.0 0.0 0.385138 0.0 0.0 0.0 0.0 0.0 0.481337 0.0 0.0 0.0
3 pain_04.nidm-1 0.082258 0.231971 0.191881 0.112308 0.079544 0.0 0.284854 0.395319 0.0 0.0 0.0 0.0 0.470476 0.458625 0.0 0.0 0.0
4 pain_05.nidm-1 0.093587 0.0 0.038789 0.08441 0.122595 0.0 0.080042 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.000069 0.038903 0.0 0.0 0.020603 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.014877
6 pain_07.nidm-1 0.0 0.0 0.0 0.0 0.016412 0.0 0.0 0.0 0.000013 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.043225 0.112782 0.0 0.0 0.0 0.207134 0.000097 0.490627 0.50184 0.0 0.0 0.0 0.016052 0.14733
8 pain_09.nidm-1 0.001849 0.0 0.0 0.0 0.061254 0.0 0.0 0.0 0.135617 0.0 0.000032 0.494551 0.0 0.0 0.0 0.0 0.268507
9 pain_10.nidm-1 0.076232 0.141862 0.0 0.02168 0.116324 0.057577 0.0 0.0 0.000094 0.0 0.373361 0.000654 0.000001 0.0 0.0 0.000002 0.0
10 pain_11.nidm-1 0.0 0.0 0.0 0.0 0.0 0.000001 0.0 0.0 0.302373 0.41431 0.0 0.0 0.0 0.0 0.0 0.0 0.0
11 pain_12.nidm-1 0.052454 0.120187 0.193699 0.0 0.0 0.0 0.000078 0.0 0.0 0.0 0.13226 0.0 0.0 0.0 0.0 0.493174 0.0
12 pain_13.nidm-1 0.118988 0.0 0.173801 0.0 0.0 0.173527 0.000288 0.0 0.0 0.0 0.0 0.0 0.000016 0.0 0.0 0.0 0.0
13 pain_14.nidm-1 0.069968 0.0 0.0 0.0 0.115811 0.0 0.0 0.157469 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
14 pain_15.nidm-1 0.036286 0.0 0.0 0.056467 0.0 0.130732 0.0 0.0 0.0 0.0 0.0 0.0 0.000002 0.0 0.0 0.0 0.0
15 pain_16.nidm-1 0.051733 0.099472 0.186977 0.05616 0.000337 0.105598 0.0011 0.0 0.350806 0.000019 0.000254 0.0 0.000527 0.0 0.135198 0.487895 0.0
16 pain_17.nidm-1 0.0 0.0 0.0 0.0 0.080481 0.212732 0.0 0.0 0.0 0.171132 0.0 0.000065 0.0 0.0 0.331724 0.0 0.0
17 pain_18.nidm-1 0.091518 0.110608 0.00032 0.0 0.0 0.206953 0.0 0.0 0.0 0.411024 0.0 0.0 0.0 0.0 0.0 0.0 0.0
18 pain_19.nidm-1 0.129434 0.0 0.0 0.15361 0.102752 0.0 0.0 0.0 0.0 0.000002 0.0 0.0 0.0 0.000097 0.0 0.0 0.0
19 pain_20.nidm-1 0.084744 0.0 0.0 0.114289 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.002087 0.410713 0.0 0.0
20 pain_21.nidm-1 0.044325 0.0 0.208654 0.176981 0.0 0.108555 0.281598 0.0 0.0 0.0 0.0 0.0 0.0 0.054862 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: (0 minutes 5.721 seconds)

Gallery generated by Sphinx-Gallery