Combine CBMA kernels and estimators

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 FWECorrector
from nimare.dataset import Dataset
from nimare.meta import ALE, KDA, MKDAChi2, MKDADensity
from nimare.meta.kernel import ALEKernel, KDAKernel, MKDAKernel
from nimare.utils import get_resource_path

Load Dataset

List possible kernel transformers

kernel_transformers = {
    "MKDA kernel": MKDAKernel,
    "KDA kernel": KDAKernel,
    "ALE kernel": ALEKernel,
}

MKDA density analysis

for kt_name, kt in kernel_transformers.items():
    try:
        mkda = MKDADensity(kernel_transformer=kt, 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",
            title="MKDA estimator with %s" % kt_name,
        )

    except AttributeError:
        print(
            "\nError: the %s does not currently work with the MKDA meta-analysis method\n"
            % kt_name
        )
  • 07 plot cbma combine estimators and kernels
  • 07 plot cbma combine estimators and kernels
  • 07 plot cbma combine estimators and kernels

Out:

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

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

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

MKDA Chi2

for kt_name, kt in kernel_transformers.items():
    try:
        mkda = MKDAChi2(kernel_transformer=kt)
        dset1 = dset.slice(dset.ids)
        dset2 = dset.slice(dset.ids)
        mkda.fit(dset1, dset2)
        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",
            title="MKDA Chi2 estimator with %s" % kt_name,
        )

    except AttributeError:
        print(
            "\nError: the %s does not currently work with the MKDA Chi2 meta-analysis method\n"
            % kt_name
        )
  • 07 plot cbma combine estimators and kernels
  • 07 plot cbma combine estimators and kernels
  • 07 plot cbma combine estimators and kernels

Out:

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:03,  2.77it/s]
 20%|##        | 2/10 [00:00<00:02,  2.80it/s]
 30%|###       | 3/10 [00:01<00:02,  2.83it/s]
 40%|####      | 4/10 [00:01<00:02,  2.82it/s]
 50%|#####     | 5/10 [00:01<00:01,  2.82it/s]
 60%|######    | 6/10 [00:02<00:01,  2.82it/s]
 70%|#######   | 7/10 [00:02<00:01,  2.83it/s]
 80%|########  | 8/10 [00:02<00:00,  2.84it/s]
 90%|######### | 9/10 [00:03<00:00,  2.84it/s]
100%|##########| 10/10 [00:03<00:00,  2.83it/s]
100%|##########| 10/10 [00:03<00:00,  2.83it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.11/lib/python3.7/site-packages/nilearn/plotting/displays.py:880: UserWarning: empty mask
  get_mask_bounds(new_img_like(img, not_mask, affine))

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:03,  2.53it/s]
 20%|##        | 2/10 [00:00<00:03,  2.57it/s]
 30%|###       | 3/10 [00:01<00:02,  2.57it/s]
 40%|####      | 4/10 [00:01<00:02,  2.58it/s]
 50%|#####     | 5/10 [00:01<00:01,  2.58it/s]
 60%|######    | 6/10 [00:02<00:01,  2.58it/s]
 70%|#######   | 7/10 [00:02<00:01,  2.59it/s]
 80%|########  | 8/10 [00:03<00:00,  2.59it/s]
 90%|######### | 9/10 [00:03<00:00,  2.59it/s]
100%|##########| 10/10 [00:03<00:00,  2.59it/s]
100%|##########| 10/10 [00:03<00:00,  2.58it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.11/lib/python3.7/site-packages/nilearn/plotting/displays.py:880: UserWarning: empty mask
  get_mask_bounds(new_img_like(img, not_mask, affine))

  0%|          | 0/10 [00:00<?, ?it/s]
 10%|#         | 1/10 [00:00<00:04,  1.92it/s]
 20%|##        | 2/10 [00:01<00:04,  1.93it/s]
 30%|###       | 3/10 [00:01<00:03,  1.94it/s]
 40%|####      | 4/10 [00:02<00:03,  1.94it/s]
 50%|#####     | 5/10 [00:02<00:02,  1.94it/s]
 60%|######    | 6/10 [00:03<00:02,  1.95it/s]
 70%|#######   | 7/10 [00:03<00:01,  1.95it/s]
 80%|########  | 8/10 [00:04<00:01,  1.95it/s]
 90%|######### | 9/10 [00:04<00:00,  1.95it/s]
100%|##########| 10/10 [00:05<00:00,  1.95it/s]
100%|##########| 10/10 [00:05<00:00,  1.94it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.11/lib/python3.7/site-packages/nilearn/plotting/displays.py:880: UserWarning: empty mask
  get_mask_bounds(new_img_like(img, not_mask, affine))

KDA

for kt_name, kt in kernel_transformers.items():
    try:
        kda = KDA(kernel_transformer=kt, 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",
            title="KDA estimator with %s" % kt_name,
        )

    except AttributeError:
        print(
            "\nError: the %s does not currently work with the KDA meta-analysis method\n" % kt_name
        )
  • 07 plot cbma combine estimators and kernels
  • 07 plot cbma combine estimators and kernels
  • 07 plot cbma combine estimators and kernels

Out:

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

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

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

ALE

for kt_name, kt in kernel_transformers.items():
    try:
        ale = ALE(kernel_transformer=kt, 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",
            title="ALE estimator with %s" % kt_name,
        )

    except AttributeError:
        print(
            "\nError: the %s does not currently work with the ALE meta-analysis method\n" % kt_name
        )
  • 07 plot cbma combine estimators and kernels
  • 07 plot cbma combine estimators and kernels
  • 07 plot cbma combine estimators and kernels

Out:

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

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

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

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

Gallery generated by Sphinx-Gallery