Note
Click here to download the full example code
Test combinations of kernels and estimators for coordinate-based meta-analyses.¶
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
import nimare
from nimare.tests.utils import get_test_data_path
Load Dataset¶
dset_file = os.path.join(get_test_data_path(), "nidm_pain_dset.json")
dset = nimare.dataset.Dataset(dset_file)
mask_img = dset.masker.mask_img
List possible kernel transformers¶
kernel_transformers = {
"MKDA kernel": nimare.meta.kernel.MKDAKernel,
"KDA kernel": nimare.meta.kernel.KDAKernel,
"ALE kernel": nimare.meta.kernel.ALEKernel,
}
MKDA density analysis¶
for kt_name, kt in kernel_transformers.items():
try:
mkda = nimare.meta.MKDADensity(
kernel_transformer=kt, null_method="empirical", n_iters=100
)
mkda.fit(dset)
corr = nimare.correct.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 IndexError:
print(
"\nError: the %s does not currently work with the MKDA meta-analysis method\n"
% kt_name
)
Out:
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 4.92it/s]
20%|## | 2/10 [00:00<00:01, 4.94it/s]
30%|### | 3/10 [00:00<00:01, 4.96it/s]
40%|#### | 4/10 [00:00<00:01, 4.95it/s]
50%|##### | 5/10 [00:01<00:01, 4.97it/s]
60%|###### | 6/10 [00:01<00:00, 4.94it/s]
70%|####### | 7/10 [00:01<00:00, 4.97it/s]
80%|######## | 8/10 [00:01<00:00, 4.99it/s]
90%|######### | 9/10 [00:01<00:00, 5.00it/s]
100%|##########| 10/10 [00:02<00:00, 4.99it/s]
100%|##########| 10/10 [00:02<00:00, 4.97it/s]
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 4.86it/s]
20%|## | 2/10 [00:00<00:01, 4.81it/s]
30%|### | 3/10 [00:00<00:01, 4.85it/s]
40%|#### | 4/10 [00:00<00:01, 4.86it/s]
50%|##### | 5/10 [00:01<00:01, 4.89it/s]
60%|###### | 6/10 [00:01<00:00, 4.91it/s]
70%|####### | 7/10 [00:01<00:00, 4.91it/s]
80%|######## | 8/10 [00:01<00:00, 4.91it/s]
90%|######### | 9/10 [00:01<00:00, 4.91it/s]
100%|##########| 10/10 [00:02<00:00, 4.91it/s]
100%|##########| 10/10 [00:02<00:00, 4.89it/s]
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 4.51it/s]
20%|## | 2/10 [00:00<00:01, 4.52it/s]
30%|### | 3/10 [00:00<00:01, 4.51it/s]
40%|#### | 4/10 [00:00<00:01, 4.51it/s]
50%|##### | 5/10 [00:01<00:01, 4.52it/s]
60%|###### | 6/10 [00:01<00:00, 4.52it/s]
70%|####### | 7/10 [00:01<00:00, 4.51it/s]
80%|######## | 8/10 [00:01<00:00, 4.51it/s]
90%|######### | 9/10 [00:01<00:00, 4.51it/s]
100%|##########| 10/10 [00:02<00:00, 4.49it/s]
100%|##########| 10/10 [00:02<00:00, 4.51it/s]
MKDA Chi2¶
for kt_name, kt in kernel_transformers.items():
try:
mkda = nimare.meta.MKDAChi2(kernel_transformer=kt)
dset1 = dset.slice(dset.ids)
dset2 = dset.slice(dset.ids)
mkda.fit(dset1, dset2)
corr = nimare.correct.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 IndexError:
print(
"\nError: the %s does not currently work with the MKDA Chi2 meta-analysis method\n"
% kt_name
)
Out:
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:02, 3.02it/s]
20%|## | 2/10 [00:00<00:02, 3.09it/s]
30%|### | 3/10 [00:00<00:02, 3.12it/s]
40%|#### | 4/10 [00:01<00:01, 3.12it/s]
50%|##### | 5/10 [00:01<00:01, 3.12it/s]
60%|###### | 6/10 [00:01<00:01, 3.12it/s]
70%|####### | 7/10 [00:02<00:00, 3.12it/s]
80%|######## | 8/10 [00:02<00:00, 3.12it/s]
90%|######### | 9/10 [00:02<00:00, 3.12it/s]
100%|##########| 10/10 [00:03<00:00, 3.12it/s]
100%|##########| 10/10 [00:03<00:00, 3.11it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.5/lib/python3.7/site-packages/nilearn/plotting/displays.py:786: 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.93it/s]
20%|## | 2/10 [00:00<00:02, 2.99it/s]
30%|### | 3/10 [00:00<00:02, 3.04it/s]
40%|#### | 4/10 [00:01<00:01, 3.04it/s]
50%|##### | 5/10 [00:01<00:01, 3.01it/s]
60%|###### | 6/10 [00:01<00:01, 3.02it/s]
70%|####### | 7/10 [00:02<00:00, 3.02it/s]
80%|######## | 8/10 [00:02<00:00, 3.00it/s]
90%|######### | 9/10 [00:02<00:00, 3.01it/s]
100%|##########| 10/10 [00:03<00:00, 3.02it/s]
100%|##########| 10/10 [00:03<00:00, 3.02it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.5/lib/python3.7/site-packages/nilearn/plotting/displays.py:786: 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.51it/s]
30%|### | 3/10 [00:01<00:02, 2.52it/s]
40%|#### | 4/10 [00:01<00:02, 2.49it/s]
50%|##### | 5/10 [00:01<00:02, 2.50it/s]
60%|###### | 6/10 [00:02<00:01, 2.51it/s]
70%|####### | 7/10 [00:02<00:01, 2.52it/s]
80%|######## | 8/10 [00:03<00:00, 2.52it/s]
90%|######### | 9/10 [00:03<00:00, 2.51it/s]
100%|##########| 10/10 [00:03<00:00, 2.52it/s]
100%|##########| 10/10 [00:03<00:00, 2.51it/s]
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/0.0.5/lib/python3.7/site-packages/nilearn/plotting/displays.py:786: UserWarning: empty mask
get_mask_bounds(new_img_like(img, not_mask, affine))
KDA¶
for kt_name, kt in kernel_transformers.items():
try:
kda = nimare.meta.KDA(kernel_transformer=kt, null_method="empirical", n_iters=100)
kda.fit(dset)
corr = nimare.correct.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 IndexError:
print(
"\nError: the %s does not currently work with the KDA meta-analysis method\n" % kt_name
)
Out:
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 5.29it/s]
20%|## | 2/10 [00:00<00:01, 5.43it/s]
30%|### | 3/10 [00:00<00:01, 5.46it/s]
40%|#### | 4/10 [00:00<00:01, 5.49it/s]
50%|##### | 5/10 [00:00<00:00, 5.56it/s]
60%|###### | 6/10 [00:01<00:00, 5.57it/s]
70%|####### | 7/10 [00:01<00:00, 5.59it/s]
80%|######## | 8/10 [00:01<00:00, 5.59it/s]
90%|######### | 9/10 [00:01<00:00, 5.60it/s]
100%|##########| 10/10 [00:01<00:00, 5.60it/s]
100%|##########| 10/10 [00:01<00:00, 5.55it/s]
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 5.45it/s]
20%|## | 2/10 [00:00<00:01, 5.45it/s]
30%|### | 3/10 [00:00<00:01, 5.41it/s]
40%|#### | 4/10 [00:00<00:01, 5.42it/s]
50%|##### | 5/10 [00:00<00:00, 5.41it/s]
60%|###### | 6/10 [00:01<00:00, 5.43it/s]
70%|####### | 7/10 [00:01<00:00, 5.44it/s]
80%|######## | 8/10 [00:01<00:00, 5.44it/s]
90%|######### | 9/10 [00:01<00:00, 5.42it/s]
100%|##########| 10/10 [00:01<00:00, 5.41it/s]
100%|##########| 10/10 [00:01<00:00, 5.42it/s]
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 5.01it/s]
20%|## | 2/10 [00:00<00:01, 5.00it/s]
30%|### | 3/10 [00:00<00:01, 5.00it/s]
40%|#### | 4/10 [00:00<00:01, 5.02it/s]
50%|##### | 5/10 [00:00<00:00, 5.01it/s]
60%|###### | 6/10 [00:01<00:00, 5.00it/s]
70%|####### | 7/10 [00:01<00:00, 5.00it/s]
80%|######## | 8/10 [00:01<00:00, 5.00it/s]
90%|######### | 9/10 [00:01<00:00, 5.01it/s]
100%|##########| 10/10 [00:01<00:00, 5.01it/s]
100%|##########| 10/10 [00:01<00:00, 5.01it/s]
ALE¶
for kt_name, kt in kernel_transformers.items():
try:
ale = nimare.meta.ALE(kernel_transformer=kt)
ale.fit(dset)
corr = nimare.correct.FWECorrector(method="montecarlo", n_iters=10, n_cores=1)
cres = corr.transform(ale.results)
plot_stat_map(
cres.get_map("logp_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 IndexError:
print(
"\nError: the %s does not currently work with the ALE meta-analysis method\n" % kt_name
)
Out:
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 5.02it/s]
20%|## | 2/10 [00:00<00:01, 5.01it/s]
30%|### | 3/10 [00:00<00:01, 5.03it/s]
40%|#### | 4/10 [00:00<00:01, 5.02it/s]
50%|##### | 5/10 [00:00<00:00, 5.02it/s]
60%|###### | 6/10 [00:01<00:00, 4.99it/s]
70%|####### | 7/10 [00:01<00:00, 5.01it/s]
80%|######## | 8/10 [00:01<00:00, 5.04it/s]
90%|######### | 9/10 [00:01<00:00, 5.02it/s]
100%|##########| 10/10 [00:01<00:00, 5.03it/s]
100%|##########| 10/10 [00:01<00:00, 5.02it/s]
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 4.98it/s]
20%|## | 2/10 [00:00<00:01, 4.95it/s]
30%|### | 3/10 [00:00<00:01, 4.95it/s]
40%|#### | 4/10 [00:00<00:01, 4.97it/s]
50%|##### | 5/10 [00:01<00:01, 4.93it/s]
60%|###### | 6/10 [00:01<00:00, 4.89it/s]
70%|####### | 7/10 [00:01<00:00, 4.91it/s]
80%|######## | 8/10 [00:01<00:00, 4.96it/s]
90%|######### | 9/10 [00:01<00:00, 4.95it/s]
100%|##########| 10/10 [00:02<00:00, 4.92it/s]
100%|##########| 10/10 [00:02<00:00, 4.93it/s]
0%| | 0/10 [00:00<?, ?it/s]
10%|# | 1/10 [00:00<00:01, 4.74it/s]
20%|## | 2/10 [00:00<00:01, 4.71it/s]
30%|### | 3/10 [00:00<00:01, 4.69it/s]
40%|#### | 4/10 [00:00<00:01, 4.66it/s]
50%|##### | 5/10 [00:01<00:01, 4.65it/s]
60%|###### | 6/10 [00:01<00:00, 4.66it/s]
70%|####### | 7/10 [00:01<00:00, 4.66it/s]
80%|######## | 8/10 [00:01<00:00, 4.68it/s]
90%|######### | 9/10 [00:01<00:00, 4.67it/s]
100%|##########| 10/10 [00:02<00:00, 4.67it/s]
100%|##########| 10/10 [00:02<00:00, 4.67it/s]
Total running time of the script: ( 1 minutes 43.002 seconds)