Two-sample ALE meta-analysis

Meta-analytic projects often involve a number of common steps comparing two or more samples.

In this example, we replicate the ALE-based analyses from Enge et al.[1].

A common project workflow with two meta-analytic samples involves the following:

  1. Run a within-sample meta-analysis of the first sample.

  2. Characterize/summarize the results of the first meta-analysis.

  3. Run a within-sample meta-analysis of the second sample.

  4. Characterize/summarize the results of the second meta-analysis.

  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

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

Load Sleuth text files directly into Studysets

The data for this example are a subset of studies from a meta-analysis on semantic cognition in children [1]. A first group of studies probed children’s semantic world knowledge (e.g., correctly naming an object after hearing its auditory description) while a second group of studies asked children to decide if two (or more) words were semantically related to one another or not.

Individual group ALEs

Computing separate ALE analyses for each group is not strictly necessary for performing the subtraction analysis but will help the experimenter to appreciate the similarities and differences between the groups.

from nimare.correct import FWECorrector
from nimare.meta.cbma import ALE

ale = ALE(null_method="approximate")
knowledge_results = ale.fit(knowledge_studyset)
related_results = ale.fit(related_studyset)

corr = FWECorrector(method="montecarlo", voxel_thresh=0.001, n_iters=100, n_cores=2)
knowledge_corrected_results = corr.transform(knowledge_results)
related_corrected_results = corr.transform(related_results)

fig, axes = plt.subplots(figsize=(12, 10), nrows=2)
knowledge_img = knowledge_corrected_results.get_map(
    "z_desc-size_level-cluster_corr-FWE_method-montecarlo"
)
plot_stat_map(
    knowledge_img,
    cut_coords=4,
    display_mode="z",
    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,
)

related_img = related_corrected_results.get_map(
    "z_desc-size_level-cluster_corr-FWE_method-montecarlo"
)
plot_stat_map(
    related_img,
    cut_coords=4,
    display_mode="z",
    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,
)
fig.show()
08 plot cbma subtraction conjunction
  0%|          | 0/100 [00:00<?, ?it/s]
  1%|          | 1/100 [00:00<00:12,  7.98it/s]
  3%|▎         | 3/100 [00:00<00:07, 13.43it/s]
  5%|▌         | 5/100 [00:00<00:06, 15.73it/s]
  7%|▋         | 7/100 [00:00<00:05, 16.43it/s]
  9%|▉         | 9/100 [00:00<00:05, 17.26it/s]
 11%|█         | 11/100 [00:00<00:05, 17.47it/s]
 13%|█▎        | 13/100 [00:00<00:04, 17.61it/s]
 15%|█▌        | 15/100 [00:00<00:04, 17.59it/s]
 17%|█▋        | 17/100 [00:01<00:04, 18.06it/s]
 19%|█▉        | 19/100 [00:01<00:04, 18.26it/s]
 21%|██        | 21/100 [00:01<00:04, 17.82it/s]
 23%|██▎       | 23/100 [00:01<00:04, 18.10it/s]
 25%|██▌       | 25/100 [00:01<00:04, 18.46it/s]
 27%|██▋       | 27/100 [00:01<00:03, 18.70it/s]
 29%|██▉       | 29/100 [00:01<00:03, 18.66it/s]
 31%|███       | 31/100 [00:01<00:03, 18.65it/s]
 33%|███▎      | 33/100 [00:01<00:03, 18.81it/s]
 35%|███▌      | 35/100 [00:01<00:03, 18.85it/s]
 37%|███▋      | 37/100 [00:02<00:03, 18.97it/s]
 39%|███▉      | 39/100 [00:02<00:03, 18.92it/s]
 41%|████      | 41/100 [00:02<00:03, 18.89it/s]
 43%|████▎     | 43/100 [00:02<00:03, 18.40it/s]
 45%|████▌     | 45/100 [00:02<00:02, 18.55it/s]
 49%|████▉     | 49/100 [00:02<00:02, 19.10it/s]
 51%|█████     | 51/100 [00:02<00:02, 19.16it/s]
 53%|█████▎    | 53/100 [00:02<00:02, 19.16it/s]
 55%|█████▌    | 55/100 [00:03<00:02, 19.16it/s]
 57%|█████▋    | 57/100 [00:03<00:02, 18.67it/s]
 59%|█████▉    | 59/100 [00:03<00:02, 18.90it/s]
 61%|██████    | 61/100 [00:03<00:02, 19.00it/s]
 63%|██████▎   | 63/100 [00:03<00:01, 19.06it/s]
 65%|██████▌   | 65/100 [00:03<00:01, 19.16it/s]
 67%|██████▋   | 67/100 [00:03<00:01, 19.21it/s]
 69%|██████▉   | 69/100 [00:03<00:01, 18.57it/s]
 71%|███████   | 71/100 [00:03<00:01, 18.83it/s]
 75%|███████▌  | 75/100 [00:04<00:01, 19.32it/s]
 77%|███████▋  | 77/100 [00:04<00:01, 19.40it/s]
 79%|███████▉  | 79/100 [00:04<00:01, 19.26it/s]
 81%|████████  | 81/100 [00:04<00:01, 18.66it/s]
 85%|████████▌ | 85/100 [00:04<00:00, 18.92it/s]
 89%|████████▉ | 89/100 [00:04<00:00, 19.46it/s]
 91%|█████████ | 91/100 [00:04<00:00, 19.33it/s]
 93%|█████████▎| 93/100 [00:05<00:00, 19.35it/s]
 96%|█████████▌| 96/100 [00:05<00:00, 21.60it/s]
 99%|█████████▉| 99/100 [00:05<00:00, 19.00it/s]
