{"action":"created","comment":{"url":"https://api.github.com/repos/nilearn/nilearn/pulls/comments/45124465","id":45124465,"diff_hunk":"@@ -0,0 +1,260 @@\n+\"\"\"\n+NeuroVault cross-study ICA maps.\n+=====================================================================\n+\n+This example shows how to download statistical maps from\n+NeuroVault, label them with NeuroSynth terms,\n+and compute ICA components across all the maps.\n+\n+See :func:`nilearn.datasets.fetch_neurovault` documentation for more details.\n+\"\"\"\n+# Outline\n+\n+\n+\"\"\" Code to grab the data from NeuroVault, and compute a map of\n+frequency of activation in the brain.\n+\"\"\"\n+# Authors: Chris Filo Gorgolewski, Gael Varoquaux\n+# License: BSD\n+\n+import json\n+import io\n+import os\n+\n+import numpy as np\n+from joblib import Memory\n+from matplotlib import pyplot as plt\n+from scipy import stats\n+from sklearn.decomposition import FastICA\n+from sklearn.feature_extraction import DictVectorizer\n+\n+import nibabel as nib\n+from nilearn import datasets\n+from nilearn.datasets.utils import _fetch_files, _get_dataset_dir\n+from nilearn.image import resample_img\n+from nilearn.input_data import NiftiMasker\n+from nilearn.masking import compute_background_mask, _extrapolate_out_mask\n+from nilearn.plotting import plot_stat_map\n+\n+\n+mem = Memory('cache', verbose=0)\n+\n+\n+@mem.cache\n+def splitext(p):\n+    if p.endswith('.nii.gz'):\n+        return p[:-7], '.nii.gz'\n+    return os.path.splitext(p)\n+\n+\n+@mem.cache\n+def resample_and_expand_image(src_nii, target_nii, out_path=None, force=False):","path":"examples/connectivity/plot_ica_neurovault.py","position":51,"original_position":51,"commit_id":"496f3446612f3cc1704b09374e869aff6f8b2ba9","original_commit_id":"496f3446612f3cc1704b09374e869aff6f8b2ba9","user":{"login":"KamalakerDadi","id":11410385,"avatar_url":"https://avatars.githubusercontent.com/u/11410385?v=3","gravatar_id":"","url":"https://api.github.com/users/KamalakerDadi","html_url":"https://github.com/KamalakerDadi","followers_url":"https://api.github.com/users/KamalakerDadi/followers","following_url":"https://api.github.com/users/KamalakerDadi/following{/other_user}","gists_url":"https://api.github.com/users/KamalakerDadi/gists{/gist_id}","starred_url":"https://api.github.com/users/KamalakerDadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KamalakerDadi/subscriptions","organizations_url":"https://api.github.com/users/KamalakerDadi/orgs","repos_url":"https://api.github.com/users/KamalakerDadi/repos","events_url":"https://api.github.com/users/KamalakerDadi/events{/privacy}","received_events_url":"https://api.github.com/users/KamalakerDadi/received_events","type":"User","site_admin":false},"body":"Taking into account reviews on my PR's, I think ```src_nii``` should be denoted as ```src_img``` same to ```target_nii```.","created_at":"2015-11-17T21:33:39Z","updated_at":"2015-11-17T21:33:39Z","html_url":"https://github.com/nilearn/nilearn/pull/832#discussion_r45124465","pull_request_url":"https://api.github.com/repos/nilearn/nilearn/pulls/832","_links":{"self":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/comments/45124465"},"html":{"href":"https://github.com/nilearn/nilearn/pull/832#discussion_r45124465"},"pull_request":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/832"}}},"pull_request":{"url":"https://api.github.com/repos/nilearn/nilearn/pulls/832","id":50015488,"html_url":"https://github.com/nilearn/nilearn/pull/832","diff_url":"https://github.com/nilearn/nilearn/pull/832.diff","patch_url":"https://github.com/nilearn/nilearn/pull/832.patch","issue_url":"https://api.github.com/repos/nilearn/nilearn/issues/832","number":832,"state":"open","locked":false,"title":"NeuroVault downloader","user":{"login":"bcipolli","id":4072455,"avatar_url":"https://avatars.githubusercontent.com/u/4072455?v=3","gravatar_id":"","url":"https://api.github.com/users/bcipolli","html_url":"https://github.com/bcipolli","followers_url":"https://api.github.com/users/bcipolli/followers","following_url":"https://api.github.com/users/bcipolli/following{/other_user}","gists_url":"https://api.github.com/users/bcipolli/gists{/gist_id}","starred_url":"https://api.github.com/users/bcipolli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcipolli/subscriptions","organizations_url":"https://api.github.com/users/bcipolli/orgs","repos_url":"https://api.github.com/users/bcipolli/repos","events_url":"https://api.github.com/users/bcipolli/events{/privacy}","received_events_url":"https://api.github.com/users/bcipolli/received_events","type":"User","site_admin":false},"body":"This is an enhancement for #640. Not quite done, but far enough along to talk about the API I've implemented.\r\n\r\nTo do:\r\n* [x] Implement an API for downloading selected images from http://neurovault.org/\r\n* [x] Create dataset documentation\r\n* [x] Create a basic example for downloading a subset of files.\r\n* [x] Create a more complex ICA-based example.\r\n* [x] Create tests\r\n* [x] Remove dependency on `requests` - use `urllib`\r\n* [x] Read from disk when offline.\r\n* [ ] Detect outdated cached collection or image metadata or data.\r\n\r\nNeurovault contains images in collections. Collections can be filtered via a few querystring arguments. Images to download and return should be limited by filters on collection and image metadata.\r\n\r\nTo do this, I've included `collection_filters` and `image_filters` arguments.\r\n* If `isinstance(collection_filters, dict)`, the filters are used as querystring argument filters.\r\n* If `isinstance(*_filters, collections.Iterable)` (i.e. a list), the filters are assumed to be functions that receive a collection or image metadata, and returns `True` if the collection's images should be queried, or if the image should be downloaded.\r\n\r\nThe function returns a `Bunch` of three:\r\n* `collections`: a dict (key: collection_id) of collection metadata for matched collections.\r\n* `images`: a list of image metadata (including local file paths) for matched & downloaded images.\r\n* `func_files`: a list of paths to downloaded files. Could be removed, but I kept it as many other functions return a list of paths to images.\r\n\r\nThe example I've begun with is a `stop-go` task meta-analysis, ported from:\r\nhttps://github.com/NeuroVault/neurovault_analysis/blob/master/Stop%20vs.%20Go%20metaanalysis.ipynb\r\n\r\nNote that I avoided trying to convert things to a `pandas` dataframe. The previous examples downloaded all images and filtered using `pandas`; however, all `nilearn` dataset fetchers filter before returning to the user. It was simple enough to allow lambda functions as filters to make very powerful pre-fetch filtering available to the user, so I went that route.\r\n\r\nLooking for feedback on the overall API design to start. @chrisfilo and anyone else around! ","created_at":"2015-11-06T23:00:16Z","updated_at":"2015-11-17T21:33:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"43c17a1c0f6b5d33e37b5247e05ff30f3a837318","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nilearn/nilearn/pulls/832/commits","review_comments_url":"https://api.github.com/repos/nilearn/nilearn/pulls/832/comments","review_comment_url":"https://api.github.com/repos/nilearn/nilearn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nilearn/nilearn/issues/832/comments","statuses_url":"https://api.github.com/repos/nilearn/nilearn/statuses/496f3446612f3cc1704b09374e869aff6f8b2ba9","head":{"label":"bcipolli:neurovault-downloader","ref":"neurovault-downloader","sha":"496f3446612f3cc1704b09374e869aff6f8b2ba9","user":{"login":"bcipolli","id":4072455,"avatar_url":"https://avatars.githubusercontent.com/u/4072455?v=3","gravatar_id":"","url":"https://api.github.com/users/bcipolli","html_url":"https://github.com/bcipolli","followers_url":"https://api.github.com/users/bcipolli/followers","following_url":"https://api.github.com/users/bcipolli/following{/other_user}","gists_url":"https://api.github.com/users/bcipolli/gists{/gist_id}","starred_url":"https://api.github.com/users/bcipolli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcipolli/subscriptions","organizations_url":"https://api.github.com/users/bcipolli/orgs","repos_url":"https://api.github.com/users/bcipolli/repos","events_url":"https://api.github.com/users/bcipolli/events{/privacy}","received_events_url":"https://api.github.com/users/bcipolli/received_events","type":"User","site_admin":false},"repo":{"id":28233031,"name":"nilearn","full_name":"bcipolli/nilearn","owner":{"login":"bcipolli","id":4072455,"avatar_url":"https://avatars.githubusercontent.com/u/4072455?v=3","gravatar_id":"","url":"https://api.github.com/users/bcipolli","html_url":"https://github.com/bcipolli","followers_url":"https://api.github.com/users/bcipolli/followers","following_url":"https://api.github.com/users/bcipolli/following{/other_user}","gists_url":"https://api.github.com/users/bcipolli/gists{/gist_id}","starred_url":"https://api.github.com/users/bcipolli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcipolli/subscriptions","organizations_url":"https://api.github.com/users/bcipolli/orgs","repos_url":"https://api.github.com/users/bcipolli/repos","events_url":"https://api.github.com/users/bcipolli/events{/privacy}","received_events_url":"https://api.github.com/users/bcipolli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bcipolli/nilearn","description":"Machine learning for NeuroImaging in Python","fork":true,"url":"https://api.github.com/repos/bcipolli/nilearn","forks_url":"https://api.github.com/repos/bcipolli/nilearn/forks","keys_url":"https://api.github.com/repos/bcipolli/nilearn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bcipolli/nilearn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bcipolli/nilearn/teams","hooks_url":"https://api.github.com/repos/bcipolli/nilearn/hooks","issue_events_url":"https://api.github.com/repos/bcipolli/nilearn/issues/events{/number}","events_url":"https://api.github.com/repos/bcipolli/nilearn/events","assignees_url":"https://api.github.com/repos/bcipolli/nilearn/assignees{/user}","branches_url":"https://api.github.com/repos/bcipolli/nilearn/branches{/branch}","tags_url":"https://api.github.com/repos/bcipolli/nilearn/tags","blobs_url":"https://api.github.com/repos/bcipolli/nilearn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bcipolli/nilearn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bcipolli/nilearn/git/refs{/sha}","trees_url":"https://api.github.com/repos/bcipolli/nilearn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bcipolli/nilearn/statuses/{sha}","languages_url":"https://api.github.com/repos/bcipolli/nilearn/languages","stargazers_url":"https://api.github.com/repos/bcipolli/nilearn/stargazers","contributors_url":"https://api.github.com/repos/bcipolli/nilearn/contributors","subscribers_url":"https://api.github.com/repos/bcipolli/nilearn/subscribers","subscription_url":"https://api.github.com/repos/bcipolli/nilearn/subscription","commits_url":"https://api.github.com/repos/bcipolli/nilearn/commits{/sha}","git_commits_url":"https://api.github.com/repos/bcipolli/nilearn/git/commits{/sha}","comments_url":"https://api.github.com/repos/bcipolli/nilearn/comments{/number}","issue_comment_url":"https://api.github.com/repos/bcipolli/nilearn/issues/comments{/number}","contents_url":"https://api.github.com/repos/bcipolli/nilearn/contents/{+path}","compare_url":"https://api.github.com/repos/bcipolli/nilearn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bcipolli/nilearn/merges","archive_url":"https://api.github.com/repos/bcipolli/nilearn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bcipolli/nilearn/downloads","issues_url":"https://api.github.com/repos/bcipolli/nilearn/issues{/number}","pulls_url":"https://api.github.com/repos/bcipolli/nilearn/pulls{/number}","milestones_url":"https://api.github.com/repos/bcipolli/nilearn/milestones{/number}","notifications_url":"https://api.github.com/repos/bcipolli/nilearn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bcipolli/nilearn/labels{/name}","releases_url":"https://api.github.com/repos/bcipolli/nilearn/releases{/id}","created_at":"2014-12-19T14:43:35Z","updated_at":"2015-03-27T00:19:15Z","pushed_at":"2015-11-17T16:03:25Z","git_url":"git://github.com/bcipolli/nilearn.git","ssh_url":"git@github.com:bcipolli/nilearn.git","clone_url":"https://github.com/bcipolli/nilearn.git","svn_url":"https://github.com/bcipolli/nilearn","homepage":"http://nilearn.github.io","size":8162,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nilearn:master","ref":"master","sha":"40be7abdc4a845a7a90e8f21e2834f871c0af158","user":{"login":"nilearn","id":4646912,"avatar_url":"https://avatars.githubusercontent.com/u/4646912?v=3","gravatar_id":"","url":"https://api.github.com/users/nilearn","html_url":"https://github.com/nilearn","followers_url":"https://api.github.com/users/nilearn/followers","following_url":"https://api.github.com/users/nilearn/following{/other_user}","gists_url":"https://api.github.com/users/nilearn/gists{/gist_id}","starred_url":"https://api.github.com/users/nilearn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilearn/subscriptions","organizations_url":"https://api.github.com/users/nilearn/orgs","repos_url":"https://api.github.com/users/nilearn/repos","events_url":"https://api.github.com/users/nilearn/events{/privacy}","received_events_url":"https://api.github.com/users/nilearn/received_events","type":"Organization","site_admin":false},"repo":{"id":1235740,"name":"nilearn","full_name":"nilearn/nilearn","owner":{"login":"nilearn","id":4646912,"avatar_url":"https://avatars.githubusercontent.com/u/4646912?v=3","gravatar_id":"","url":"https://api.github.com/users/nilearn","html_url":"https://github.com/nilearn","followers_url":"https://api.github.com/users/nilearn/followers","following_url":"https://api.github.com/users/nilearn/following{/other_user}","gists_url":"https://api.github.com/users/nilearn/gists{/gist_id}","starred_url":"https://api.github.com/users/nilearn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilearn/subscriptions","organizations_url":"https://api.github.com/users/nilearn/orgs","repos_url":"https://api.github.com/users/nilearn/repos","events_url":"https://api.github.com/users/nilearn/events{/privacy}","received_events_url":"https://api.github.com/users/nilearn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nilearn/nilearn","description":"Machine learning for NeuroImaging in Python","fork":false,"url":"https://api.github.com/repos/nilearn/nilearn","forks_url":"https://api.github.com/repos/nilearn/nilearn/forks","keys_url":"https://api.github.com/repos/nilearn/nilearn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nilearn/nilearn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nilearn/nilearn/teams","hooks_url":"https://api.github.com/repos/nilearn/nilearn/hooks","issue_events_url":"https://api.github.com/repos/nilearn/nilearn/issues/events{/number}","events_url":"https://api.github.com/repos/nilearn/nilearn/events","assignees_url":"https://api.github.com/repos/nilearn/nilearn/assignees{/user}","branches_url":"https://api.github.com/repos/nilearn/nilearn/branches{/branch}","tags_url":"https://api.github.com/repos/nilearn/nilearn/tags","blobs_url":"https://api.github.com/repos/nilearn/nilearn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nilearn/nilearn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nilearn/nilearn/git/refs{/sha}","trees_url":"https://api.github.com/repos/nilearn/nilearn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nilearn/nilearn/statuses/{sha}","languages_url":"https://api.github.com/repos/nilearn/nilearn/languages","stargazers_url":"https://api.github.com/repos/nilearn/nilearn/stargazers","contributors_url":"https://api.github.com/repos/nilearn/nilearn/contributors","subscribers_url":"https://api.github.com/repos/nilearn/nilearn/subscribers","subscription_url":"https://api.github.com/repos/nilearn/nilearn/subscription","commits_url":"https://api.github.com/repos/nilearn/nilearn/commits{/sha}","git_commits_url":"https://api.github.com/repos/nilearn/nilearn/git/commits{/sha}","comments_url":"https://api.github.com/repos/nilearn/nilearn/comments{/number}","issue_comment_url":"https://api.github.com/repos/nilearn/nilearn/issues/comments{/number}","contents_url":"https://api.github.com/repos/nilearn/nilearn/contents/{+path}","compare_url":"https://api.github.com/repos/nilearn/nilearn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nilearn/nilearn/merges","archive_url":"https://api.github.com/repos/nilearn/nilearn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nilearn/nilearn/downloads","issues_url":"https://api.github.com/repos/nilearn/nilearn/issues{/number}","pulls_url":"https://api.github.com/repos/nilearn/nilearn/pulls{/number}","milestones_url":"https://api.github.com/repos/nilearn/nilearn/milestones{/number}","notifications_url":"https://api.github.com/repos/nilearn/nilearn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nilearn/nilearn/labels{/name}","releases_url":"https://api.github.com/repos/nilearn/nilearn/releases{/id}","created_at":"2011-01-09T19:02:23Z","updated_at":"2015-11-14T02:02:25Z","pushed_at":"2015-11-17T16:16:25Z","git_url":"git://github.com/nilearn/nilearn.git","ssh_url":"git@github.com:nilearn/nilearn.git","clone_url":"https://github.com/nilearn/nilearn.git","svn_url":"https://github.com/nilearn/nilearn","homepage":"http://nilearn.github.io","size":14961,"stargazers_count":121,"watchers_count":121,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":90,"mirror_url":null,"open_issues_count":100,"forks":90,"open_issues":100,"watchers":121,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/832"},"html":{"href":"https://github.com/nilearn/nilearn/pull/832"},"issue":{"href":"https://api.github.com/repos/nilearn/nilearn/issues/832"},"comments":{"href":"https://api.github.com/repos/nilearn/nilearn/issues/832/comments"},"review_comments":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/832/comments"},"review_comment":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/832/commits"},"statuses":{"href":"https://api.github.com/repos/nilearn/nilearn/statuses/496f3446612f3cc1704b09374e869aff6f8b2ba9"}}}}