{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/comments/65152480","id":65152480,"diff_hunk":"@@ -0,0 +1,106 @@\n+\"\"\"\n+==============================================================\n+Visualize phase-amplitude coupling measures between signals\n+==============================================================\n+Computes the normalized amplitude traces for a cross frequency coupled\n+signal across a given range of frequencies and displays it along with\n+the event related average response.\n+References\n+----------\n+[1] Canolty RT, Edwards E, Dalal SS, Soltani M, Nagarajan SS, Kirsch HE,\n+    Berger MS, Barbaro NM, Knight RT. \"High gamma power is phase-locked to\n+    theta oscillations in human neocortex.\" Science. 2006.\n+[2] Tort ABL, Komorowski R, Eichenbaum H, Kopell N. Measuring phase-amplitude\n+    coupling between neuronal oscillations of different frequencies. Journal of\n+    Neurophysiology. 2010.\n+\"\"\"\n+# Author: Chris Holdgraf <choldgraf@berkeley.edu>\n+#         Praveen Sripad <praveen.sripad@rwth-aachen.de>\n+#         Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>\n+#\n+# License: BSD (3-clause)\n+\n+import numpy as np\n+\n+import mne\n+from mne import io\n+from mne.datasets import sample\n+from mne_sandbox.connectivity import (phase_amplitude_coupling,\n+                                      plot_phase_locked_amplitude,\n+                                      plot_phase_binned_amplitude)\n+import matplotlib.pyplot as plt\n+\n+print(__doc__)\n+\n+###############################################################################\n+# Set parameters\n+data_path = sample.data_path()\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+\n+# Setup for reading the raw data\n+raw = io.Raw(raw_fname, preload=True)\n+events = mne.read_events(event_fname)\n+ev_ixs = events[:, 0].astype(int)\n+\n+# Add a bad channel\n+raw.info['bads'] += ['MEG 2443']\n+\n+# Pick MEG gradiometers\n+raw = raw.pick_types(meg='grad', eeg=False, stim=False, eog=True,\n+                     exclude='bads')\n+\n+# Define a pair of indices\n+ixs = [(4, 10)]\n+ix_ph, ix_amp = ixs[0]\n+\n+# First we can simply calculate a PAC statistic for these signals\n+f_range_phase = (6, 8)\n+f_range_amp = (40, 60)\n+\n+# Create some artifical PAC data to show the effect\n+# Calculate the low-frequency phase\n+raw_phase = raw.copy()\n+raw_phase = raw_phase.filter(*f_range_phase)\n+raw_phase.apply_hilbert([ix_ph])\n+angles = np.angle(raw_phase._data[1])\n+msk_angles = angles > (.5 * np.pi)\n+\n+# Take the high-frequency component of the signal, and modulate it w/ the phase\n+raw_band = raw.copy()\n+raw_band = raw_band.filter(*f_range_amp)\n+raw_band._data[ix_amp][~msk_angles] = 0\n+raw_band._data[ix_amp][msk_angles] *= 10.\n+\n+# Now add the high-freq signal back into the raw data\n+raw_artificial = raw.copy()\n+raw_artificial._data[ix_amp] += raw_band._data[ix_amp]\n+\n+for i_data in [raw, raw_artificial]:\n+    pac = phase_amplitude_coupling(\n+        i_data, f_range_phase, f_range_amp, ixs, pac_func='glm',\n+        events=ev_ixs, tmin=0, tmax=.5)\n+    pac = pac.mean()  # Average across events","path":"examples/connectivity/plot_pac_viz.py","position":83,"original_position":83,"commit_id":"b445843ba54db68b59da26de8ed1a1921f019d04","original_commit_id":"b445843ba54db68b59da26de8ed1a1921f019d04","user":{"login":"TomDLT","id":11065596,"avatar_url":"https://avatars.githubusercontent.com/u/11065596?v=3","gravatar_id":"","url":"https://api.github.com/users/TomDLT","html_url":"https://github.com/TomDLT","followers_url":"https://api.github.com/users/TomDLT/followers","following_url":"https://api.github.com/users/TomDLT/following{/other_user}","gists_url":"https://api.github.com/users/TomDLT/gists{/gist_id}","starred_url":"https://api.github.com/users/TomDLT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomDLT/subscriptions","organizations_url":"https://api.github.com/users/TomDLT/orgs","repos_url":"https://api.github.com/users/TomDLT/repos","events_url":"https://api.github.com/users/TomDLT/events{/privacy}","received_events_url":"https://api.github.com/users/TomDLT/received_events","type":"User","site_admin":false},"body":"`pac = pac[0].mean()`","created_at":"2016-05-31T09:49:33Z","updated_at":"2016-05-31T09:49:33Z","html_url":"https://github.com/mne-tools/mne-sandbox/pull/7#discussion_r65152480","pull_request_url":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/comments/65152480"},"html":{"href":"https://github.com/mne-tools/mne-sandbox/pull/7#discussion_r65152480"},"pull_request":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/7","id":66236100,"html_url":"https://github.com/mne-tools/mne-sandbox/pull/7","diff_url":"https://github.com/mne-tools/mne-sandbox/pull/7.diff","patch_url":"https://github.com/mne-tools/mne-sandbox/pull/7.patch","issue_url":"https://api.github.com/repos/mne-tools/mne-sandbox/issues/7","number":7,"state":"open","locked":false,"title":"adding CFC code, first commit","user":{"login":"choldgraf","id":1839645,"avatar_url":"https://avatars.githubusercontent.com/u/1839645?v=3","gravatar_id":"","url":"https://api.github.com/users/choldgraf","html_url":"https://github.com/choldgraf","followers_url":"https://api.github.com/users/choldgraf/followers","following_url":"https://api.github.com/users/choldgraf/following{/other_user}","gists_url":"https://api.github.com/users/choldgraf/gists{/gist_id}","starred_url":"https://api.github.com/users/choldgraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choldgraf/subscriptions","organizations_url":"https://api.github.com/users/choldgraf/orgs","repos_url":"https://api.github.com/users/choldgraf/repos","events_url":"https://api.github.com/users/choldgraf/events{/privacy}","received_events_url":"https://api.github.com/users/choldgraf/received_events","type":"User","site_admin":false},"body":"This is a modified port of the CFC code in the PR here: https://github.com/mne-tools/mne-python/pull/2306\r\n\r\nThe code has been cleaned up a bit and some new features have been added (e.g., ability to concatenate epochs before calculating CFC vs. calculating CFC individually for each epoch). It still has a ways to go and I'm unsure of the specific features to include, so all comments are welcome. I've also included a couple of visualization features. Some thoughts on next steps:\r\n\r\n1. Create a good example, preferably with some data that shows clear CFC\r\n2. Determine the scope of functionality for this\r\n3. Freeze and API\r\n4. Think of some good benchmarks for CFC\r\n\r\nLMKWYT","created_at":"2016-04-12T22:05:58Z","updated_at":"2016-05-31T09:49:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8fb00d3d23371df5619c6e7216426aea5fe1c89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/7/commits","review_comments_url":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/7/comments","review_comment_url":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mne-tools/mne-sandbox/issues/7/comments","statuses_url":"https://api.github.com/repos/mne-tools/mne-sandbox/statuses/b445843ba54db68b59da26de8ed1a1921f019d04","head":{"label":"choldgraf:add_cfc","ref":"add_cfc","sha":"b445843ba54db68b59da26de8ed1a1921f019d04","user":{"login":"choldgraf","id":1839645,"avatar_url":"https://avatars.githubusercontent.com/u/1839645?v=3","gravatar_id":"","url":"https://api.github.com/users/choldgraf","html_url":"https://github.com/choldgraf","followers_url":"https://api.github.com/users/choldgraf/followers","following_url":"https://api.github.com/users/choldgraf/following{/other_user}","gists_url":"https://api.github.com/users/choldgraf/gists{/gist_id}","starred_url":"https://api.github.com/users/choldgraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choldgraf/subscriptions","organizations_url":"https://api.github.com/users/choldgraf/orgs","repos_url":"https://api.github.com/users/choldgraf/repos","events_url":"https://api.github.com/users/choldgraf/events{/privacy}","received_events_url":"https://api.github.com/users/choldgraf/received_events","type":"User","site_admin":false},"repo":{"id":56100249,"name":"mne-sandbox","full_name":"choldgraf/mne-sandbox","owner":{"login":"choldgraf","id":1839645,"avatar_url":"https://avatars.githubusercontent.com/u/1839645?v=3","gravatar_id":"","url":"https://api.github.com/users/choldgraf","html_url":"https://github.com/choldgraf","followers_url":"https://api.github.com/users/choldgraf/followers","following_url":"https://api.github.com/users/choldgraf/following{/other_user}","gists_url":"https://api.github.com/users/choldgraf/gists{/gist_id}","starred_url":"https://api.github.com/users/choldgraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choldgraf/subscriptions","organizations_url":"https://api.github.com/users/choldgraf/orgs","repos_url":"https://api.github.com/users/choldgraf/repos","events_url":"https://api.github.com/users/choldgraf/events{/privacy}","received_events_url":"https://api.github.com/users/choldgraf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/choldgraf/mne-sandbox","description":"experimental mne-python code","fork":true,"url":"https://api.github.com/repos/choldgraf/mne-sandbox","forks_url":"https://api.github.com/repos/choldgraf/mne-sandbox/forks","keys_url":"https://api.github.com/repos/choldgraf/mne-sandbox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/choldgraf/mne-sandbox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/choldgraf/mne-sandbox/teams","hooks_url":"https://api.github.com/repos/choldgraf/mne-sandbox/hooks","issue_events_url":"https://api.github.com/repos/choldgraf/mne-sandbox/issues/events{/number}","events_url":"https://api.github.com/repos/choldgraf/mne-sandbox/events","assignees_url":"https://api.github.com/repos/choldgraf/mne-sandbox/assignees{/user}","branches_url":"https://api.github.com/repos/choldgraf/mne-sandbox/branches{/branch}","tags_url":"https://api.github.com/repos/choldgraf/mne-sandbox/tags","blobs_url":"https://api.github.com/repos/choldgraf/mne-sandbox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/choldgraf/mne-sandbox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/choldgraf/mne-sandbox/git/refs{/sha}","trees_url":"https://api.github.com/repos/choldgraf/mne-sandbox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/choldgraf/mne-sandbox/statuses/{sha}","languages_url":"https://api.github.com/repos/choldgraf/mne-sandbox/languages","stargazers_url":"https://api.github.com/repos/choldgraf/mne-sandbox/stargazers","contributors_url":"https://api.github.com/repos/choldgraf/mne-sandbox/contributors","subscribers_url":"https://api.github.com/repos/choldgraf/mne-sandbox/subscribers","subscription_url":"https://api.github.com/repos/choldgraf/mne-sandbox/subscription","commits_url":"https://api.github.com/repos/choldgraf/mne-sandbox/commits{/sha}","git_commits_url":"https://api.github.com/repos/choldgraf/mne-sandbox/git/commits{/sha}","comments_url":"https://api.github.com/repos/choldgraf/mne-sandbox/comments{/number}","issue_comment_url":"https://api.github.com/repos/choldgraf/mne-sandbox/issues/comments{/number}","contents_url":"https://api.github.com/repos/choldgraf/mne-sandbox/contents/{+path}","compare_url":"https://api.github.com/repos/choldgraf/mne-sandbox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/choldgraf/mne-sandbox/merges","archive_url":"https://api.github.com/repos/choldgraf/mne-sandbox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/choldgraf/mne-sandbox/downloads","issues_url":"https://api.github.com/repos/choldgraf/mne-sandbox/issues{/number}","pulls_url":"https://api.github.com/repos/choldgraf/mne-sandbox/pulls{/number}","milestones_url":"https://api.github.com/repos/choldgraf/mne-sandbox/milestones{/number}","notifications_url":"https://api.github.com/repos/choldgraf/mne-sandbox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/choldgraf/mne-sandbox/labels{/name}","releases_url":"https://api.github.com/repos/choldgraf/mne-sandbox/releases{/id}","deployments_url":"https://api.github.com/repos/choldgraf/mne-sandbox/deployments","created_at":"2016-04-12T21:48:53Z","updated_at":"2016-04-12T21:48:54Z","pushed_at":"2016-05-25T20:06:12Z","git_url":"git://github.com/choldgraf/mne-sandbox.git","ssh_url":"git@github.com:choldgraf/mne-sandbox.git","clone_url":"https://github.com/choldgraf/mne-sandbox.git","svn_url":"https://github.com/choldgraf/mne-sandbox","homepage":null,"size":60,"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":"91626fb23518be4262f6435836bed5c1512afcdc","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":53668965,"name":"mne-sandbox","full_name":"mne-tools/mne-sandbox","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-sandbox","description":"experimental mne-python code","fork":false,"url":"https://api.github.com/repos/mne-tools/mne-sandbox","forks_url":"https://api.github.com/repos/mne-tools/mne-sandbox/forks","keys_url":"https://api.github.com/repos/mne-tools/mne-sandbox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mne-tools/mne-sandbox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mne-tools/mne-sandbox/teams","hooks_url":"https://api.github.com/repos/mne-tools/mne-sandbox/hooks","issue_events_url":"https://api.github.com/repos/mne-tools/mne-sandbox/issues/events{/number}","events_url":"https://api.github.com/repos/mne-tools/mne-sandbox/events","assignees_url":"https://api.github.com/repos/mne-tools/mne-sandbox/assignees{/user}","branches_url":"https://api.github.com/repos/mne-tools/mne-sandbox/branches{/branch}","tags_url":"https://api.github.com/repos/mne-tools/mne-sandbox/tags","blobs_url":"https://api.github.com/repos/mne-tools/mne-sandbox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mne-tools/mne-sandbox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mne-tools/mne-sandbox/git/refs{/sha}","trees_url":"https://api.github.com/repos/mne-tools/mne-sandbox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mne-tools/mne-sandbox/statuses/{sha}","languages_url":"https://api.github.com/repos/mne-tools/mne-sandbox/languages","stargazers_url":"https://api.github.com/repos/mne-tools/mne-sandbox/stargazers","contributors_url":"https://api.github.com/repos/mne-tools/mne-sandbox/contributors","subscribers_url":"https://api.github.com/repos/mne-tools/mne-sandbox/subscribers","subscription_url":"https://api.github.com/repos/mne-tools/mne-sandbox/subscription","commits_url":"https://api.github.com/repos/mne-tools/mne-sandbox/commits{/sha}","git_commits_url":"https://api.github.com/repos/mne-tools/mne-sandbox/git/commits{/sha}","comments_url":"https://api.github.com/repos/mne-tools/mne-sandbox/comments{/number}","issue_comment_url":"https://api.github.com/repos/mne-tools/mne-sandbox/issues/comments{/number}","contents_url":"https://api.github.com/repos/mne-tools/mne-sandbox/contents/{+path}","compare_url":"https://api.github.com/repos/mne-tools/mne-sandbox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mne-tools/mne-sandbox/merges","archive_url":"https://api.github.com/repos/mne-tools/mne-sandbox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mne-tools/mne-sandbox/downloads","issues_url":"https://api.github.com/repos/mne-tools/mne-sandbox/issues{/number}","pulls_url":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls{/number}","milestones_url":"https://api.github.com/repos/mne-tools/mne-sandbox/milestones{/number}","notifications_url":"https://api.github.com/repos/mne-tools/mne-sandbox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mne-tools/mne-sandbox/labels{/name}","releases_url":"https://api.github.com/repos/mne-tools/mne-sandbox/releases{/id}","deployments_url":"https://api.github.com/repos/mne-tools/mne-sandbox/deployments","created_at":"2016-03-11T13:30:09Z","updated_at":"2016-05-13T01:48:32Z","pushed_at":"2016-05-25T20:06:12Z","git_url":"git://github.com/mne-tools/mne-sandbox.git","ssh_url":"git@github.com:mne-tools/mne-sandbox.git","clone_url":"https://github.com/mne-tools/mne-sandbox.git","svn_url":"https://github.com/mne-tools/mne-sandbox","homepage":null,"size":153,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":6,"forks":8,"open_issues":6,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/7"},"html":{"href":"https://github.com/mne-tools/mne-sandbox/pull/7"},"issue":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/issues/7"},"comments":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/mne-tools/mne-sandbox/statuses/b445843ba54db68b59da26de8ed1a1921f019d04"}}}}
{"actor":{"display_login":"TomDLT"}}