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("logp_level-voxel_corr-FWE_method-montecarlo"),
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
)
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.25it/s]
 30%|###       | 3/10 [00:00<00:02,  3.25it/s]
 40%|####      | 4/10 [00:01<00:01,  3.25it/s]
 50%|#####     | 5/10 [00:01<00:01,  3.25it/s]
 60%|######    | 6/10 [00:01<00:01,  3.25it/s]
 70%|#######   | 7/10 [00:02<00:00,  3.24it/s]
 80%|########  | 8/10 [00:02<00:00,  3.24it/s]
 90%|######### | 9/10 [00:02<00:00,  3.26it/s]
100%|##########| 10/10 [00:03<00:00,  3.25it/s]
100%|##########| 10/10 [00:03<00:00,  3.25it/s]

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

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"),
    threshold=1.65,
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
)
01 plot cbma

Out:

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

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

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-consistency_level-voxel_corr-FWE_method-montecarlo"),
    threshold=1.65,
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
)
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.82it/s]
 30%|###       | 3/10 [00:01<00:02,  2.83it/s]
 40%|####      | 4/10 [00:01<00:02,  2.84it/s]
 50%|#####     | 5/10 [00:01<00:01,  2.85it/s]
 60%|######    | 6/10 [00:02<00:01,  2.85it/s]
 70%|#######   | 7/10 [00:02<00:01,  2.85it/s]
 80%|########  | 8/10 [00:02<00:00,  2.85it/s]
 90%|######### | 9/10 [00:03<00:00,  2.85it/s]
100%|##########| 10/10 [00:03<00:00,  2.85it/s]
100%|##########| 10/10 [00:03<00:00,  2.84it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.12rc1/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 0x7fc43806d650>

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("logp_level-voxel_corr-FWE_method-montecarlo"),
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
)
01 plot cbma

Out:

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:02,  3.17it/s]
 20%|##        | 2/10 [00:00<00:02,  3.24it/s]
 30%|###       | 3/10 [00:00<00:02,  3.24it/s]
 40%|####      | 4/10 [00:01<00:01,  3.25it/s]
 50%|#####     | 5/10 [00:01<00:01,  3.25it/s]
 60%|######    | 6/10 [00:01<00:01,  3.25it/s]
 70%|#######   | 7/10 [00:02<00:00,  3.25it/s]
 80%|########  | 8/10 [00:02<00:00,  3.25it/s]
 90%|######### | 9/10 [00:02<00:00,  3.25it/s]
100%|##########| 10/10 [00:03<00:00,  3.26it/s]
100%|##########| 10/10 [00:03<00:00,  3.25it/s]

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

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("logp_desc-size_level-cluster_corr-FWE_method-montecarlo"),
    cut_coords=[0, 0, -8],
    draw_cross=False,
    cmap="RdBu_r",
)
01 plot cbma

Out:

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:03,  2.82it/s]
 20%|##        | 2/10 [00:00<00:02,  2.84it/s]
 30%|###       | 3/10 [00:01<00:02,  2.86it/s]
 40%|####      | 4/10 [00:01<00:02,  2.85it/s]
 50%|#####     | 5/10 [00:01<00:01,  2.85it/s]
 60%|######    | 6/10 [00:02<00:01,  2.84it/s]
 70%|#######   | 7/10 [00:02<00:01,  2.85it/s]
 80%|########  | 8/10 [00:02<00:00,  2.86it/s]
 90%|######### | 9/10 [00:03<00:00,  2.86it/s]
100%|##########| 10/10 [00:03<00:00,  2.86it/s]
100%|##########| 10/10 [00:03<00:00,  2.85it/s]

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

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

Gallery generated by Sphinx-Gallery