8.6.5. NeuroVault cross-study ICA maps.

This example shows how to download statistical maps from NeuroVault, label them with NeuroSynth terms, and compute ICA components across all the maps.

See nilearn.datasets.fetch_neurovault documentation for more details.

# Author: Ben Cipollini
# License: BSD
# Ported from code authored by Chris Filo Gorgolewski, Gael Varoquaux
# https://github.com/NeuroVault/neurovault_analysis
import warnings

import numpy as np
from scipy import stats
from sklearn.decomposition import FastICA

from nilearn.datasets import fetch_neurovault
from nilearn.image import smooth_img

from nilearn.datasets import load_mni152_brain_mask
from nilearn.input_data import NiftiMasker

from nilearn import plotting

8.6.5.1. Get image and term data

# Download images
# Here by default we only download 80 images to save time,
# but for better results I recommend using at least 200.
print("Fetching Neurovault images; "
      "if you haven't downloaded any Neurovault data before "
      "this will take several minutes.")
nv_data = fetch_neurovault(max_images=80, fetch_neurosynth_words=True)

images = nv_data['images']
term_weights = nv_data['word_frequencies']
vocabulary = nv_data['vocabulary']

# Clean and report term scores
term_weights[term_weights < 0] = 0
total_scores = np.mean(term_weights, axis=0)

print("\nTop 10 neurosynth terms from downloaded images:\n")

for term_idx in np.argsort(total_scores)[-10:][::-1]:
    print(vocabulary[term_idx])

Out:

Fetching Neurovault images; if you haven't downloaded any Neurovault data before this will take several minutes.

Dataset created in /home/kamalakar/nilearn_data/neurovault

