{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-sandbox/pulls/comments/63238156","id":63238156,"diff_hunk":"@@ -0,0 +1,157 @@\n+\"\"\"\n+==============================================================\n+Compute phase-amplitude coupling measures between signals\n+==============================================================\n+Simulate phase-amplitude coupling between two signals, and computes\n+several PAC metrics between them. Calculates PAC for all timepoints, as well\n+as for time-locked PAC responses.\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+#\n+# License: BSD (3-clause)\n+import mne\n+import numpy as np\n+from matplotlib import pyplot as plt\n+from mne_sandbox.connectivity import (simulate_pac_signal,\n+                                      phase_amplitude_coupling)\n+\n+print(__doc__)\n+\n+###############################################################################\n+# Phase-amplitude coupling (PAC) is a technique to determine if the\n+# amplitude of a high-frequency signal is locked to the phase\n+# of a low-frequency signal. The phase_amplitude_coupling function\n+# calculates PAC between pairs of signals for one or multiple\n+# time windows. In this example, we'll simulate two signals. One\n+# of the signals has an amplitude that is locked to the phase of\n+# the other. We'll calculate PAC for a number of time points, and\n+# in both directions to show how PAC responds.\n+\n+# Define parameters for our simulated signal\n+sfreq = 1000.\n+f_phase = 4\n+f_amp = 40\n+frac_pac = .99  # This is the fraction of PAC to use\n+mag_ph = 4\n+mag_am = 1\n+\n+# These are the times where PAC is active in our simulated signal\n+n_secs = 20.\n+time = np.arange(0, n_secs, 1. / sfreq)\n+event_times = [1, 5, 9, 13, 17]\n+event_dur = 2.\n+\n+# Create a time maks that defines when PAC is active","path":"examples/connectivity/plot_pac.py","position":52,"original_position":52,"commit_id":"88eb3c34c76f70ef766893583e5cfd66124849df","original_commit_id":"88eb3c34c76f70ef766893583e5cfd66124849df","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":"mask","created_at":"2016-05-13T19:25:34Z","updated_at":"2016-05-13T19:25:34Z","html_url":"https://github.com/mne-tools/mne-sandbox/pull/7#discussion_r63238156","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/63238156"},"html":{"href":"https://github.com/mne-tools/mne-sandbox/pull/7#discussion_r63238156"},"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-13T19:25:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f79bc2f2bbd84657bdff5e6273380365b65d489","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/88eb3c34c76f70ef766893583e5cfd66124849df","head":{"label":"choldgraf:add_cfc","ref":"add_cfc","sha":"88eb3c34c76f70ef766893583e5cfd66124849df","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-13T18:29:23Z","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":52,"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":"9906704012e0f7d83dc0159efc95d61aa6f8abd9","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-13T18:29:24Z","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":118,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":7,"forks":7,"open_issues":7,"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/88eb3c34c76f70ef766893583e5cfd66124849df"}}}}