{"action":"created","comment":{"url":"https://api.github.com/repos/nilearn/nilearn/pulls/comments/72448222","id":72448222,"diff_hunk":"@@ -0,0 +1,148 @@\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`\n+documentation for more details.\n+\n+\"\"\"\n+# Author: Ben Cipollini\n+# License: BSD\n+# Ported from code authored by Chris Filo Gorgolewski, Gael Varoquaux\n+# https://github.com/NeuroVault/neurovault_analysis\n+import warnings\n+\n+import numpy as np\n+from scipy import stats\n+from sklearn.decomposition import FastICA\n+\n+from nilearn.datasets import fetch_neurovault\n+from nilearn.image import new_img_like, load_img\n+\n+\n+def clean_img(img, dtype=np.float32):\n+    \"\"\" Remove nan/inf entries.\"\"\"\n+    img = load_img(img)\n+    img_data = img.get_data().astype(dtype)\n+    img_data[np.isnan(img_data)] = 0\n+    img_data[np.isinf(img_data)] = 0","path":"examples/03_connectivity/plot_ica_neurovault.py","position":null,"original_position":32,"commit_id":"9185434e5655b563ee733ea5842238e398a46b21","original_commit_id":"7e1c3b3cbe3e5a902643d8125b15e3bb4354fc11","user":{"login":"jeromedockes","id":9196501,"avatar_url":"https://avatars.githubusercontent.com/u/9196501?v=3","gravatar_id":"","url":"https://api.github.com/users/jeromedockes","html_url":"https://github.com/jeromedockes","followers_url":"https://api.github.com/users/jeromedockes/followers","following_url":"https://api.github.com/users/jeromedockes/following{/other_user}","gists_url":"https://api.github.com/users/jeromedockes/gists{/gist_id}","starred_url":"https://api.github.com/users/jeromedockes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeromedockes/subscriptions","organizations_url":"https://api.github.com/users/jeromedockes/orgs","repos_url":"https://api.github.com/users/jeromedockes/repos","events_url":"https://api.github.com/users/jeromedockes/events{/privacy}","received_events_url":"https://api.github.com/users/jeromedockes/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2016-07-27T14:22:49Z","updated_at":"2016-07-27T14:22:49Z","html_url":"https://github.com/nilearn/nilearn/pull/1182#discussion_r72448222","pull_request_url":"https://api.github.com/repos/nilearn/nilearn/pulls/1182","_links":{"self":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/comments/72448222"},"html":{"href":"https://github.com/nilearn/nilearn/pull/1182#discussion_r72448222"},"pull_request":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/1182"}}},"pull_request":{"url":"https://api.github.com/repos/nilearn/nilearn/pulls/1182","id":78110962,"html_url":"https://github.com/nilearn/nilearn/pull/1182","diff_url":"https://github.com/nilearn/nilearn/pull/1182.diff","patch_url":"https://github.com/nilearn/nilearn/pull/1182.patch","issue_url":"https://api.github.com/repos/nilearn/nilearn/issues/1182","number":1182,"state":"open","locked":false,"title":"Add a Neurovault fetcher.","user":{"login":"jeromedockes","id":9196501,"avatar_url":"https://avatars.githubusercontent.com/u/9196501?v=3","gravatar_id":"","url":"https://api.github.com/users/jeromedockes","html_url":"https://github.com/jeromedockes","followers_url":"https://api.github.com/users/jeromedockes/followers","following_url":"https://api.github.com/users/jeromedockes/following{/other_user}","gists_url":"https://api.github.com/users/jeromedockes/gists{/gist_id}","starred_url":"https://api.github.com/users/jeromedockes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeromedockes/subscriptions","organizations_url":"https://api.github.com/users/jeromedockes/orgs","repos_url":"https://api.github.com/users/jeromedockes/repos","events_url":"https://api.github.com/users/jeromedockes/events{/privacy}","received_events_url":"https://api.github.com/users/jeromedockes/received_events","type":"User","site_admin":false},"body":"This is based on PR #832 opened by @bcipolli in answer to issue\r\n#640. The contribution is to add a fetcher for downloading selected\r\nimages from http://neurovault.org/. I have tried to address some of\r\nthe remarks that were made in the discussion about #832. I have\r\nincluded the examples `plot_ica_neurovault.py` and\r\n`plot_neurovault_meta_analysis.py` from the previous PR; they remain\r\nalmost identical.\r\n\r\nThe interface to the fetcher is similar to that proposed in #832. I\r\nhave kept the possibility to filter collections and images either with\r\na function or with a dictionary of `{field: desired_value}` pairs (or\r\nboth), but they are now separate arguments called respectively\r\n`collection_filter` (`image_filter` for images) and `collection_terms`\r\n(`image_terms` for images). Also, now the filters passed in a\r\ndictionary are only inserted in the query URL if they are actually\r\navailable on the server (which is the case for the collection owner,\r\nthe collection DOI, and the collection name); otherwise they are\r\napplied to the metadata once it has been downloaded.\r\n\r\nFor users who want a specific set of image or collection ids,\r\ndownloading all the Neurovault metadata and filtering on the ids is\r\ninefficient; so they can use the `image_ids` or `collection_ids`\r\nparameters to pass the lists of ids they want to download; in this\r\ncase any filter is ignored and the server is queried directly for the\r\nrequired image and collection ids. Note: this is also done under the\r\nhood if the collection id is used as a filter term - either by\r\nspecifying the collection 'id' field or the image 'collection_id'\r\nfield - except that in this case the other filters are still applied.\r\n\r\nI have included a `ResultFilter` class and a bunch of special values\r\nsuch as `NotNull` which can be used to specify filters more easily. In\r\nsome neurovault metadata jsons, some values are strings such as \"\",\r\n\"null\", \"None\"... instead of actual `null`; these (more precisely\r\nstrings that match `($|n/?a$|none|null)` in a case-insensitive way)\r\nare replaced by a true null value (`null` in the json, converted to\r\n`None` when loaded in a python dict) upon download so that comparing\r\nto `None` or testing for truth should yield the expected results.  In\r\nparticular `dict.get(field)` will give the same value wether the\r\noriginal value was `null`, \"null\", ... , or plain missing.\r\n\r\nThis should make using `fetch_neurovault` somewhat easier. However,\r\nfor users who are interested in a large subset of the neurovault data\r\nand are not too short on disk space, I would recommend using only very\r\nsimple filters (e.g. the defaults) when calling `fetch_neurovault` to\r\ndownload (almost all) the data, and, once it is on disk, only access\r\nit through `read_sql_query`, `local_database_connection` or\r\n`local_database_cursor`. The metadata is stored in an sqlite database,\r\nso instead of having to read the docstring for `fetch_neurovault`,\r\nwriting their own filters, etc., most users will probably prefer to\r\ndownload it all and then simply use SQL syntax to select the subset\r\nthey're interested in. `read_sql_query` queries the database and\r\nreturns the result as an `OrderedDict` of columns (the default) or as\r\na list of rows. `local_database_connection` gives a connection to the\r\nsqlite file, so that pandas users can load e.g., all the images'\r\nmetadata by typing:\r\n\r\n    images = pandas.read_sql_query(\r\n         \"SELECT * FROM images\", neurovault.local_database_connection())\r\n\r\nOf course if they prefer manipulating sqlite3 objects directly they\r\ncan use the connection given by `local_database_connection` or the\r\ncursor given by `local_database_cursor`.\r\n\r\n@bcipolli, @chrisfilo, @GaelVaroquaux, or anyone else, please let me\r\nknow what modifications need to be made! In particular:\r\n\r\n- What should be the default filters? The current behaviour is to\r\n  exclude:\r\n    - Collections from a list of known bad collections (found in PR #832,  with one addition).\r\n    - Empty collections.\r\n    - Images from a list of known bad images (found in PR #832).\r\n    - Images that are not in MNI space.\r\n    - Images for which the metadata field 'is_valid' is cleared.\r\n    - Images for which the metadata field 'is_thresholded' is set.\r\n    - Images for which 'map_type' is 'ROI/mask', 'anatomical' or 'parcellation'\r\n    - Images for which 'image_type' is 'atlas'\r\n\r\n- Should the fetcher, by default, download all the images matching the\r\n  filters, or only a limited number (the current behaviour)?\r\n","created_at":"2016-07-20T08:58:52Z","updated_at":"2016-07-27T14:22:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3aa6298a12c4e4d1b8f6c358a1c6293e7c8858e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nilearn/nilearn/pulls/1182/commits","review_comments_url":"https://api.github.com/repos/nilearn/nilearn/pulls/1182/comments","review_comment_url":"https://api.github.com/repos/nilearn/nilearn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nilearn/nilearn/issues/1182/comments","statuses_url":"https://api.github.com/repos/nilearn/nilearn/statuses/9185434e5655b563ee733ea5842238e398a46b21","head":{"label":"jeromedockes:neurovault_fetcher","ref":"neurovault_fetcher","sha":"9185434e5655b563ee733ea5842238e398a46b21","user":{"login":"jeromedockes","id":9196501,"avatar_url":"https://avatars.githubusercontent.com/u/9196501?v=3","gravatar_id":"","url":"https://api.github.com/users/jeromedockes","html_url":"https://github.com/jeromedockes","followers_url":"https://api.github.com/users/jeromedockes/followers","following_url":"https://api.github.com/users/jeromedockes/following{/other_user}","gists_url":"https://api.github.com/users/jeromedockes/gists{/gist_id}","starred_url":"https://api.github.com/users/jeromedockes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeromedockes/subscriptions","organizations_url":"https://api.github.com/users/jeromedockes/orgs","repos_url":"https://api.github.com/users/jeromedockes/repos","events_url":"https://api.github.com/users/jeromedockes/events{/privacy}","received_events_url":"https://api.github.com/users/jeromedockes/received_events","type":"User","site_admin":false},"repo":{"id":55776026,"name":"nilearn","full_name":"jeromedockes/nilearn","owner":{"login":"jeromedockes","id":9196501,"avatar_url":"https://avatars.githubusercontent.com/u/9196501?v=3","gravatar_id":"","url":"https://api.github.com/users/jeromedockes","html_url":"https://github.com/jeromedockes","followers_url":"https://api.github.com/users/jeromedockes/followers","following_url":"https://api.github.com/users/jeromedockes/following{/other_user}","gists_url":"https://api.github.com/users/jeromedockes/gists{/gist_id}","starred_url":"https://api.github.com/users/jeromedockes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeromedockes/subscriptions","organizations_url":"https://api.github.com/users/jeromedockes/orgs","repos_url":"https://api.github.com/users/jeromedockes/repos","events_url":"https://api.github.com/users/jeromedockes/events{/privacy}","received_events_url":"https://api.github.com/users/jeromedockes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeromedockes/nilearn","description":"Machine learning for NeuroImaging in Python","fork":true,"url":"https://api.github.com/repos/jeromedockes/nilearn","forks_url":"https://api.github.com/repos/jeromedockes/nilearn/forks","keys_url":"https://api.github.com/repos/jeromedockes/nilearn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeromedockes/nilearn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeromedockes/nilearn/teams","hooks_url":"https://api.github.com/repos/jeromedockes/nilearn/hooks","issue_events_url":"https://api.github.com/repos/jeromedockes/nilearn/issues/events{/number}","events_url":"https://api.github.com/repos/jeromedockes/nilearn/events","assignees_url":"https://api.github.com/repos/jeromedockes/nilearn/assignees{/user}","branches_url":"https://api.github.com/repos/jeromedockes/nilearn/branches{/branch}","tags_url":"https://api.github.com/repos/jeromedockes/nilearn/tags","blobs_url":"https://api.github.com/repos/jeromedockes/nilearn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeromedockes/nilearn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeromedockes/nilearn/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeromedockes/nilearn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeromedockes/nilearn/statuses/{sha}","languages_url":"https://api.github.com/repos/jeromedockes/nilearn/languages","stargazers_url":"https://api.github.com/repos/jeromedockes/nilearn/stargazers","contributors_url":"https://api.github.com/repos/jeromedockes/nilearn/contributors","subscribers_url":"https://api.github.com/repos/jeromedockes/nilearn/subscribers","subscription_url":"https://api.github.com/repos/jeromedockes/nilearn/subscription","commits_url":"https://api.github.com/repos/jeromedockes/nilearn/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeromedockes/nilearn/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeromedockes/nilearn/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeromedockes/nilearn/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeromedockes/nilearn/contents/{+path}","compare_url":"https://api.github.com/repos/jeromedockes/nilearn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeromedockes/nilearn/merges","archive_url":"https://api.github.com/repos/jeromedockes/nilearn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeromedockes/nilearn/downloads","issues_url":"https://api.github.com/repos/jeromedockes/nilearn/issues{/number}","pulls_url":"https://api.github.com/repos/jeromedockes/nilearn/pulls{/number}","milestones_url":"https://api.github.com/repos/jeromedockes/nilearn/milestones{/number}","notifications_url":"https://api.github.com/repos/jeromedockes/nilearn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeromedockes/nilearn/labels{/name}","releases_url":"https://api.github.com/repos/jeromedockes/nilearn/releases{/id}","deployments_url":"https://api.github.com/repos/jeromedockes/nilearn/deployments","created_at":"2016-04-08T12:05:30Z","updated_at":"2016-04-08T12:05:32Z","pushed_at":"2016-07-27T14:08:09Z","git_url":"git://github.com/jeromedockes/nilearn.git","ssh_url":"git@github.com:jeromedockes/nilearn.git","clone_url":"https://github.com/jeromedockes/nilearn.git","svn_url":"https://github.com/jeromedockes/nilearn","homepage":"http://nilearn.github.io","size":10206,"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":"0f07e2f4d86a553c20ef22ba531aeabe1b08f595","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}","deployments_url":"https://api.github.com/repos/nilearn/nilearn/deployments","created_at":"2011-01-09T19:02:23Z","updated_at":"2016-07-26T16:04:34Z","pushed_at":"2016-07-27T14:08:10Z","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":13396,"stargazers_count":186,"watchers_count":186,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":138,"mirror_url":null,"open_issues_count":154,"forks":138,"open_issues":154,"watchers":186,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/1182"},"html":{"href":"https://github.com/nilearn/nilearn/pull/1182"},"issue":{"href":"https://api.github.com/repos/nilearn/nilearn/issues/1182"},"comments":{"href":"https://api.github.com/repos/nilearn/nilearn/issues/1182/comments"},"review_comments":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/1182/comments"},"review_comment":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/1182/commits"},"statuses":{"href":"https://api.github.com/repos/nilearn/nilearn/statuses/9185434e5655b563ee733ea5842238e398a46b21"}}}}
{"actor":{"display_login":"jeromedockes"}}