Reading local neurovault data.
No image found on local disk.
Reading server neurovault data.
Scroll collections: getting new batch: http://neurovault.org/api/collections/?limit=100&offset=0
Scroll collections: batch size: 100
Scroll images from collection 921: getting new batch: http://neurovault.org/api/collections/921/images/?limit=100&offset=0
Scroll images from collection 921: batch size: 1
On neurovault.org: no image matched query in collection 921
Scroll images from collection 35: getting new batch: http://neurovault.org/api/collections/35/images/?limit=100&offset=0
Scroll images from collection 35: batch size: 4
Downloading file: https://neurovault.org/media/images/35/Fig3B_zstat1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_35/image_110.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=110
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_35/neurosynth_words_for_image_110.json
Already fetched 1 image
Downloading file: https://neurovault.org/media/images/35/Fig3A_zstat1_2.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_35/image_111.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=111
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_35/neurosynth_words_for_image_111.json
Already fetched 2 images
Downloading file: https://neurovault.org/media/images/35/Fig4B_zstat1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_35/image_112.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=112
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_35/neurosynth_words_for_image_112.json
Already fetched 3 images
Downloading file: https://neurovault.org/media/images/35/Fig4A_zstat1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_35/image_113.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=113
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_35/neurosynth_words_for_image_113.json
Already fetched 4 images
On neurovault.org: 4 images matched query in collection 35
Scroll images from collection 440: getting new batch: http://neurovault.org/api/collections/440/images/?limit=100&offset=0
Scroll images from collection 440: batch size: 2
On neurovault.org: no image matched query in collection 440
Scroll images from collection 496: getting new batch: http://neurovault.org/api/collections/496/images/?limit=100&offset=0
Scroll images from collection 496: batch size: 1
On neurovault.org: no image matched query in collection 496
Scroll images from collection 1054: getting new batch: http://neurovault.org/api/collections/1054/images/?limit=100&offset=0
Scroll images from collection 1054: batch size: 40
Downloading file: https://neurovault.org/media/images/1054/vol0000.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14181.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14181
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14181.json
Already fetched 5 images
Downloading file: https://neurovault.org/media/images/1054/vol0001.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14182.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14182
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14182.json
Already fetched 6 images
Downloading file: https://neurovault.org/media/images/1054/vol0002.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14183.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14183
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14183.json
Already fetched 7 images
Downloading file: https://neurovault.org/media/images/1054/vol0003.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14184.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14184
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14184.json
Already fetched 8 images
Downloading file: https://neurovault.org/media/images/1054/vol0004.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14185.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14185
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14185.json
Already fetched 9 images
Downloading file: https://neurovault.org/media/images/1054/vol0005.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14186.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14186
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14186.json
Already fetched 10 images
Downloading file: https://neurovault.org/media/images/1054/vol0006.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14187.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14187
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14187.json
Already fetched 11 images
Downloading file: https://neurovault.org/media/images/1054/vol0007.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14188.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14188
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14188.json
Already fetched 12 images
Downloading file: https://neurovault.org/media/images/1054/vol0008.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14189.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14189
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14189.json
Already fetched 13 images
Downloading file: https://neurovault.org/media/images/1054/vol0009.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14190.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14190
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14190.json
Already fetched 14 images
Downloading file: https://neurovault.org/media/images/1054/vol0010.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14191.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14191
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14191.json
Already fetched 15 images
Downloading file: https://neurovault.org/media/images/1054/vol0011.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14192.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14192
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14192.json
Already fetched 16 images
Downloading file: https://neurovault.org/media/images/1054/vol0012.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14193.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14193
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14193.json
Already fetched 17 images
Downloading file: https://neurovault.org/media/images/1054/vol0013.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14194.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14194
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14194.json
Already fetched 18 images
Downloading file: https://neurovault.org/media/images/1054/vol0014.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14195.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14195
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14195.json
Already fetched 19 images
Downloading file: https://neurovault.org/media/images/1054/vol0015.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14196.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14196
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14196.json
Already fetched 20 images
Downloading file: https://neurovault.org/media/images/1054/vol0016.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14197.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14197
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14197.json
Already fetched 21 images
Downloading file: https://neurovault.org/media/images/1054/vol0017.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14198.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14198
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14198.json
Already fetched 22 images
Downloading file: https://neurovault.org/media/images/1054/vol0018.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14199.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14199
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14199.json
Already fetched 23 images
Downloading file: https://neurovault.org/media/images/1054/vol0019.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14200.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14200
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14200.json
Already fetched 24 images
Downloading file: https://neurovault.org/media/images/1054/vol0000_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14201.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14201
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14201.json
Already fetched 25 images
Downloading file: https://neurovault.org/media/images/1054/vol0001_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14202.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14202
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14202.json
Already fetched 26 images
Downloading file: https://neurovault.org/media/images/1054/vol0002_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14203.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14203
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14203.json
Already fetched 27 images
Downloading file: https://neurovault.org/media/images/1054/vol0003_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14204.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14204
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14204.json
Already fetched 28 images
Downloading file: https://neurovault.org/media/images/1054/vol0004_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14205.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14205
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14205.json
Already fetched 29 images
Downloading file: https://neurovault.org/media/images/1054/vol0005_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14206.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14206
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14206.json
Already fetched 30 images
Downloading file: https://neurovault.org/media/images/1054/vol0006_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14207.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14207
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14207.json
Already fetched 31 images
Downloading file: https://neurovault.org/media/images/1054/vol0007_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14208.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14208
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14208.json
Already fetched 32 images
Downloading file: https://neurovault.org/media/images/1054/vol0008_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14209.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14209
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14209.json
Already fetched 33 images
Downloading file: https://neurovault.org/media/images/1054/vol0009_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14210.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14210
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14210.json
Already fetched 34 images
Downloading file: https://neurovault.org/media/images/1054/vol0010_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14211.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14211
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14211.json
Already fetched 35 images
Downloading file: https://neurovault.org/media/images/1054/vol0011_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14212.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14212
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14212.json
Already fetched 36 images
Downloading file: https://neurovault.org/media/images/1054/vol0012_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14213.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14213
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14213.json
Already fetched 37 images
Downloading file: https://neurovault.org/media/images/1054/vol0013_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14214.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14214
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14214.json
Already fetched 38 images
Downloading file: https://neurovault.org/media/images/1054/vol0014_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14215.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14215
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14215.json
Already fetched 39 images
Downloading file: https://neurovault.org/media/images/1054/vol0015_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14216.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14216
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14216.json
Already fetched 40 images
Downloading file: https://neurovault.org/media/images/1054/vol0016_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14217.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14217
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14217.json
Already fetched 41 images
Downloading file: https://neurovault.org/media/images/1054/vol0017_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14218.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14218
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14218.json
Already fetched 42 images
Downloading file: https://neurovault.org/media/images/1054/vol0018_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14219.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14219
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14219.json
Already fetched 43 images
Downloading file: https://neurovault.org/media/images/1054/vol0019_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/image_14220.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14220
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1054/neurosynth_words_for_image_14220.json
Already fetched 44 images
On neurovault.org: 40 images matched query in collection 1054
Scroll images from collection 4: getting new batch: http://neurovault.org/api/collections/4/images/?limit=100&offset=0
Scroll images from collection 4: batch size: 1
On neurovault.org: no image matched query in collection 4
Scroll images from collection 79: getting new batch: http://neurovault.org/api/collections/79/images/?limit=100&offset=0
Scroll images from collection 79: batch size: 5
Downloading file: https://neurovault.org/media/images/79/neurosynth_spectral_01.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_79/image_11020.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=11020
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_79/neurosynth_words_for_image_11020.json
Already fetched 45 images
Downloading file: https://neurovault.org/media/images/79/neurosynth_spectral_01_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_79/image_11021.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=11021
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_79/neurosynth_words_for_image_11021.json
Already fetched 46 images
On neurovault.org: 2 images matched query in collection 79
Scroll images from collection 1257: getting new batch: http://neurovault.org/api/collections/1257/images/?limit=100&offset=0
Scroll images from collection 1257: batch size: 100
Scroll images from collection 1257: getting new batch: http://neurovault.org/api/collections/1257/images/?limit=100&offset=100
Scroll images from collection 1257: batch size: 100
Scroll images from collection 1257: getting new batch: http://neurovault.org/api/collections/1257/images/?limit=100&offset=200
Scroll images from collection 1257: batch size: 100
Scroll images from collection 1257: getting new batch: http://neurovault.org/api/collections/1257/images/?limit=100&offset=300
Scroll images from collection 1257: batch size: 100
Scroll images from collection 1257: getting new batch: http://neurovault.org/api/collections/1257/images/?limit=100&offset=400
Scroll images from collection 1257: batch size: 100
Scroll images from collection 1257: getting new batch: http://neurovault.org/api/collections/1257/images/?limit=100&offset=500
Scroll images from collection 1257: batch size: 100
Scroll images from collection 1257: getting new batch: http://neurovault.org/api/collections/1257/images/?limit=100&offset=600
Scroll images from collection 1257: batch size: 14
On neurovault.org: no image matched query in collection 1257
Scroll images from collection 70: getting new batch: http://neurovault.org/api/collections/70/images/?limit=100&offset=0
Scroll images from collection 70: batch size: 1
On neurovault.org: no image matched query in collection 70
Scroll images from collection 3146: getting new batch: http://neurovault.org/api/collections/3146/images/?limit=100&offset=0
Scroll images from collection 3146: batch size: 1
Downloading file: https://neurovault.org/media/images/3146/prediction_errors.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_3146/image_56803.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=56803
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_3146/neurosynth_words_for_image_56803.json
Already fetched 47 images
On neurovault.org: 1 image matched query in collection 3146
Scroll images from collection 1962: getting new batch: http://neurovault.org/api/collections/1962/images/?limit=100&offset=0
Scroll images from collection 1962: batch size: 1
On neurovault.org: no image matched query in collection 1962
Scroll images from collection 1284: getting new batch: http://neurovault.org/api/collections/1284/images/?limit=100&offset=0
Scroll images from collection 1284: batch size: 2
Downloading file: https://neurovault.org/media/images/1284/zstat1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1284/image_18787.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=18787
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1284/neurosynth_words_for_image_18787.json
Already fetched 48 images
Downloading file: https://neurovault.org/media/images/1284/zstat1_1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1284/image_18788.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=18788
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1284/neurosynth_words_for_image_18788.json
Already fetched 49 images
On neurovault.org: 2 images matched query in collection 1284
Scroll images from collection 1407: getting new batch: http://neurovault.org/api/collections/1407/images/?limit=100&offset=0
Scroll images from collection 1407: batch size: 2
Downloading file: https://neurovault.org/media/images/1407/zstat1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1407/image_20731.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=20731
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1407/neurosynth_words_for_image_20731.json
Already fetched 50 images
Downloading file: https://neurovault.org/media/images/1407/tstat1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1407/image_20732.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=20732
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1407/neurosynth_words_for_image_20732.json
Already fetched 51 images
On neurovault.org: 2 images matched query in collection 1407
Scroll images from collection 215: getting new batch: http://neurovault.org/api/collections/215/images/?limit=100&offset=0
Scroll images from collection 215: batch size: 1
On neurovault.org: no image matched query in collection 215
Scroll images from collection 1194: getting new batch: http://neurovault.org/api/collections/1194/images/?limit=100&offset=0
Scroll images from collection 1194: batch size: 2
Downloading file: https://neurovault.org/media/images/1194/18FDOPA.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1194/image_16252.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=16252
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1194/neurosynth_words_for_image_16252.json
Already fetched 52 images
Downloading file: https://neurovault.org/media/images/1194/123I-FP-CIT.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1194/image_16253.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=16253
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1194/neurosynth_words_for_image_16253.json
Already fetched 53 images
On neurovault.org: 2 images matched query in collection 1194
Scroll images from collection 89: getting new batch: http://neurovault.org/api/collections/89/images/?limit=100&offset=0
Scroll images from collection 89: batch size: 1
On neurovault.org: no image matched query in collection 89
Scroll images from collection 684: getting new batch: http://neurovault.org/api/collections/684/images/?limit=100&offset=0
Scroll images from collection 684: batch size: 1
Downloading file: https://neurovault.org/media/images/684/regularPLS.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_684/image_10764.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=10764
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_684/neurosynth_words_for_image_10764.json
Already fetched 54 images
On neurovault.org: 1 image matched query in collection 684
Scroll images from collection 103: getting new batch: http://neurovault.org/api/collections/103/images/?limit=100&offset=0
Scroll images from collection 103: batch size: 2
On neurovault.org: no image matched query in collection 103
Scroll images from collection 612: getting new batch: http://neurovault.org/api/collections/612/images/?limit=100&offset=0
Scroll images from collection 612: batch size: 1
Downloading file: https://neurovault.org/media/images/612/spmT_0001.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_612/image_9884.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=9884
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_612/neurosynth_words_for_image_9884.json
Already fetched 55 images
On neurovault.org: 1 image matched query in collection 612
Scroll images from collection 1103: getting new batch: http://neurovault.org/api/collections/1103/images/?limit=100&offset=0
Scroll images from collection 1103: batch size: 4
Downloading file: https://neurovault.org/media/images/1103/out_lag1_importanti.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1103/image_14936.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14936
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1103/neurosynth_words_for_image_14936.json
Already fetched 56 images
On neurovault.org: 1 image matched query in collection 1103
Scroll images from collection 1831: getting new batch: http://neurovault.org/api/collections/1831/images/?limit=100&offset=0
Scroll images from collection 1831: batch size: 1
Downloading file: https://neurovault.org/media/images/1831/Z_BeforeThreshold_VMHC_T1.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1831/image_28471.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=28471
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1831/neurosynth_words_for_image_28471.json
Already fetched 57 images
On neurovault.org: 1 image matched query in collection 1831
Scroll images from collection 115: getting new batch: http://neurovault.org/api/collections/115/images/?limit=100&offset=0
Scroll images from collection 115: batch size: 11
On neurovault.org: no image matched query in collection 115
Scroll images from collection 118: getting new batch: http://neurovault.org/api/collections/118/images/?limit=100&offset=0
Scroll images from collection 118: batch size: 1
On neurovault.org: no image matched query in collection 118
Scroll images from collection 1803: getting new batch: http://neurovault.org/api/collections/1803/images/?limit=100&offset=0
Scroll images from collection 1803: batch size: 31
On neurovault.org: no image matched query in collection 1803
Scroll images from collection 2323: getting new batch: http://neurovault.org/api/collections/2323/images/?limit=100&offset=0
Scroll images from collection 2323: batch size: 4
On neurovault.org: no image matched query in collection 2323
Scroll images from collection 1056: getting new batch: http://neurovault.org/api/collections/1056/images/?limit=100&offset=0
Scroll images from collection 1056: batch size: 20
On neurovault.org: no image matched query in collection 1056
Scroll images from collection 1039: getting new batch: http://neurovault.org/api/collections/1039/images/?limit=100&offset=0
Scroll images from collection 1039: batch size: 41
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub001.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14084.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14084
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14084.json
Already fetched 58 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub009.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14085.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14085
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14085.json
Already fetched 59 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub011.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14086.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14086
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14086.json
Already fetched 60 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub015.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14087.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14087
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14087.json
Already fetched 61 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub018.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14088.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14088
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14088.json
Already fetched 62 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub026.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14089.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14089
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14089.json
Already fetched 63 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub028.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14090.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14090
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14090.json
Already fetched 64 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub030.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14091.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14091
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14091.json
Already fetched 65 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub031.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14092.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14092
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14092.json
Already fetched 66 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub033.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14093.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14093
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14093.json
Already fetched 67 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub035.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14094.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14094
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14094.json
Already fetched 68 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub036.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14095.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14095
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14095.json
Already fetched 69 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub041.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14096.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14096
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14096.json
Already fetched 70 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub044.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14097.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14097
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14097.json
Already fetched 71 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub046.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14098.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14098
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14098.json
Already fetched 72 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub050.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14099.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14099
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14099.json
Already fetched 73 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub051.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14100.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14100
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14100.json
Already fetched 74 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub053.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14101.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14101
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14101.json
Already fetched 75 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub056.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14102.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14102
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14102.json
Already fetched 76 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub057.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14103.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14103
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14103.json
Already fetched 77 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub058.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14104.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14104
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14104.json
Already fetched 78 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub059.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14105.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14105
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14105.json
Already fetched 79 images
Downloading file: https://neurovault.org/media/images/1039/zVMHCMap_sub064.nii.gz
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/image_14106.nii.gz
Downloading file: http://neurosynth.org/api/v2/decode/?neurovault=14106
Download succeeded, downloaded to: /home/kamalakar/nilearn_data/neurovault/collection_1039/neurosynth_words_for_image_14106.json
Already fetched 80 images
Computing word features.
Computing word features done; vocabulary size: 2911