100%|██████████| 100/100 [00:05<00:00, 18.81it/s]

  0%|          | 0/100 [00:00<?, ?it/s]
  1%|          | 1/100 [00:00<00:10,  9.44it/s]
  5%|▌         | 5/100 [00:00<00:05, 18.46it/s]
  9%|▉         | 9/100 [00:00<00:04, 20.28it/s]
 13%|█▎        | 13/100 [00:00<00:04, 20.65it/s]
 17%|█▋        | 17/100 [00:00<00:03, 20.92it/s]
 21%|██        | 21/100 [00:01<00:03, 21.07it/s]
 25%|██▌       | 25/100 [00:01<00:03, 21.36it/s]
 28%|██▊       | 28/100 [00:01<00:03, 22.88it/s]
 31%|███       | 31/100 [00:01<00:03, 20.54it/s]
 35%|███▌      | 35/100 [00:01<00:03, 20.80it/s]
 39%|███▉      | 39/100 [00:01<00:02, 20.62it/s]
 43%|████▎     | 43/100 [00:02<00:02, 21.01it/s]
 46%|████▌     | 46/100 [00:02<00:02, 22.47it/s]
 49%|████▉     | 49/100 [00:02<00:02, 20.65it/s]
 53%|█████▎    | 53/100 [00:02<00:02, 20.80it/s]
 57%|█████▋    | 57/100 [00:02<00:02, 20.76it/s]
 61%|██████    | 61/100 [00:02<00:01, 21.14it/s]
 65%|██████▌   | 65/100 [00:03<00:01, 20.83it/s]
 69%|██████▉   | 69/100 [00:03<00:01, 20.90it/s]
 73%|███████▎  | 73/100 [00:03<00:01, 21.23it/s]
 77%|███████▋  | 77/100 [00:03<00:01, 20.80it/s]
 81%|████████  | 81/100 [00:03<00:00, 21.27it/s]
 84%|████████▍ | 84/100 [00:03<00:00, 22.72it/s]
 87%|████████▋ | 87/100 [00:04<00:00, 20.85it/s]
 91%|█████████ | 91/100 [00:04<00:00, 20.99it/s]
 95%|█████████▌| 95/100 [00:04<00:00, 21.10it/s]
 99%|█████████▉| 99/100 [00:04<00:00, 21.17it/s]
100%|██████████| 100/100 [00:04<00:00, 21.21it/s]

Characterize the relative contributions of experiments in the ALE results

NiMARE contains two methods for this: Jackknife and FocusCounter. We will show both below, but for the sake of speed we will only apply one to each subgroup meta-analysis.

from nimare.diagnostics import FocusCounter

counter = FocusCounter(
    target_image="z_desc-size_level-cluster_corr-FWE_method-montecarlo",
    voxel_thresh=None,
)
knowledge_diagnostic_results = counter.transform(knowledge_corrected_results)
  0%|          | 0/21 [00:00<?, ?it/s]
 29%|██▊       | 6/21 [00:00<00:00, 52.42it/s]
 57%|█████▋    | 12/21 [00:00<00:00, 52.71it/s]
 86%|████████▌ | 18/21 [00:00<00:00, 52.84it/s]
100%|██████████| 21/21 [00:00<00:00, 52.85it/s]

Clusters table.

knowledge_clusters_table = knowledge_diagnostic_results.tables[
    "z_desc-size_level-cluster_corr-FWE_method-montecarlo_tab-clust"
]
knowledge_clusters_table.head(10)
Cluster ID X Y Z Peak Stat Cluster Size (mm3)
0 PositiveTail 1 -4.0 16.0 50.0 6.757158 3472
1 PositiveTail 1a 2.0 30.0 40.0 4.420875
2 PositiveTail 2 -44.0 16.0 24.0 5.520610 3096
3 PositiveTail 2a -42.0 8.0 32.0 4.879655
4 PositiveTail 3 -32.0 22.0 -2.0 5.268503 992
5 PositiveTail 3a -42.0 20.0 2.0 3.681865
6 PositiveTail 4 36.0 24.0 -8.0 4.806498 1128
7 PositiveTail 4a 36.0 22.0 4.0 3.309718
8 PositiveTail 5 54.0 -28.0 4.0 4.729418 512
9 PositiveTail 6 -52.0 -34.0 4.0 4.691677 672


