Note
Go to the end to download the full example code.
Compare image and coordinate based meta-analyses
Run IBMAs and CBMAs on a toy Studyset, then compare the results qualitatively.
Collection of NIDM-Results packs downloaded from Neurovault collection 1425, uploaded by Dr. Camille Maumet.
import os
import pandas as pd
from nilearn.plotting import plot_stat_map
from nimare.extract import download_nidm_pain
from nimare.meta.cbma import ALE
from nimare.meta.ibma import DerSimonianLaird
from nimare.nimads import Studyset
from nimare.transforms import ImagesToCoordinates, ImageTransformer
from nimare.utils import get_resource_path
Download data
Load Studyset
studyset_file = os.path.join(get_resource_path(), "nidm_pain_studyset.json")
studyset = Studyset(studyset_file, target="mni152_2mm")
studyset.update_path(dset_dir)
# Calculate missing statistical images from the available stats.
xformer = ImageTransformer(target=["varcope"])
studyset = xformer.transform(studyset)
# create coordinates from statistical maps
coord_gen = ImagesToCoordinates(merge_strategy="fill")
studyset = coord_gen.transform(studyset)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:355: UserWarning: imgs are being resampled to the mask_img resolution. This process is memory intensive. You might want to provide a target_affine that is equal to the affine of the imgs or resample the mask beforehand to save memory and computation time.
se = masker.transform(available_data["se"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/nilearn/image/image.py:540: RuntimeWarning: overflow encountered in scalar negative
infinity_norm = max(-data.min(), data.max())
ALE (CBMA)
meta_cbma = ALE()
cbma_results = meta_cbma.fit(studyset)
plot_stat_map(
cbma_results.get_map("z"),
cut_coords=[0, 0, -8],
draw_cross=False,
cmap="RdBu_r",
symmetric_cbar=True,
)

<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x78fa386f2ba0>
DerSimonian-Laird (IBMA)
meta_ibma = DerSimonianLaird()
ibma_results = meta_ibma.fit(studyset)
plot_stat_map(
ibma_results.get_map("z"),
cut_coords=[0, 0, -8],
draw_cross=False,
cmap="RdBu_r",
symmetric_cbar=True,
)

/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/meta/ibma.py:133: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/envs/latest/lib/python3.13/site-packages/numpy/_core/numeric.py:386: RuntimeWarning: invalid value encountered in cast
multiarray.copyto(a, fill_value, casting='unsafe')
<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x78fa386f2780>
Compare CBMA and IBMA Z-maps
stat_df = pd.DataFrame(
{
"CBMA": cbma_results.get_map("z", return_type="array"),
"IBMA": ibma_results.get_map("z", return_type="array"),
}
)
print(stat_df.corr())
CBMA IBMA
CBMA 1.00000 0.52153
IBMA 0.52153 1.00000
Total running time of the script: (0 minutes 8.075 seconds)