Hello everyone! Pardon my inexperience with programming, I’m sure this is a simple task.
I’m trying to pull unthresholded images from the term-based meta-analysis data published on neurosynth, but I’m having difficulties because it is deprecated. I have been slowly learning other options such as NiMARE, but it seems like there are a lot of different packages to learn.
I was wondering if anyone could point me in the direction of a package/repository that would allow me to either access these unthresholded images, or to generate new ones using the same process.
Again, apologies for the simplicity of the question, I haven’t found a good answer anywhere. Thanks.
I don’t believe the unthresholded maps are available in bulk anywhere, so I can see three possible solutions:
Go to each term’s page on Neurosynth and download the maps by hand.
Write a script to scrape the maps from the website. I wouldn’t recommend doing this, as the Neurosynth documentation explicitly warns that web scraping attempts will result in a permanent IP ban. See the Data section here for that warning.
Use NiMARE. I’ve drafted some code that should work, though it’ll take a while.
import nimare
# Download the Neurosynth data and convert to a NiMARE Dataset
nimare.extract.fetch_neurosynth("data/", unpack=True)
ns_dset = nimare.io.convert_neurosynth_to_dataset(
"data/database.txt",
"data/features.txt",
)
# Initialize a meta-analysis
meta = nimare.meta.cbma.mkda.MKDAChi2()
# Get the full list of Neurosynth labels
# You may want to find a way to reduce this list,
# since it will include a bunch of "terms" that are not useful, like "001"
terms = ns_dset.get_labels()
all_ids = ns_dset.ids
for term in terms:
# Remember to use a threshold of 0.001 to get associated studies,
# since NiMARE's default is 0.5.
term_ids = ns_dset.get_studies_by_label(term, label_threshold=0.001)
notterm_ids = sorted(list(set(all_ids) - set(term_ids)))
term_dset = ns_dset.slice(term_ids)
notterm_dset = ns_dset.slice(notterm_ids)
# Run the meta-analysis.
# No multiple comparisons correction since you want the unthreshold maps.
results = meta.fit(term_dset, notterm_dset)
# Save the maps to files
term_name = term.split("__")[1]
results.save_maps(out_dir="meta-analyses/", prefix=term_name)