Contribution table. Here PostiveTail refers to clusters with positive statistics.

knowledge_count_table = knowledge_diagnostic_results.tables[
    "z_desc-size_level-cluster_corr-FWE_method-montecarlo_diag-FocusCounter"
    "_tab-counts_tail-positive"
]
knowledge_count_table.head(10)
id PositiveTail 1 PositiveTail 2 PositiveTail 3 PositiveTail 4 PositiveTail 5 PositiveTail 6 PositiveTail 7
0 arnoldussen2006nc-analysis_1 0 0 1 0 0 0 0
1 arnoldussen2006rm-analysis_1 0 0 1 0 0 0 0
2 backes2002-analysis_1 0 1 1 0 0 0 0
3 balsamo2002-analysis_1 0 0 0 0 1 0 0
4 balsamo2006-analysis_1 0 1 1 0 0 0 0
5 bauer2017-analysis_1 1 0 0 0 0 0 1
6 berl2014-analysis_1 1 2 2 0 0 1 1
7 brauer2007-analysis_1 0 1 0 0 0 0 0
8 gaillard2001-analysis_1 0 0 1 0 0 0 0
9 gaillard2003-analysis_1 1 1 1 0 0 0 0


from nimare.diagnostics import Jackknife

jackknife = Jackknife(
    target_image="z_desc-size_level-cluster_corr-FWE_method-montecarlo",
    voxel_thresh=None,
)
related_diagnostic_results = jackknife.transform(related_corrected_results)
related_jackknife_table = related_diagnostic_results.tables[
    "z_desc-size_level-cluster_corr-FWE_method-montecarlo_diag-Jackknife_tab-counts_tail-positive"
]
related_jackknife_table.head(10)
  0%|          | 0/16 [00:00<?, ?it/s]
 12%|█▎        | 2/16 [00:00<00:00, 14.23it/s]
 25%|██▌       | 4/16 [00:00<00:00, 14.16it/s]
 38%|███▊      | 6/16 [00:00<00:00, 14.22it/s]
 50%|█████     | 8/16 [00:00<00:00, 14.22it/s]
 62%|██████▎   | 10/16 [00:00<00:00, 13.89it/s]
 75%|███████▌  | 12/16 [00:00<00:00, 14.02it/s]
 88%|████████▊ | 14/16 [00:00<00:00, 14.05it/s]
100%|██████████| 16/16 [00:01<00:00, 14.18it/s]
100%|██████████| 16/16 [00:01<00:00, 14.12it/s]
id PositiveTail 1 PositiveTail 2 PositiveTail 3 PositiveTail 4 PositiveTail 5
0 booth2001-analysis_1 0.0 0.0 0.029415 0.054821 0.0
1 booth2003-analysis_1 0.0 0.0 0.0 0.000008 0.0
2 booth2007-analysis_1 0.021799 0.068333 0.051598 0.000028 0.000019
3 cao2008-analysis_1 0.134026 0.06561 0.035607 0.094222 0.0
4 chou2006a-analysis_1 0.211268 0.123099 0.000075 0.095687 0.0
5 chou2006b-analysis_1 0.21024 0.117018 0.004724 0.117981 0.0
6 chou2009-analysis_1 0.188491 0.1575 0.22325 0.212472 0.330668
7 chou2019-analysis_1 0.0 0.061734 0.0 0.0 0.0
8 fan2020-analysis_1 0.0 0.070051 0.002654 0.101595 0.0
9 lee2011aud-analysis_1 0.000026 0.000246 0.164283 0.068827 0.243831


Subtraction analysis

Typically, one would use at least 5000 iterations for a subtraction analysis. However, we have reduced this to 100 iterations for this example. Here we use a cluster-defining p-threshold of 0.01 for Monte Carlo FWE correction. In practice one would generally use a more stringent threshold.

from nimare.meta.cbma import ALESubtraction
from nimare.reports.base import run_reports
from nimare.workflows import PairwiseCBMAWorkflow

subtraction_iters = 100
subtraction_voxel_thresh = 0.01

# Keep estimator and Corrector Monte Carlo parameters synchronized so the
# correction step can reuse cached permutation nulls from ALESubtraction.
subtraction_estimator = ALESubtraction(
    n_iters=subtraction_iters,
    voxel_thresh=subtraction_voxel_thresh,
    vfwe_only=False,
    n_cores=1,
)
subtraction_corrector = FWECorrector(
    method="montecarlo",
    voxel_thresh=subtraction_voxel_thresh,
    n_iters=subtraction_iters,
    n_cores=1,
    vfwe_only=False,
)

