neurostuff / NiMARE

Coordinate- and image-based meta-analysis in Python
https://nimare.readthedocs.io
MIT License
178 stars 58 forks source link

Collection not found with convert_neurovault_to_dataset() - Extraction from Neurovault with collection's ID #574

Closed gnbattist closed 3 years ago

gnbattist commented 3 years ago

Hi everyone!

I open this issu because when I try to run my meta analysis script, my terminal report a error. Apparently, I can't extract data (as json file?) from NeuroVault with the collection IDs.

My script:

from nimare.io import convert_neurovault_to_dataset

# The specific collections I would like to download group level
# statistical maps from
collection_ids = (48858, 48859, 48860, 48861, 48862, 48863, 48864, 48865, 48866, 48867, 48868, 48869, 453291, 64897, 64898, 64899, 64900, 65068, 65066, 65067, 306480, 306481, 306482, 306483, 306484, 306485, 306486, 306487, 306488)

# A mapping between what I want the contrast(s) to be
# named in the dataset and what their respective group
# statistical maps are named on neurovault
contrasts = {
    "dyad synchrony": (
        "Cerebellum"
        "DMN1"
        "DMN2"
        "FPNL"
        "FPNR"
        "Limbic"
        "Salience"
        "Somatosensory"
        "VentralStream"
        "Visual1"
        "Visual2"
        "Visual3"
        "Effect of ideoloy similarity on neural synchrony during political debate"
        "General ISC"
        "HC vs LC ISC"
        "General ISPS"
        "HC vs LC ISPS"
        "Cue > (Math + Feedback)"
        "children's brain self-family contrast negatively correlated with the relationship quality"
        "children's brain self-family contrast negatively correlated with the perceptual similarity (ffa rsa value)"
        "Parents' response to feedback, no errors"
        "Adolescents' response to feedback, no errors"
        "Parent vs adolescent response to feedback, no errors"
        "Parents' response to adolescent error feedback"
        "Adolescents' response to parent error feedback"
        "Parent vs adolescent response to dyadic error feedback"
        "Parents' response to adolescent error feedback vs Parents' response to feedback, no errors"
        "Adolescents' response to parent error feedback vs Adolescents' response to feedback, no errors"
        "Parent vs adolescent response to dyadic error feedback vs feedback, no errors"
    )
}

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

dset = convert_neurovault_to_dataset(
    collection_ids,
    contrasts,
    img_dir="/Users/ginodiez/Desktop/Cogmaster/M1/LNC2/meta",
    map_type_conversion=map_type_conversion,
)

from nimare.transforms import ImageTransformer

# Not all studies have Z maps!
#print(dset.images["z"])

z_transformer = ImageTransformer(target="z")
dset = z_transformer.transform(dset)

# All studies now have Z maps!
#print(dset.images["z"])

from nilearn.plotting import plot_stat_map

from nimare.meta.ibma import Fishers

meta = Fishers()

meta_res = meta.fit(dset)

plot_stat_map(meta_res.get_map("z"), threshold=3.3)
# The result may look questionable, but this code provides
# a template on how to use neurovault in your meta analysis.

The terminal response:

Dataset created in /Users/ginodiez/Desktop/Cogmaster/M1/LNC2/meta/dyad synchrony

Traceback (most recent call last):
  File "statmap_neurovault.py", line 48, in <module>
    dset = convert_neurovault_to_dataset(
  File "/Users/ginodiez/opt/anaconda3/lib/python3.8/site-packages/nimare/io.py", line 374, in convert_neurovault_to_dataset
    raise ValueError(
ValueError: Collection 48858 not found. Three likely causes are (1) the collection doesn't exist, (2) the collection is private, or (3) the provided ID corresponds to an image instead of a collection

My aim: run a meta analysis and extract pattern of activation from NeuroVault to produce a statistical map.

At the end, the "dyad synchrony" file is correctly create in "/Users/ginodiez/Desktop/Cogmaster/M1/LNC2/meta", but it's empty.

Can someone have a solution to properly extract data from NeuroVault and save the result figure?

tsalo commented 3 years ago

@jdkent would you be willing to take a look at this? I'm not really familiar with the NeuroVault extraction/conversion code.

jdkent commented 3 years ago

Hi @gnodix,

Are the collections you want to use private? for example, this collection exists and is public: https://neurovault.org/collections/4606/

but I cannot access the collection specified in the error message you posted: https://neurovault.org/collections/48858/,

It looks like you selecting images instead since this url does exist: https://neurovault.org/images/48858/

try replacing all the image locations with collection ids, image 48858 for example is a part of collection 2525 (https://neurovault.org/collections/2525/)

let me know if that fixes the error you are having!

gnbattist commented 3 years ago

Thank you for your response!

It's actually work, but very disappointing that I can select specific sub-collection (as 48857 in 2525)...

Nevertheless, I have another problem not reported in the sample_size (in the same function convert_neurovault_to_dataset()).

I will open a new issu on it