Use NeuroVault statistical maps in NiMARE

Download statistical maps from NeuroVault, then use them in a meta-analysis, with NiMARE.

import matplotlib.pyplot as plt
from nilearn.plotting import plot_stat_map

Neurovault + NiMARE: Load freely shared statistical maps for Meta-Analysis

Neurovault is an online platform that hosts unthresholded statistical maps, including group statistical maps. NiMARE can read these statistical maps when given a list of collection_ids. I search “working memory” on neurovault, and find these relevant collections:

I can load specific statistical maps from these collections directly into a Studyset for analysis:

from nimare.generate import create_neurovault_studyset

# The specific collections I would like to download group level
# statistical maps from
collection_ids = (2884, 2621, 3085, 5623, 3264, 3192, 457)

# A mapping between what I want the contrast(s) to be
# named in the Studyset and what their respective group
# statistical maps are named on neurovault
contrasts = {
    "working_memory": (
        "Working memory load of 2 faces versus 1 face - NT2_Tstat|"
        "t-value contrast 2-back minus 0-back|"
        "Searchlight multivariate Decoding 2: visual working memory|"
        "Context-dependent group-specific WM information|"
        "WM working memory zstat1|"
        "WM task over CRT task map|"
        "tfMRI WM 2BK PLACE zstat1"
    )
}

# Convert how the statistical maps on neurovault are represented
# in a NiMARE Studyset.
map_type_conversion = {"Z map": "z", "T map": "t"}

studyset = create_neurovault_studyset(
    collection_ids,
    contrasts,
    img_dir=None,
    map_type_conversion=map_type_conversion,
)
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:310: 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.
  t = masker.transform(available_data["t"])
/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:310: 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.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:310: 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.
  t = masker.transform(available_data["t"])
/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:310: 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.
  t = masker.transform(available_data["t"])
/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:310: 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.
  t = masker.transform(available_data["t"])
/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())

Conversion of Statistical Maps

create_neurovault_studyset already resolves compatible image types. To explicitly demonstrate ImageTransformer on a Studyset-backed collection, we drop the derived Z maps from contrasts that still have T maps and regenerate them.

from nimare.transforms import ImageTransformer

images = studyset.images.copy()
images.loc[images["t"].notnull(), "z"] = None
studyset.images = images

# Some studies are now missing Z maps again.
studyset.images[["t", "z"]]
t z
0 /home/docs/.nimare/working_memory/collection-2... None
1 /home/docs/.nimare/working_memory/collection-2... None
2 /home/docs/.nimare/working_memory/collection-3... None
3 None /home/docs/.nimare/working_memory/collection-3...
4 None /home/docs/.nimare/working_memory/collection-3...
5 None /home/docs/.nimare/working_memory/collection-4...
6 /home/docs/.nimare/working_memory/collection-5... None


/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:310: 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.
  t = masker.transform(available_data["t"])
/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:310: 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.
  t = masker.transform(available_data["t"])
/home/docs/checkouts/readthedocs.org/user_builds/nimare/checkouts/latest/nimare/transforms.py:310: 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.
  t = masker.transform(available_data["t"])
/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:310: 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.
  t = masker.transform(available_data["t"])
/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:310: 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.
  t = masker.transform(available_data["t"])
/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())

All studies now have Z maps again.

z
0 /home/docs/.nimare/study-2621-working_memory_2...
1 /home/docs/.nimare/study-2884-working_memory_2...
2 /home/docs/.nimare/study-3085-working_memory_2...
3 /home/docs/.nimare/working_memory/collection-3...
4 /home/docs/.nimare/working_memory/collection-3...
5 /home/docs/.nimare/working_memory/collection-4...
6 /home/docs/.nimare/study-5623-working_memory_2...


Run a Meta-Analysis

With the missing Z maps filled in, we can run a Meta-Analysis and plot our results

from nimare.meta.ibma import Fishers

# The default template has a slightly different, but completely compatible,
# affine than the NeuroVault images, so we allow the Estimator to resample
# images during the fitting process.
meta = Fishers(resample=True)

# Drop studies that have no Z map (e.g. collections with no downloadable images).
has_z = studyset.images["z"].notnull()
valid_ids = studyset.images.loc[has_z, "id"].tolist()
if valid_ids:
    studyset = studyset.filter_ids(valid_ids)

meta_res = meta.fit(studyset)

fig, ax = plt.subplots()
display = plot_stat_map(meta_res.get_map("z"), threshold=3.3, axes=ax, figure=fig)
fig.show()
# The result may look questionable, but this code provides
# a template on how to use neurovault in your meta analysis.
03 plot neurovault io
/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')

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

Gallery generated by Sphinx-Gallery