workflow = PairwiseCBMAWorkflow(
    estimator=subtraction_estimator,
    corrector=subtraction_corrector,
    diagnostics=FocusCounter(voxel_thresh=0.01, display_second_group=True),
)
res_sub = workflow.fit(knowledge_studyset, related_studyset)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/examples/02_meta-analyses/08_plot_cbma_subtraction_conjunction.py:174: FutureWarning: 'voxel_thresh' is deprecated for diagnostics and will be removed in a future release. Use 'target_threshold' to threshold the selected target image before diagnostics table/support generation.
  diagnostics=FocusCounter(voxel_thresh=0.01, display_second_group=True),

  0%|          | 0/100 [00:00<?, ?it/s]
  6%|▌         | 6/100 [00:00<00:01, 57.28it/s]
 12%|█▏        | 12/100 [00:00<00:01, 57.48it/s]
 18%|█▊        | 18/100 [00:00<00:01, 57.60it/s]
 24%|██▍       | 24/100 [00:00<00:01, 57.69it/s]
 30%|███       | 30/100 [00:00<00:01, 57.79it/s]
 36%|███▌      | 36/100 [00:00<00:01, 57.98it/s]
 42%|████▏     | 42/100 [00:00<00:00, 58.39it/s]
 48%|████▊     | 48/100 [00:00<00:00, 58.22it/s]
 54%|█████▍    | 54/100 [00:00<00:00, 57.74it/s]
 60%|██████    | 60/100 [00:01<00:00, 57.29it/s]
 66%|██████▌   | 66/100 [00:01<00:00, 57.27it/s]
 72%|███████▏  | 72/100 [00:01<00:00, 57.19it/s]
 78%|███████▊  | 78/100 [00:01<00:00, 57.03it/s]
 84%|████████▍ | 84/100 [00:01<00:00, 57.23it/s]
 90%|█████████ | 90/100 [00:01<00:00, 57.43it/s]
 96%|█████████▌| 96/100 [00:01<00:00, 57.45it/s]
100%|██████████| 100/100 [00:01<00:00, 57.54it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/diagnostics.py:174: UserWarning: Attention: At least one of the (sub)peaks falls outside of the cluster body. Identifying the nearest in-cluster voxel.
  result = get_clusters_table(

  0%|          | 0/21 [00:00<?, ?it/s]
 19%|█▉        | 4/21 [00:00<00:00, 34.58it/s]
 38%|███▊      | 8/21 [00:00<00:00, 34.23it/s]
 57%|█████▋    | 12/21 [00:00<00:00, 34.31it/s]
 76%|███████▌  | 16/21 [00:00<00:00, 33.80it/s]
 95%|█████████▌| 20/21 [00:00<00:00, 35.76it/s]
100%|██████████| 21/21 [00:00<00:00, 34.97it/s]

  0%|          | 0/16 [00:00<?, ?it/s]
 12%|█▎        | 2/16 [00:00<00:00, 16.18it/s]
 25%|██▌       | 4/16 [00:00<00:00, 15.84it/s]
 38%|███▊      | 6/16 [00:00<00:00, 15.46it/s]
 50%|█████     | 8/16 [00:00<00:00, 15.40it/s]
 62%|██████▎   | 10/16 [00:00<00:00, 15.45it/s]
 75%|███████▌  | 12/16 [00:00<00:00, 15.51it/s]
 88%|████████▊ | 14/16 [00:00<00:00, 15.63it/s]
100%|██████████| 16/16 [00:01<00:00, 15.50it/s]
100%|██████████| 16/16 [00:01<00:00, 15.54it/s]

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" / "08_subtraction"
html_dir.mkdir(parents=True, exist_ok=True)

run_reports(res_sub, html_dir)

Conjunction analysis

To determine the overlap of the meta-analytic results, a conjunction image can be computed by (a) identifying voxels that were statistically significant in both individual group maps and (b) selecting, for each of these voxels, the smaller of the two group-specific z values Nichols et al.[2].

from nimare.workflows.misc import conjunction_analysis

img_conj = conjunction_analysis([knowledge_img, related_img])

plot_stat_map(
    img_conj,
    cut_coords=4,
    display_mode="z",
    title="Conjunction",
    threshold=2.326,  # cluster-level p < .01, one-tailed
    cmap="RdBu_r",
    symmetric_cbar=True,
    vmax=4,
)
08 plot cbma subtraction conjunction
<nilearn.plotting.displays._slicers.ZSlicer object at 0x7987131803b0>

References

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

Gallery generated by Sphinx-Gallery