{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/34544447","id":34544447,"diff_hunk":"@@ -0,0 +1,66 @@\n+\"\"\"\n+====================================================================\n+Decoding in sensor space data using the linear models \n+====================================================================\n+\n+Decoding applied to MEG data in sensor space using a linear classifier\n+Here the model coefficient are interpreted using [1].\n+\n+\n+[1] Haufe, S., Meinecke, F., Görgen, K., Dähne, S., Haynes, J.-D., \n+Blankertz, B., & Bießmann, F. (2014). On the interpretation of \n+weight vectors of linear models in multivariate neuroimaging. \n+NeuroImage, 87, 96–110. doi:10.1016/j.neuroimage.2013.10.067\n+\"\"\"\n+# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>\n+#          Romain Trachel <trachelr@gmail.com>\n+#\n+# License: BSD (3-clause)\n+\n+import mne\n+from mne import io\n+from mne.datasets import sample\n+\n+print(__doc__)\n+\n+data_path = sample.data_path()\n+\n+###############################################################################\n+# Set parameters and read data\n+raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'\n+event_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'\n+tmin, tmax = -0.2, 0.5\n+event_id = dict(aud_l=1, aud_r=3)\n+\n+# Setup for reading the raw data\n+raw = io.Raw(raw_fname, preload=True)\n+raw.filter(2, None, method='iir')  # replace baselining with high-pass\n+events = mne.read_events(event_fname)\n+\n+raw.info['bads'] = ['MEG 2443']  # set bad channels\n+picks = mne.pick_types(raw.info, meg='grad', eeg=False, stim=False, eog=False,\n+                       exclude='bads')\n+\n+# Read epochs\n+epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,\n+                    picks=picks, baseline=None, preload=True)\n+\n+import sklearn.linear_model as lm\n+import sklearn.svm as svm\n+from mne.decoding.classifier import compute_patterns\n+\n+# computes patterns estimated with a ridge classifier\n+ridge  = lm.RidgeClassifier()\n+ridge_patterns = compute_patterns(epochs, ridge)\n+ridge_patterns.plot_topomap()\n+\n+# computes patterns estimated with a linear SVM classifier\n+linsvc = svm.LinearSVC()\n+linsvc_patterns = compute_patterns(epochs, linsvc)\n+linsvc_patterns.plot_topomap()\n+\n+# computes patterns estimated with a logistic regression classifier\n+logreg = lm.LogisticRegression(penalty='l1')\n+logreg_patterns = compute_patterns(epochs, logreg)\n+logreg_patterns.plot_topomap()","path":"examples/decoding/plot_decoding_linear_model_patterns.py","position":65,"original_position":65,"commit_id":"e028fa5120d02616177e7b573d07f5717c73b156","original_commit_id":"e028fa5120d02616177e7b573d07f5717c73b156","user":{"login":"kingjr","id":4881164,"avatar_url":"https://avatars.githubusercontent.com/u/4881164?v=3","gravatar_id":"","url":"https://api.github.com/users/kingjr","html_url":"https://github.com/kingjr","followers_url":"https://api.github.com/users/kingjr/followers","following_url":"https://api.github.com/users/kingjr/following{/other_user}","gists_url":"https://api.github.com/users/kingjr/gists{/gist_id}","starred_url":"https://api.github.com/users/kingjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingjr/subscriptions","organizations_url":"https://api.github.com/users/kingjr/orgs","repos_url":"https://api.github.com/users/kingjr/repos","events_url":"https://api.github.com/users/kingjr/events{/privacy}","received_events_url":"https://api.github.com/users/kingjr/received_events","type":"User","site_admin":false},"body":"I think the example only needs one linear classifier, and perhaps one linear regresser to make the point.","created_at":"2015-07-14T07:47:53Z","updated_at":"2015-07-14T07:47:53Z","html_url":"https://github.com/mne-tools/mne-python/pull/2284#discussion_r34544447","pull_request_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2284","_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/34544447"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2284#discussion_r34544447"},"pull_request":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2284"}}},"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2284","id":39837850,"html_url":"https://github.com/mne-tools/mne-python/pull/2284","diff_url":"https://github.com/mne-tools/mne-python/pull/2284.diff","patch_url":"https://github.com/mne-tools/mne-python/pull/2284.patch","issue_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2284","number":2284,"state":"open","locked":false,"title":"ENH: Pattern computation for linear models","user":{"login":"trachelr","id":4253050,"avatar_url":"https://avatars.githubusercontent.com/u/4253050?v=3","gravatar_id":"","url":"https://api.github.com/users/trachelr","html_url":"https://github.com/trachelr","followers_url":"https://api.github.com/users/trachelr/followers","following_url":"https://api.github.com/users/trachelr/following{/other_user}","gists_url":"https://api.github.com/users/trachelr/gists{/gist_id}","starred_url":"https://api.github.com/users/trachelr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trachelr/subscriptions","organizations_url":"https://api.github.com/users/trachelr/orgs","repos_url":"https://api.github.com/users/trachelr/repos","events_url":"https://api.github.com/users/trachelr/events{/privacy}","received_events_url":"https://api.github.com/users/trachelr/received_events","type":"User","site_admin":false},"body":"This is a simple function that fit a linear model onto some data (X, y), computes the corresponding patterns and create an evoked object with it.\r\nVisualization is much more simple now...\r\n","created_at":"2015-07-13T17:52:03Z","updated_at":"2015-07-14T07:47:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f538629bf7310b0ae88ce41d792ff3b4347578aa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2284/commits","review_comments_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2284/comments","review_comment_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2284/comments","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/e028fa5120d02616177e7b573d07f5717c73b156","head":{"label":"trachelr:compute_patterns","ref":"compute_patterns","sha":"e028fa5120d02616177e7b573d07f5717c73b156","user":{"login":"trachelr","id":4253050,"avatar_url":"https://avatars.githubusercontent.com/u/4253050?v=3","gravatar_id":"","url":"https://api.github.com/users/trachelr","html_url":"https://github.com/trachelr","followers_url":"https://api.github.com/users/trachelr/followers","following_url":"https://api.github.com/users/trachelr/following{/other_user}","gists_url":"https://api.github.com/users/trachelr/gists{/gist_id}","starred_url":"https://api.github.com/users/trachelr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trachelr/subscriptions","organizations_url":"https://api.github.com/users/trachelr/orgs","repos_url":"https://api.github.com/users/trachelr/repos","events_url":"https://api.github.com/users/trachelr/events{/privacy}","received_events_url":"https://api.github.com/users/trachelr/received_events","type":"User","site_admin":false},"repo":{"id":9671966,"name":"mne-python","full_name":"trachelr/mne-python","owner":{"login":"trachelr","id":4253050,"avatar_url":"https://avatars.githubusercontent.com/u/4253050?v=3","gravatar_id":"","url":"https://api.github.com/users/trachelr","html_url":"https://github.com/trachelr","followers_url":"https://api.github.com/users/trachelr/followers","following_url":"https://api.github.com/users/trachelr/following{/other_user}","gists_url":"https://api.github.com/users/trachelr/gists{/gist_id}","starred_url":"https://api.github.com/users/trachelr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trachelr/subscriptions","organizations_url":"https://api.github.com/users/trachelr/orgs","repos_url":"https://api.github.com/users/trachelr/repos","events_url":"https://api.github.com/users/trachelr/events{/privacy}","received_events_url":"https://api.github.com/users/trachelr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/trachelr/mne-python","description":"MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python","fork":true,"url":"https://api.github.com/repos/trachelr/mne-python","forks_url":"https://api.github.com/repos/trachelr/mne-python/forks","keys_url":"https://api.github.com/repos/trachelr/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/trachelr/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/trachelr/mne-python/teams","hooks_url":"https://api.github.com/repos/trachelr/mne-python/hooks","issue_events_url":"https://api.github.com/repos/trachelr/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/trachelr/mne-python/events","assignees_url":"https://api.github.com/repos/trachelr/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/trachelr/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/trachelr/mne-python/tags","blobs_url":"https://api.github.com/repos/trachelr/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/trachelr/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/trachelr/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/trachelr/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/trachelr/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/trachelr/mne-python/languages","stargazers_url":"https://api.github.com/repos/trachelr/mne-python/stargazers","contributors_url":"https://api.github.com/repos/trachelr/mne-python/contributors","subscribers_url":"https://api.github.com/repos/trachelr/mne-python/subscribers","subscription_url":"https://api.github.com/repos/trachelr/mne-python/subscription","commits_url":"https://api.github.com/repos/trachelr/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/trachelr/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/trachelr/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/trachelr/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/trachelr/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/trachelr/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/trachelr/mne-python/merges","archive_url":"https://api.github.com/repos/trachelr/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/trachelr/mne-python/downloads","issues_url":"https://api.github.com/repos/trachelr/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/trachelr/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/trachelr/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/trachelr/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/trachelr/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/trachelr/mne-python/releases{/id}","created_at":"2013-04-25T13:11:33Z","updated_at":"2014-12-11T20:21:39Z","pushed_at":"2015-07-14T07:28:09Z","git_url":"git://github.com/trachelr/mne-python.git","ssh_url":"git@github.com:trachelr/mne-python.git","clone_url":"https://github.com/trachelr/mne-python.git","svn_url":"https://github.com/trachelr/mne-python","homepage":"http://martinos.org/mne/","size":72625,"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":"mne-tools:master","ref":"master","sha":"f32436e9fb93f33f452f4138a11638de8b9c0df5","user":{"login":"mne-tools","id":583875,"avatar_url":"https://avatars.githubusercontent.com/u/583875?v=3","gravatar_id":"","url":"https://api.github.com/users/mne-tools","html_url":"https://github.com/mne-tools","followers_url":"https://api.github.com/users/mne-tools/followers","following_url":"https://api.github.com/users/mne-tools/following{/other_user}","gists_url":"https://api.github.com/users/mne-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/mne-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mne-tools/subscriptions","organizations_url":"https://api.github.com/users/mne-tools/orgs","repos_url":"https://api.github.com/users/mne-tools/repos","events_url":"https://api.github.com/users/mne-tools/events{/privacy}","received_events_url":"https://api.github.com/users/mne-tools/received_events","type":"Organization","site_admin":false},"repo":{"id":1301584,"name":"mne-python","full_name":"mne-tools/mne-python","owner":{"login":"mne-tools","id":583875,"avatar_url":"https://avatars.githubusercontent.com/u/583875?v=3","gravatar_id":"","url":"https://api.github.com/users/mne-tools","html_url":"https://github.com/mne-tools","followers_url":"https://api.github.com/users/mne-tools/followers","following_url":"https://api.github.com/users/mne-tools/following{/other_user}","gists_url":"https://api.github.com/users/mne-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/mne-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mne-tools/subscriptions","organizations_url":"https://api.github.com/users/mne-tools/orgs","repos_url":"https://api.github.com/users/mne-tools/repos","events_url":"https://api.github.com/users/mne-tools/events{/privacy}","received_events_url":"https://api.github.com/users/mne-tools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mne-tools/mne-python","description":"MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python","fork":false,"url":"https://api.github.com/repos/mne-tools/mne-python","forks_url":"https://api.github.com/repos/mne-tools/mne-python/forks","keys_url":"https://api.github.com/repos/mne-tools/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mne-tools/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mne-tools/mne-python/teams","hooks_url":"https://api.github.com/repos/mne-tools/mne-python/hooks","issue_events_url":"https://api.github.com/repos/mne-tools/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/mne-tools/mne-python/events","assignees_url":"https://api.github.com/repos/mne-tools/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/mne-tools/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/mne-tools/mne-python/tags","blobs_url":"https://api.github.com/repos/mne-tools/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mne-tools/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mne-tools/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/mne-tools/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/mne-tools/mne-python/languages","stargazers_url":"https://api.github.com/repos/mne-tools/mne-python/stargazers","contributors_url":"https://api.github.com/repos/mne-tools/mne-python/contributors","subscribers_url":"https://api.github.com/repos/mne-tools/mne-python/subscribers","subscription_url":"https://api.github.com/repos/mne-tools/mne-python/subscription","commits_url":"https://api.github.com/repos/mne-tools/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/mne-tools/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/mne-tools/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/mne-tools/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/mne-tools/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/mne-tools/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mne-tools/mne-python/merges","archive_url":"https://api.github.com/repos/mne-tools/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mne-tools/mne-python/downloads","issues_url":"https://api.github.com/repos/mne-tools/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/mne-tools/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/mne-tools/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/mne-tools/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mne-tools/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/mne-tools/mne-python/releases{/id}","created_at":"2011-01-28T03:31:13Z","updated_at":"2015-07-10T19:14:50Z","pushed_at":"2015-07-14T07:28:11Z","git_url":"git://github.com/mne-tools/mne-python.git","ssh_url":"git@github.com:mne-tools/mne-python.git","clone_url":"https://github.com/mne-tools/mne-python.git","svn_url":"https://github.com/mne-tools/mne-python","homepage":"http://martinos.org/mne/","size":179622,"stargazers_count":138,"watchers_count":138,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":128,"mirror_url":null,"open_issues_count":178,"forks":128,"open_issues":178,"watchers":138,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2284"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2284"},"issue":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2284"},"comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2284/comments"},"review_comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2284/comments"},"review_comment":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2284/commits"},"statuses":{"href":"https://api.github.com/repos/mne-tools/mne-python/statuses/e028fa5120d02616177e7b573d07f5717c73b156"}}}}