Coordinate-based meta-analysis

Perform CBMAs on a toy dataset.

Collection of NIDM-Results packs downloaded from Neurovault collection 1425, uploaded by Dr. Camille Maumet.

Note

Creation of the Dataset from the NIDM-Results packs was done with custom code. The Results packs for collection 1425 are not completely NIDM-Results-compliant, so the nidmresults library could not be used to facilitate data extraction.

import os

from nilearn.plotting import plot_stat_map

from nimare.correct import FDRCorrector, FWECorrector
from nimare.dataset import Dataset
from nimare.meta import ALE, KDA, MKDAChi2, MKDADensity
from nimare.utils import get_resource_path

Load Dataset

MKDA density analysis

mkda = MKDADensity(kernel__r=10, null_method="approximate")
mkda.fit(dset)
corr = FWECorrector(method="montecarlo", n_iters=10, n_cores=1)
cres = corr.transform(mkda.results)
plot_stat_map(
    cres.get_map("z_level-voxel_corr-FWE_method-montecarlo"),
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
    threshold=0.1,
)
01 plot cbma

Out:

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:02,  3.30it/s]
 20%|##        | 2/10 [00:00<00:02,  3.32it/s]
 30%|###       | 3/10 [00:00<00:02,  3.35it/s]
 40%|####      | 4/10 [00:01<00:01,  3.34it/s]
 50%|#####     | 5/10 [00:01<00:01,  3.36it/s]
 60%|######    | 6/10 [00:01<00:01,  3.35it/s]
 70%|#######   | 7/10 [00:02<00:00,  3.36it/s]
 80%|########  | 8/10 [00:02<00:00,  3.37it/s]
 90%|######### | 9/10 [00:02<00:00,  3.35it/s]
100%|##########| 10/10 [00:02<00:00,  3.36it/s]
100%|##########| 10/10 [00:02<00:00,  3.35it/s]

<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7f3b8c852510>

MKDA Chi2 with FDR correction

mkda = MKDAChi2(kernel__r=10)
dset1 = dset.slice(dset.ids)
dset2 = dset.slice(dset.ids)
mkda.fit(dset1, dset2)
corr = FDRCorrector(method="bh", alpha=0.001)
cres = corr.transform(mkda.results)
plot_stat_map(
    cres.get_map("z_desc-consistency_level-voxel_corr-FDR_method-bh"),
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
    threshold=1.65,
)
01 plot cbma

Out:

/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/0.0.12rc2/nimare/meta/cbma/mkda.py:371: RuntimeWarning: invalid value encountered in true_divide
  pFgA = pAgF * pF / pA
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/0.0.12rc2/nimare/meta/cbma/mkda.py:377: RuntimeWarning: invalid value encountered in true_divide
  pFgA_prior = pAgF * self.prior / pAgF_prior

<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7f3b8c6c8250>

MKDA Chi2 with FWE correction

Since we’ve already fitted the Estimator, we can just apply a new Corrector to the estimator.

corr = FWECorrector(method="montecarlo", n_iters=10, n_cores=1)
cres = corr.transform(mkda.results)
plot_stat_map(
    cres.get_map("z_desc-consistencySize_level-cluster_corr-FWE_method-montecarlo"),
    draw_cross=False,
    cmap="RdBu_r",
    threshold=1.65,
)
01 plot cbma

Out:

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:06,  1.44it/s]
 20%|##        | 2/10 [00:01<00:05,  1.47it/s]
 30%|###       | 3/10 [00:02<00:04,  1.49it/s]
 40%|####      | 4/10 [00:02<00:04,  1.50it/s]
 50%|#####     | 5/10 [00:03<00:03,  1.50it/s]
 60%|######    | 6/10 [00:04<00:02,  1.50it/s]
 70%|#######   | 7/10 [00:04<00:01,  1.50it/s]
 80%|########  | 8/10 [00:05<00:01,  1.51it/s]
 90%|######### | 9/10 [00:05<00:00,  1.52it/s]
100%|##########| 10/10 [00:06<00:00,  1.52it/s]
100%|##########| 10/10 [00:06<00:00,  1.51it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.12rc2/lib/python3.7/site-packages/nilearn/plotting/find_cuts.py:141: UserWarning: Could not determine cut coords: All voxels were masked by the thresholding. Returning the center of mass instead.
  "Could not determine cut coords: "
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.12rc2/lib/python3.7/site-packages/nilearn/plotting/displays/_slicers.py:373: UserWarning: empty mask
  get_mask_bounds(new_img_like(img, not_mask, affine))

<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7f3b8c5ae910>

KDA

kda = KDA(kernel__r=10, null_method="approximate")
kda.fit(dset)
corr = FWECorrector(method="montecarlo", n_iters=10, n_cores=1)
cres = corr.transform(kda.results)
plot_stat_map(
    cres.get_map("z_level-voxel_corr-FWE_method-montecarlo"),
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
    threshold=0.1,
)
01 plot cbma

Out:

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:02,  3.25it/s]
 20%|##        | 2/10 [00:00<00:02,  3.29it/s]
 30%|###       | 3/10 [00:00<00:02,  3.31it/s]
 40%|####      | 4/10 [00:01<00:01,  3.32it/s]
 50%|#####     | 5/10 [00:01<00:01,  3.35it/s]
 60%|######    | 6/10 [00:01<00:01,  3.33it/s]
 70%|#######   | 7/10 [00:02<00:00,  3.34it/s]
 80%|########  | 8/10 [00:02<00:00,  3.34it/s]
 90%|######### | 9/10 [00:02<00:00,  3.34it/s]
100%|##########| 10/10 [00:02<00:00,  3.35it/s]
100%|##########| 10/10 [00:02<00:00,  3.33it/s]

<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7f3b8c415b90>

ALE

ale = ALE(null_method="approximate")
ale.fit(dset)
corr = FWECorrector(method="montecarlo", n_iters=10, n_cores=1)
cres = corr.transform(ale.results)
plot_stat_map(
    cres.get_map("z_desc-size_level-cluster_corr-FWE_method-montecarlo"),
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
    threshold=0.1,
)
01 plot cbma

Out:

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:03,  2.78it/s]
 20%|##        | 2/10 [00:00<00:02,  2.91it/s]
 30%|###       | 3/10 [00:01<00:02,  2.95it/s]
 40%|####      | 4/10 [00:01<00:02,  2.99it/s]
 50%|#####     | 5/10 [00:01<00:01,  3.00it/s]
 60%|######    | 6/10 [00:02<00:01,  3.01it/s]
 70%|#######   | 7/10 [00:02<00:00,  3.02it/s]
 80%|########  | 8/10 [00:02<00:00,  3.01it/s]
 90%|######### | 9/10 [00:03<00:00,  3.00it/s]
100%|##########| 10/10 [00:03<00:00,  3.01it/s]
100%|##########| 10/10 [00:03<00:00,  2.99it/s]

<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7f3b8c60fc50>

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

Gallery generated by Sphinx-Gallery