Top 10 neurosynth terms from downloaded images:

cingulate
thalamus
posterior cingulate
striatum
cingulate cortex
reward
basal ganglia
ganglia
motor
basal

8.6.5.2. Reshape and mask images

print("\nReshaping and masking images.\n")

with warnings.catch_warnings():
    warnings.simplefilter('ignore', UserWarning)
    warnings.simplefilter('ignore', DeprecationWarning)

    mask_img = load_mni152_brain_mask()
    masker = NiftiMasker(
        mask_img=mask_img, memory='nilearn_cache', memory_level=1)
    masker = masker.fit()

    # Images may fail to be transformed, and are of different shapes,
    # so we need to transform one-by-one and keep track of failures.
    X = []
    is_usable = np.ones((len(images),), dtype=bool)

    for index, image_path in enumerate(images):
        # load image and remove nan and inf values.
        # applying smooth_img to an image with fwhm=None simply cleans up
        # non-finite values but otherwise doesn't modify the image.
        image = smooth_img(image_path, fwhm=None)
        try:
            X.append(masker.transform(image))
        except Exception as e:
            meta = nv_data['images_meta'][index]
            print("Failed to mask/reshape image: id: {0}; "
                  "name: '{1}'; collection: {2}; error: {3}".format(
                      meta.get('id'), meta.get('name'),
                      meta.get('collection_id'), e))
            is_usable[index] = False

