Fetching URLs from OpenNeuro

Dear NeuroStars,

I’m trying to download data from OpenNeuro website using the function fetch_openneuro_dataset from nilearn: nilearn.datasets.fetch_openneuro_dataset - Nilearn

However, I would need to provide a list of urls (input ‘url’ in the function above) in order to download the data. I would like to use the fetch_openneuro_dataset because I could download data only from some subjects.

Is there an easy way to get this list of urls from OpenNeuro and download then with nilearn?

Many thanks!

Hey @gustavopamplona

Even though nilearn has this function, I would argue that it is not the best tool for this job, especially to “download data only from some subjects” because of the very problem you are facing.

I would recommend using datalad for this.

Check this page for more info: OpenNeuro Quickstart Guide: Accessing OpenNeuro datasets via DataLad — The DataLad Handbook

Each openeuro dataset gives you the command to access it with datalad.
For example: OpenNeuro

I would recommend checking at least the 2 first chapters of the fantastic datalad handbook to avoid some pains later: The Handbook — The DataLad Handbook

But in brief things would look like this

# install dataset
datalad install https://github.com/OpenNeuroDatasets/ds004848.git
# get the data you need (here the 2 first subjects)
cd ds004848
dataladd get sub-DP01 sub-DP01

Note that datalad also has a python API if you want to stay in the world of python.

1 Like

Many thanks, @Remi-Gau. Your suggestion worked perfectly for me.

1 Like