{"action":"created","comment":{"url":"https://api.github.com/repos/nistats/nistats/pulls/comments/69695366","id":69695366,"diff_hunk":"@@ -467,23 +479,33 @@ def compute_contrast(self, contrast_def, contrast_name=None,\n \n         Returns\n         -------\n-        output_image : Nifti1Image\n-            The desired output image\n+        output : Nifti1Image\n+            The desired output image from a fixed effects computation.\n \n         \"\"\"\n         if self.labels_ is None or self.results_ is None:\n             raise ValueError('The model has not been fit yet')\n \n-        if isinstance(contrast_def, np.ndarray):\n+        if isinstance(contrast_def, (np.ndarray, str)):\n             con_vals = [contrast_def]\n         elif isinstance(contrast_def, (list, tuple)):\n             con_vals = contrast_def\n-            for cidx, con in enumerate(contrast_def):\n+        else:\n+            raise ValueError('contrast_def must be an array or str or list of'\n+                             ' (array or str)')\n+        # We reinterpret formulas as vectors only if design has column names.\n+        des_names = np.unique(self.design_matrices_[0].columns.tolist())\n+        if len(des_names) == len(self.design_matrices_[0].columns):\n+            di = DesignInfo(self.design_matrices_[0].columns.tolist())","path":"nistats/first_level_model.py","position":176,"original_position":176,"commit_id":"dab96b5bdab91758b13373b9c19fc5b6a7e0a956","original_commit_id":"dab96b5bdab91758b13373b9c19fc5b6a7e0a956","user":{"login":"bthirion","id":234454,"avatar_url":"https://avatars.githubusercontent.com/u/234454?v=3","gravatar_id":"","url":"https://api.github.com/users/bthirion","html_url":"https://github.com/bthirion","followers_url":"https://api.github.com/users/bthirion/followers","following_url":"https://api.github.com/users/bthirion/following{/other_user}","gists_url":"https://api.github.com/users/bthirion/gists{/gist_id}","starred_url":"https://api.github.com/users/bthirion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bthirion/subscriptions","organizations_url":"https://api.github.com/users/bthirion/orgs","repos_url":"https://api.github.com/users/bthirion/repos","events_url":"https://api.github.com/users/bthirion/events{/privacy}","received_events_url":"https://api.github.com/users/bthirion/received_events","type":"User","site_admin":false},"body":"`design_info` instead of `di` ","created_at":"2016-07-06T08:55:27Z","updated_at":"2016-07-06T08:55:27Z","html_url":"https://github.com/nistats/nistats/pull/78#discussion_r69695366","pull_request_url":"https://api.github.com/repos/nistats/nistats/pulls/78","_links":{"self":{"href":"https://api.github.com/repos/nistats/nistats/pulls/comments/69695366"},"html":{"href":"https://github.com/nistats/nistats/pull/78#discussion_r69695366"},"pull_request":{"href":"https://api.github.com/repos/nistats/nistats/pulls/78"}}},"pull_request":{"url":"https://api.github.com/repos/nistats/nistats/pulls/78","id":73512037,"html_url":"https://github.com/nistats/nistats/pull/78","diff_url":"https://github.com/nistats/nistats/pull/78.diff","patch_url":"https://github.com/nistats/nistats/pull/78.patch","issue_url":"https://api.github.com/repos/nistats/nistats/issues/78","number":78,"state":"open","locked":false,"title":"Second level model","user":{"login":"MartinPerez","id":8766915,"avatar_url":"https://avatars.githubusercontent.com/u/8766915?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinPerez","html_url":"https://github.com/MartinPerez","followers_url":"https://api.github.com/users/MartinPerez/followers","following_url":"https://api.github.com/users/MartinPerez/following{/other_user}","gists_url":"https://api.github.com/users/MartinPerez/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinPerez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinPerez/subscriptions","organizations_url":"https://api.github.com/users/MartinPerez/orgs","repos_url":"https://api.github.com/users/MartinPerez/repos","events_url":"https://api.github.com/users/MartinPerez/events{/privacy}","received_events_url":"https://api.github.com/users/MartinPerez/received_events","type":"User","site_admin":false},"body":"Here is the second level model with one simple example (second level analysis only) on the mixed gambles dataset (which is more a sanity check than an actual example due to the lack of a nice contrast to picture the results). I will create a new PR for a complete first and second level example on a bids dataset. The second level model object is quite flexible at the moment, it accepts list of first level models, the pandas dataframe discussed with @bthirion  and a simple list of images, then the other arguments must be matched accordingly. I hope the documentation is clear in this respect.\r\n\r\nAt the moment the second level only includes a simple OLS regression that only takes into account effect maps (RFX). Future PRs would be done for more complex models.\r\n\r\nI included the patsy formulas functionality for the contrasts, it was a very small adaptation of the code. So we already have formulas for contrasts in both first and second level objects.\r\n\r\nIs built on top of the first level model, so it should be compared with #72 instead of master until #72 is merged.\r\n\r\nAll tests included too.","created_at":"2016-06-13T00:21:10Z","updated_at":"2016-07-06T08:55:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e9cab321cd58564b3265d2f6a34ff93e3f79c74","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nistats/nistats/pulls/78/commits","review_comments_url":"https://api.github.com/repos/nistats/nistats/pulls/78/comments","review_comment_url":"https://api.github.com/repos/nistats/nistats/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nistats/nistats/issues/78/comments","statuses_url":"https://api.github.com/repos/nistats/nistats/statuses/dab96b5bdab91758b13373b9c19fc5b6a7e0a956","head":{"label":"MartinPerez:second_level_model","ref":"second_level_model","sha":"dab96b5bdab91758b13373b9c19fc5b6a7e0a956","user":{"login":"MartinPerez","id":8766915,"avatar_url":"https://avatars.githubusercontent.com/u/8766915?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinPerez","html_url":"https://github.com/MartinPerez","followers_url":"https://api.github.com/users/MartinPerez/followers","following_url":"https://api.github.com/users/MartinPerez/following{/other_user}","gists_url":"https://api.github.com/users/MartinPerez/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinPerez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinPerez/subscriptions","organizations_url":"https://api.github.com/users/MartinPerez/orgs","repos_url":"https://api.github.com/users/MartinPerez/repos","events_url":"https://api.github.com/users/MartinPerez/events{/privacy}","received_events_url":"https://api.github.com/users/MartinPerez/received_events","type":"User","site_admin":false},"repo":{"id":41736457,"name":"nistats","full_name":"MartinPerez/nistats","owner":{"login":"MartinPerez","id":8766915,"avatar_url":"https://avatars.githubusercontent.com/u/8766915?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinPerez","html_url":"https://github.com/MartinPerez","followers_url":"https://api.github.com/users/MartinPerez/followers","following_url":"https://api.github.com/users/MartinPerez/following{/other_user}","gists_url":"https://api.github.com/users/MartinPerez/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinPerez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinPerez/subscriptions","organizations_url":"https://api.github.com/users/MartinPerez/orgs","repos_url":"https://api.github.com/users/MartinPerez/repos","events_url":"https://api.github.com/users/MartinPerez/events{/privacy}","received_events_url":"https://api.github.com/users/MartinPerez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MartinPerez/nistats","description":"Modeling and statistical inference on fMRI data in Python ","fork":true,"url":"https://api.github.com/repos/MartinPerez/nistats","forks_url":"https://api.github.com/repos/MartinPerez/nistats/forks","keys_url":"https://api.github.com/repos/MartinPerez/nistats/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MartinPerez/nistats/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MartinPerez/nistats/teams","hooks_url":"https://api.github.com/repos/MartinPerez/nistats/hooks","issue_events_url":"https://api.github.com/repos/MartinPerez/nistats/issues/events{/number}","events_url":"https://api.github.com/repos/MartinPerez/nistats/events","assignees_url":"https://api.github.com/repos/MartinPerez/nistats/assignees{/user}","branches_url":"https://api.github.com/repos/MartinPerez/nistats/branches{/branch}","tags_url":"https://api.github.com/repos/MartinPerez/nistats/tags","blobs_url":"https://api.github.com/repos/MartinPerez/nistats/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MartinPerez/nistats/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MartinPerez/nistats/git/refs{/sha}","trees_url":"https://api.github.com/repos/MartinPerez/nistats/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MartinPerez/nistats/statuses/{sha}","languages_url":"https://api.github.com/repos/MartinPerez/nistats/languages","stargazers_url":"https://api.github.com/repos/MartinPerez/nistats/stargazers","contributors_url":"https://api.github.com/repos/MartinPerez/nistats/contributors","subscribers_url":"https://api.github.com/repos/MartinPerez/nistats/subscribers","subscription_url":"https://api.github.com/repos/MartinPerez/nistats/subscription","commits_url":"https://api.github.com/repos/MartinPerez/nistats/commits{/sha}","git_commits_url":"https://api.github.com/repos/MartinPerez/nistats/git/commits{/sha}","comments_url":"https://api.github.com/repos/MartinPerez/nistats/comments{/number}","issue_comment_url":"https://api.github.com/repos/MartinPerez/nistats/issues/comments{/number}","contents_url":"https://api.github.com/repos/MartinPerez/nistats/contents/{+path}","compare_url":"https://api.github.com/repos/MartinPerez/nistats/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MartinPerez/nistats/merges","archive_url":"https://api.github.com/repos/MartinPerez/nistats/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MartinPerez/nistats/downloads","issues_url":"https://api.github.com/repos/MartinPerez/nistats/issues{/number}","pulls_url":"https://api.github.com/repos/MartinPerez/nistats/pulls{/number}","milestones_url":"https://api.github.com/repos/MartinPerez/nistats/milestones{/number}","notifications_url":"https://api.github.com/repos/MartinPerez/nistats/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MartinPerez/nistats/labels{/name}","releases_url":"https://api.github.com/repos/MartinPerez/nistats/releases{/id}","deployments_url":"https://api.github.com/repos/MartinPerez/nistats/deployments","created_at":"2015-09-01T12:12:28Z","updated_at":"2016-01-31T13:27:28Z","pushed_at":"2016-06-23T11:39:47Z","git_url":"git://github.com/MartinPerez/nistats.git","ssh_url":"git@github.com:MartinPerez/nistats.git","clone_url":"https://github.com/MartinPerez/nistats.git","svn_url":"https://github.com/MartinPerez/nistats","homepage":null,"size":424,"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":"nistats:master","ref":"master","sha":"8d336abe3f8ccbb7a774a901bf3dab09083857aa","user":{"login":"nistats","id":12428142,"avatar_url":"https://avatars.githubusercontent.com/u/12428142?v=3","gravatar_id":"","url":"https://api.github.com/users/nistats","html_url":"https://github.com/nistats","followers_url":"https://api.github.com/users/nistats/followers","following_url":"https://api.github.com/users/nistats/following{/other_user}","gists_url":"https://api.github.com/users/nistats/gists{/gist_id}","starred_url":"https://api.github.com/users/nistats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nistats/subscriptions","organizations_url":"https://api.github.com/users/nistats/orgs","repos_url":"https://api.github.com/users/nistats/repos","events_url":"https://api.github.com/users/nistats/events{/privacy}","received_events_url":"https://api.github.com/users/nistats/received_events","type":"Organization","site_admin":false},"repo":{"id":35545854,"name":"nistats","full_name":"nistats/nistats","owner":{"login":"nistats","id":12428142,"avatar_url":"https://avatars.githubusercontent.com/u/12428142?v=3","gravatar_id":"","url":"https://api.github.com/users/nistats","html_url":"https://github.com/nistats","followers_url":"https://api.github.com/users/nistats/followers","following_url":"https://api.github.com/users/nistats/following{/other_user}","gists_url":"https://api.github.com/users/nistats/gists{/gist_id}","starred_url":"https://api.github.com/users/nistats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nistats/subscriptions","organizations_url":"https://api.github.com/users/nistats/orgs","repos_url":"https://api.github.com/users/nistats/repos","events_url":"https://api.github.com/users/nistats/events{/privacy}","received_events_url":"https://api.github.com/users/nistats/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nistats/nistats","description":"Modeling and statistical inference on fMRI data in Python ","fork":false,"url":"https://api.github.com/repos/nistats/nistats","forks_url":"https://api.github.com/repos/nistats/nistats/forks","keys_url":"https://api.github.com/repos/nistats/nistats/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nistats/nistats/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nistats/nistats/teams","hooks_url":"https://api.github.com/repos/nistats/nistats/hooks","issue_events_url":"https://api.github.com/repos/nistats/nistats/issues/events{/number}","events_url":"https://api.github.com/repos/nistats/nistats/events","assignees_url":"https://api.github.com/repos/nistats/nistats/assignees{/user}","branches_url":"https://api.github.com/repos/nistats/nistats/branches{/branch}","tags_url":"https://api.github.com/repos/nistats/nistats/tags","blobs_url":"https://api.github.com/repos/nistats/nistats/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nistats/nistats/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nistats/nistats/git/refs{/sha}","trees_url":"https://api.github.com/repos/nistats/nistats/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nistats/nistats/statuses/{sha}","languages_url":"https://api.github.com/repos/nistats/nistats/languages","stargazers_url":"https://api.github.com/repos/nistats/nistats/stargazers","contributors_url":"https://api.github.com/repos/nistats/nistats/contributors","subscribers_url":"https://api.github.com/repos/nistats/nistats/subscribers","subscription_url":"https://api.github.com/repos/nistats/nistats/subscription","commits_url":"https://api.github.com/repos/nistats/nistats/commits{/sha}","git_commits_url":"https://api.github.com/repos/nistats/nistats/git/commits{/sha}","comments_url":"https://api.github.com/repos/nistats/nistats/comments{/number}","issue_comment_url":"https://api.github.com/repos/nistats/nistats/issues/comments{/number}","contents_url":"https://api.github.com/repos/nistats/nistats/contents/{+path}","compare_url":"https://api.github.com/repos/nistats/nistats/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nistats/nistats/merges","archive_url":"https://api.github.com/repos/nistats/nistats/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nistats/nistats/downloads","issues_url":"https://api.github.com/repos/nistats/nistats/issues{/number}","pulls_url":"https://api.github.com/repos/nistats/nistats/pulls{/number}","milestones_url":"https://api.github.com/repos/nistats/nistats/milestones{/number}","notifications_url":"https://api.github.com/repos/nistats/nistats/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nistats/nistats/labels{/name}","releases_url":"https://api.github.com/repos/nistats/nistats/releases{/id}","deployments_url":"https://api.github.com/repos/nistats/nistats/deployments","created_at":"2015-05-13T11:44:31Z","updated_at":"2016-07-03T10:34:27Z","pushed_at":"2016-07-05T04:52:36Z","git_url":"git://github.com/nistats/nistats.git","ssh_url":"git@github.com:nistats/nistats.git","clone_url":"https://github.com/nistats/nistats.git","svn_url":"https://github.com/nistats/nistats","homepage":null,"size":409,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":38,"forks":18,"open_issues":38,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nistats/nistats/pulls/78"},"html":{"href":"https://github.com/nistats/nistats/pull/78"},"issue":{"href":"https://api.github.com/repos/nistats/nistats/issues/78"},"comments":{"href":"https://api.github.com/repos/nistats/nistats/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/nistats/nistats/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/nistats/nistats/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nistats/nistats/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/nistats/nistats/statuses/dab96b5bdab91758b13373b9c19fc5b6a7e0a956"}}}}
{"actor":{"display_login":"bthirion"}}