# Now reshape list into 2D matrix, and remove failed images from terms
X = np.vstack(X)
term_weights = term_weights[is_usable, :]

Out:

Reshaping and masking images.

8.6.5.3. Run ICA and map components to terms

print("Running ICA; may take time...")
# We use a very small number of components as we have downloaded only 80
# images. For better results, increase the number of images downloaded
# and the number of components
n_components = 16
fast_ica = FastICA(n_components=n_components, random_state=0)
ica_maps = fast_ica.fit_transform(X.T).T

term_weights_for_components = np.dot(fast_ica.components_, term_weights)
print('Done, plotting results.')

Out:

Running ICA; may take time...
Done, plotting results.

8.6.5.4. Generate figures

with warnings.catch_warnings():
    warnings.simplefilter('ignore', DeprecationWarning)

    for index, (ic_map, ic_terms) in enumerate(
            zip(ica_maps, term_weights_for_components)):
        if -ic_map.min() > ic_map.max():
            # Flip the map's sign for prettiness
            ic_map = - ic_map
            ic_terms = - ic_terms

        ic_threshold = stats.scoreatpercentile(np.abs(ic_map), 90)
        ic_img = masker.inverse_transform(ic_map)
        important_terms = vocabulary[np.argsort(ic_terms)[-3:]]
        title = 'IC%i  %s' % (index, ', '.join(important_terms[::-1]))

        plotting.plot_stat_map(
            ic_img, threshold=ic_threshold, colorbar=False,
            title=title)
  • ../../_images/sphx_glr_plot_ica_neurovault_001.png
  • ../../_images/sphx_glr_plot_ica_neurovault_002.png
  • ../../_images/sphx_glr_plot_ica_neurovault_003.png
  • ../../_images/sphx_glr_plot_ica_neurovault_004.png
  • ../../_images/sphx_glr_plot_ica_neurovault_005.png
  • ../../_images/sphx_glr_plot_ica_neurovault_006.png
  • ../../_images/sphx_glr_plot_ica_neurovault_007.png
  • ../../_images/sphx_glr_plot_ica_neurovault_008.png
  • ../../_images/sphx_glr_plot_ica_neurovault_009.png
  • ../../_images/sphx_glr_plot_ica_neurovault_010.png
  • ../../_images/sphx_glr_plot_ica_neurovault_011.png
  • ../../_images/sphx_glr_plot_ica_neurovault_012.png
  • ../../_images/sphx_glr_plot_ica_neurovault_013.png
  • ../../_images/sphx_glr_plot_ica_neurovault_014.png
  • ../../_images/sphx_glr_plot_ica_neurovault_015.png
  • ../../_images/sphx_glr_plot_ica_neurovault_016.png

As we can see, some of the components capture cognitive or neurological maps, while other capture noise in the database. More data, better filtering, and better cognitive labels would give better maps

# Done.
plotting.show()

Total running time of the script: ( 11 minutes 56.144 seconds)

Generated by Sphinx-Gallery