Trouble extracting data from a NiMARE Dataset object using slice() method

Summary of what happened:

I am struggling to get the coordinates from four studies I want to analyze from Neurosynth. I downloaded the full Neurosynth database and then used the slice() method with ids, stored in a 1D numpy array. Even though when I print the new data set it says it includes four experiments, when I try to view their ids, coordinates, etc. the sections are empty.

Command used (and if a helper script was used, a link to the helper script or the command generated):

import numpy as np
ids = np.array([21568643,26610651,11087002,18510438])
neuro_dset = neurosynth_dset.slice(ids), "sliced_neurosynth.pkl.gz"))


The version was python 3.8.10

Environment (Docker, Singularity, custom installation):

I did everything in Google Colab because for some reason I could not install nimare on my machine.

Data formatted according to a validatable standard? Please provide the output of the validator:

I used NiMARE’s documentation’s recommended way of extracting the data from Neurosynth and converting it into a .pkl.gz dataset:

out_dir = os.path.abspath("/example_data/")
os.makedirs(out_dir, exist_ok=True)

files = fetch_neurosynth(
# Note that the files are saved to a new folder within "out_dir" named "neurosynth".
neurosynth_db = files[0]
neurosynth_dset = convert_neurosynth_to_dataset(
), "neurosynth_dataset.pkl.gz"))

Relevant log outputs (up to 20 lines):

“Dataset(4 experiments, space=‘mni152_2mm’)”

Screenshots / relevant information:


Can you try using the full Neurosynth IDs as strings?

ids = ["21568643-1", "26610651-1", "11087002-1", "18510438-1"]

Hi Taylor! Yes, that worked. Thank you so much.

Hi Taylor,
On another note, when I am trying to initialize a meta analysis object and to fit it to my data, I receive a KeyError ‘sample_size’. I tried creating a kernel object despite the default to ALEKernel like so:

ale = nimare.meta.kernel.ALEKernel()

and then passing it as a key:

meta1 = nimare.meta.cbma.ale.ALE(kernel_transformer = ale, null_model="approximate")

but it did not change anything.

I also tried modifying the kernel object itself by passing different values for the key sample_size:

ale = nimare.meta.kernel.ALEKernel(sample_size = None)

but I am still getting an error.

I am not sure where exactly I should define the sample size. I tried the same code for a bigger dataset, because I assumed four studies might be too little, but the same error showed up.

The ALE kernel’s FWHM depends on the study’s sample size, so the ALEKernel object will attempt to extract experiment-wise sample sizes from the Dataset, which explains the failure. Given that you’re using the Neurosynth dataset, which doesn’t have sample size information, you can set a constant sample size to use across studies. That value can’t be None, because it still needs some way to determine the appropriate FWHM of the kernel, but it can be a reasonable sample size for the literature (e.g., 20 or 30). In that situation, you can just do what you did, except provide a number instead of None.

kernel = nimare.meta.kernel.ALEKernel(sample_size=20)
meta1 = nimare.meta.cbma.ALE(kernel_transformer=kernel, null_model="approximate")
meta_results1 =

Also, it’s a minor thing, but in the screen shot you shared, you called the Estimator object meta1, but you ran, so I worry that you were fitting an old object, rather than the new one you provided the kernel to.

Thank you, the solution worked. The screenshot was to showcase the mistake; I just played with some test datasets and so I changed some variable names before running it. I appreciate the reminder.