Note
Click here to download the full example code
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 import cbma_workflow
Load Dataset
dset_file = os.path.join(get_resource_path(), "nidm_pain_dset.json")
dset = Dataset(dset_file)
Run CBMA Workflow
The CBMA workflow function runs the following steps:
Runs a meta-analysis using the specified method (default: ALE)
Applies a corrector to the meta-analysis results (default: FWECorrector, montecarlo)
Generates cluster tables and runs diagnostics on the corrected results (default: Jackknife)
All in one function call!
result = cbma_workflow(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
result = cbma_workflow(dset, corrector="fdr")
Out:
0%| | 0/21 [00:00<?, ?it/s]
5%|4 | 1/21 [00:02<00:49, 2.45s/it]
10%|9 | 2/21 [00:04<00:46, 2.45s/it]
14%|#4 | 3/21 [00:07<00:44, 2.45s/it]
19%|#9 | 4/21 [00:09<00:41, 2.43s/it]
24%|##3 | 5/21 [00:12<00:38, 2.43s/it]
29%|##8 | 6/21 [00:14<00:36, 2.43s/it]
33%|###3 | 7/21 [00:17<00:33, 2.43s/it]
38%|###8 | 8/21 [00:19<00:31, 2.41s/it]
43%|####2 | 9/21 [00:21<00:29, 2.42s/it]
48%|####7 | 10/21 [00:24<00:26, 2.42s/it]
52%|#####2 | 11/21 [00:26<00:24, 2.43s/it]
57%|#####7 | 12/21 [00:29<00:21, 2.43s/it]
62%|######1 | 13/21 [00:31<00:19, 2.43s/it]
67%|######6 | 14/21 [00:34<00:17, 2.45s/it]
71%|#######1 | 15/21 [00:36<00:14, 2.46s/it]
76%|#######6 | 16/21 [00:39<00:12, 2.46s/it]
81%|######## | 17/21 [00:41<00:09, 2.47s/it]
86%|########5 | 18/21 [00:43<00:07, 2.47s/it]
90%|######### | 19/21 [00:46<00:04, 2.45s/it]
95%|#########5| 20/21 [00:48<00:02, 2.44s/it]
100%|##########| 21/21 [00:51<00:00, 2.44s/it]
100%|##########| 21/21 [00:51<00:00, 2.44s/it]
Plot Results
The CBMA workflow function 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",
vmax=4,
)
plt.show()
Clusters table
result.tables["z_corr-FDR_method-indep_tab-clust"]
Contribution table
result.tables["z_corr-FDR_method-indep_diag-Jackknife_tab-counts"]
Report
Finally, a NiMARE report is generated from the MetaResult.
root_dir = Path(os.getcwd()).parents[1]
# Use the following path to run the documentation locally:
# html_dir = root_dir / "docs" / "_build" / "html" / "auto_examples" / "02_meta-analyses"
html_dir = root_dir / "_readthedocs" / "html" / "auto_examples" / "02_meta-analyses"
html_dir.mkdir(parents=True, exist_ok=True)
run_reports(result, html_dir)
Total running time of the script: ( 1 minutes 25.197 seconds)