{"action":"created","comment":{"url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/comments/224389588","pull_request_review_id":163740112,"id":224389588,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDM4OTU4OA==","diff_hunk":"@@ -134,6 +135,111 @@ def zscore(signal, inplace=True):\n         return result[0]\n     else:\n         return result\n+    \n+    \n+def cross_correlation_function(signal, ch_pairs, dt=1., env=False, nlags=None):\n+\n+    \"\"\"\n+    Computes unbiased estimator of the cross-correlation function.\n+    \n+    Calculates the unbiased estimator of the cross-correlation function \n+    R(tau) = 1/(N-|k|) R'(tau), where R'(tau) = E[x(t)*y(t+tau)] for signal1 \n+    and signal2 in a pairwise manner, i.e. signal1[0] vs signal2[0], signal1[1] \n+    vs signal2[1] and so on. The cross-correlation function is obtained \n+    by np.correlate. signal1 and signal2 are zscored beforehand.\n+    Alternatively returns the Hilbert envelope of R(tau), which is useful to \n+    determine the correlation length of oscillatory signals.\n+\n+    Parameters\n+    -----------\n+    signal : neo.AnalogSignal\n+        Signal that contains the LFP channels\n+    ch_pairs : list (or array with shape (N,2))\n+        list with N channel pairs for which to compute cross-correlation, \n+        each element of list must contain 2 channel indices\n+    dt : float\n+        Defines sampling period\n+    env: bool\n+        Return Hilbert envelope of cross-correlation function\n+    nlags: int\n+        Defines number of lags for cross-corelation function. Floats will be \n+        rounded to nearest integer. Output is of length 2*nlags+1. If None, \n+        len(tau) = Nt","path":"elephant/signal_processing.py","position":41,"original_position":41,"commit_id":"221df64dd4596c871b3877ffe83dfa10f138d9c3","original_commit_id":"221df64dd4596c871b3877ffe83dfa10f138d9c3","user":{"login":"JuliaSprenger","id":8088860,"node_id":"MDQ6VXNlcjgwODg4NjA=","avatar_url":"https://avatars1.githubusercontent.com/u/8088860?v=4","gravatar_id":"","url":"https://api.github.com/users/JuliaSprenger","html_url":"https://github.com/JuliaSprenger","followers_url":"https://api.github.com/users/JuliaSprenger/followers","following_url":"https://api.github.com/users/JuliaSprenger/following{/other_user}","gists_url":"https://api.github.com/users/JuliaSprenger/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaSprenger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaSprenger/subscriptions","organizations_url":"https://api.github.com/users/JuliaSprenger/orgs","repos_url":"https://api.github.com/users/JuliaSprenger/repos","events_url":"https://api.github.com/users/JuliaSprenger/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaSprenger/received_events","type":"User","site_admin":false},"body":"What is ```Nt```? The number of samples in the signals?","created_at":"2018-10-11T10:03:54Z","updated_at":"2018-10-11T10:03:54Z","html_url":"https://github.com/NeuralEnsemble/elephant/pull/170#discussion_r224389588","pull_request_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/170","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/comments/224389588"},"html":{"href":"https://github.com/NeuralEnsemble/elephant/pull/170#discussion_r224389588"},"pull_request":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/170"}}},"pull_request":{"url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/170","id":207274637,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3Mjc0NjM3","html_url":"https://github.com/NeuralEnsemble/elephant/pull/170","diff_url":"https://github.com/NeuralEnsemble/elephant/pull/170.diff","patch_url":"https://github.com/NeuralEnsemble/elephant/pull/170.patch","issue_url":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/170","number":170,"state":"open","locked":false,"title":"Cross-correlation function for analog signals","user":{"login":"mvonpapen","id":26275671,"node_id":"MDQ6VXNlcjI2Mjc1Njcx","avatar_url":"https://avatars2.githubusercontent.com/u/26275671?v=4","gravatar_id":"","url":"https://api.github.com/users/mvonpapen","html_url":"https://github.com/mvonpapen","followers_url":"https://api.github.com/users/mvonpapen/followers","following_url":"https://api.github.com/users/mvonpapen/following{/other_user}","gists_url":"https://api.github.com/users/mvonpapen/gists{/gist_id}","starred_url":"https://api.github.com/users/mvonpapen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvonpapen/subscriptions","organizations_url":"https://api.github.com/users/mvonpapen/orgs","repos_url":"https://api.github.com/users/mvonpapen/repos","events_url":"https://api.github.com/users/mvonpapen/events{/privacy}","received_events_url":"https://api.github.com/users/mvonpapen/received_events","type":"User","site_admin":false},"body":"Added a function \"cross_correlation_function\" in signal_processing.py that calculates the pairwise cross-correlation of selected channels within a neo.AnalogSignal. Optionally calculates the envelope of the cross-correlation function, which is helpful to determine the correlation length of an oscillatory signal.\r\n\r\nThe two signals, e.g. LFP, are zero padded to minimize boundary effects, transformed into Fourier domain, multiplied and transformed back into time domain. The signals are afterwards corrected (unbiased estimator) for zero-padding.\r\n\r\nThis function should not be confused with cross_corr_coeff option in cross_correlation_histogram function within spiketrain_correlation.py. The latter only works for CCH obtained from spiketrains and assumes Poissonian statistics (Equation (5.10) in \"Analysis of parallel spike trains\", 2010, Gruen & Rotter, Vol 7).\r\n\r\nThe input is \r\n- signal: neo.AnalogSignal\r\n- channel1/2: int, list, tuple, array; this determines the indices of the channels; cross-correlation will be calculated for pairs channel1[0] vs. channel2[0], channel1[1] vs channel2[1], and so forth\r\n- dt: sample resolution\r\n- env: bool; envelope yes or no\r\n- nlags: int; how many lags the output rho should have\r\n\r\nThe output is:\r\n- rho: array, the cross-correation function (ranging between -1 and 1) OR env, the envelope of rho\r\n- tau: array, vector of lags","created_at":"2018-08-09T10:46:10Z","updated_at":"2018-10-11T10:03:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e2bc340c9614581708d1943ee45633d7828741ff","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/170/commits","review_comments_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/170/comments","review_comment_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/170/comments","statuses_url":"https://api.github.com/repos/NeuralEnsemble/elephant/statuses/221df64dd4596c871b3877ffe83dfa10f138d9c3","head":{"label":"INM-6:xcorr","ref":"xcorr","sha":"221df64dd4596c871b3877ffe83dfa10f138d9c3","user":{"login":"INM-6","id":10058055,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMDU4MDU1","avatar_url":"https://avatars2.githubusercontent.com/u/10058055?v=4","gravatar_id":"","url":"https://api.github.com/users/INM-6","html_url":"https://github.com/INM-6","followers_url":"https://api.github.com/users/INM-6/followers","following_url":"https://api.github.com/users/INM-6/following{/other_user}","gists_url":"https://api.github.com/users/INM-6/gists{/gist_id}","starred_url":"https://api.github.com/users/INM-6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/INM-6/subscriptions","organizations_url":"https://api.github.com/users/INM-6/orgs","repos_url":"https://api.github.com/users/INM-6/repos","events_url":"https://api.github.com/users/INM-6/events{/privacy}","received_events_url":"https://api.github.com/users/INM-6/received_events","type":"Organization","site_admin":false},"repo":{"id":34374691,"node_id":"MDEwOlJlcG9zaXRvcnkzNDM3NDY5MQ==","name":"elephant","full_name":"INM-6/elephant","private":false,"owner":{"login":"INM-6","id":10058055,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMDU4MDU1","avatar_url":"https://avatars2.githubusercontent.com/u/10058055?v=4","gravatar_id":"","url":"https://api.github.com/users/INM-6","html_url":"https://github.com/INM-6","followers_url":"https://api.github.com/users/INM-6/followers","following_url":"https://api.github.com/users/INM-6/following{/other_user}","gists_url":"https://api.github.com/users/INM-6/gists{/gist_id}","starred_url":"https://api.github.com/users/INM-6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/INM-6/subscriptions","organizations_url":"https://api.github.com/users/INM-6/orgs","repos_url":"https://api.github.com/users/INM-6/repos","events_url":"https://api.github.com/users/INM-6/events{/privacy}","received_events_url":"https://api.github.com/users/INM-6/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/INM-6/elephant","description":"Elephant is the ElectroPhysiology Analysis Toolkit","fork":true,"url":"https://api.github.com/repos/INM-6/elephant","forks_url":"https://api.github.com/repos/INM-6/elephant/forks","keys_url":"https://api.github.com/repos/INM-6/elephant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/INM-6/elephant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/INM-6/elephant/teams","hooks_url":"https://api.github.com/repos/INM-6/elephant/hooks","issue_events_url":"https://api.github.com/repos/INM-6/elephant/issues/events{/number}","events_url":"https://api.github.com/repos/INM-6/elephant/events","assignees_url":"https://api.github.com/repos/INM-6/elephant/assignees{/user}","branches_url":"https://api.github.com/repos/INM-6/elephant/branches{/branch}","tags_url":"https://api.github.com/repos/INM-6/elephant/tags","blobs_url":"https://api.github.com/repos/INM-6/elephant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/INM-6/elephant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/INM-6/elephant/git/refs{/sha}","trees_url":"https://api.github.com/repos/INM-6/elephant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/INM-6/elephant/statuses/{sha}","languages_url":"https://api.github.com/repos/INM-6/elephant/languages","stargazers_url":"https://api.github.com/repos/INM-6/elephant/stargazers","contributors_url":"https://api.github.com/repos/INM-6/elephant/contributors","subscribers_url":"https://api.github.com/repos/INM-6/elephant/subscribers","subscription_url":"https://api.github.com/repos/INM-6/elephant/subscription","commits_url":"https://api.github.com/repos/INM-6/elephant/commits{/sha}","git_commits_url":"https://api.github.com/repos/INM-6/elephant/git/commits{/sha}","comments_url":"https://api.github.com/repos/INM-6/elephant/comments{/number}","issue_comment_url":"https://api.github.com/repos/INM-6/elephant/issues/comments{/number}","contents_url":"https://api.github.com/repos/INM-6/elephant/contents/{+path}","compare_url":"https://api.github.com/repos/INM-6/elephant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/INM-6/elephant/merges","archive_url":"https://api.github.com/repos/INM-6/elephant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/INM-6/elephant/downloads","issues_url":"https://api.github.com/repos/INM-6/elephant/issues{/number}","pulls_url":"https://api.github.com/repos/INM-6/elephant/pulls{/number}","milestones_url":"https://api.github.com/repos/INM-6/elephant/milestones{/number}","notifications_url":"https://api.github.com/repos/INM-6/elephant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/INM-6/elephant/labels{/name}","releases_url":"https://api.github.com/repos/INM-6/elephant/releases{/id}","deployments_url":"https://api.github.com/repos/INM-6/elephant/deployments","created_at":"2015-04-22T07:07:17Z","updated_at":"2018-09-13T12:02:03Z","pushed_at":"2018-10-11T09:46:08Z","git_url":"git://github.com/INM-6/elephant.git","ssh_url":"git@github.com:INM-6/elephant.git","clone_url":"https://github.com/INM-6/elephant.git","svn_url":"https://github.com/INM-6/elephant","homepage":"","size":2343,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":2,"open_issues":49,"watchers":2,"default_branch":"master"}},"base":{"label":"NeuralEnsemble:master","ref":"master","sha":"e54495bbdb3361c5e4ee6bcd5479f3ff1297dad8","user":{"login":"NeuralEnsemble","id":1540309,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NDAzMDk=","avatar_url":"https://avatars3.githubusercontent.com/u/1540309?v=4","gravatar_id":"","url":"https://api.github.com/users/NeuralEnsemble","html_url":"https://github.com/NeuralEnsemble","followers_url":"https://api.github.com/users/NeuralEnsemble/followers","following_url":"https://api.github.com/users/NeuralEnsemble/following{/other_user}","gists_url":"https://api.github.com/users/NeuralEnsemble/gists{/gist_id}","starred_url":"https://api.github.com/users/NeuralEnsemble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeuralEnsemble/subscriptions","organizations_url":"https://api.github.com/users/NeuralEnsemble/orgs","repos_url":"https://api.github.com/users/NeuralEnsemble/repos","events_url":"https://api.github.com/users/NeuralEnsemble/events{/privacy}","received_events_url":"https://api.github.com/users/NeuralEnsemble/received_events","type":"Organization","site_admin":false},"repo":{"id":10311278,"node_id":"MDEwOlJlcG9zaXRvcnkxMDMxMTI3OA==","name":"elephant","full_name":"NeuralEnsemble/elephant","private":false,"owner":{"login":"NeuralEnsemble","id":1540309,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NDAzMDk=","avatar_url":"https://avatars3.githubusercontent.com/u/1540309?v=4","gravatar_id":"","url":"https://api.github.com/users/NeuralEnsemble","html_url":"https://github.com/NeuralEnsemble","followers_url":"https://api.github.com/users/NeuralEnsemble/followers","following_url":"https://api.github.com/users/NeuralEnsemble/following{/other_user}","gists_url":"https://api.github.com/users/NeuralEnsemble/gists{/gist_id}","starred_url":"https://api.github.com/users/NeuralEnsemble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeuralEnsemble/subscriptions","organizations_url":"https://api.github.com/users/NeuralEnsemble/orgs","repos_url":"https://api.github.com/users/NeuralEnsemble/repos","events_url":"https://api.github.com/users/NeuralEnsemble/events{/privacy}","received_events_url":"https://api.github.com/users/NeuralEnsemble/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/NeuralEnsemble/elephant","description":"Elephant is the Electrophysiology Analysis Toolkit","fork":false,"url":"https://api.github.com/repos/NeuralEnsemble/elephant","forks_url":"https://api.github.com/repos/NeuralEnsemble/elephant/forks","keys_url":"https://api.github.com/repos/NeuralEnsemble/elephant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NeuralEnsemble/elephant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NeuralEnsemble/elephant/teams","hooks_url":"https://api.github.com/repos/NeuralEnsemble/elephant/hooks","issue_events_url":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/events{/number}","events_url":"https://api.github.com/repos/NeuralEnsemble/elephant/events","assignees_url":"https://api.github.com/repos/NeuralEnsemble/elephant/assignees{/user}","branches_url":"https://api.github.com/repos/NeuralEnsemble/elephant/branches{/branch}","tags_url":"https://api.github.com/repos/NeuralEnsemble/elephant/tags","blobs_url":"https://api.github.com/repos/NeuralEnsemble/elephant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NeuralEnsemble/elephant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NeuralEnsemble/elephant/git/refs{/sha}","trees_url":"https://api.github.com/repos/NeuralEnsemble/elephant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NeuralEnsemble/elephant/statuses/{sha}","languages_url":"https://api.github.com/repos/NeuralEnsemble/elephant/languages","stargazers_url":"https://api.github.com/repos/NeuralEnsemble/elephant/stargazers","contributors_url":"https://api.github.com/repos/NeuralEnsemble/elephant/contributors","subscribers_url":"https://api.github.com/repos/NeuralEnsemble/elephant/subscribers","subscription_url":"https://api.github.com/repos/NeuralEnsemble/elephant/subscription","commits_url":"https://api.github.com/repos/NeuralEnsemble/elephant/commits{/sha}","git_commits_url":"https://api.github.com/repos/NeuralEnsemble/elephant/git/commits{/sha}","comments_url":"https://api.github.com/repos/NeuralEnsemble/elephant/comments{/number}","issue_comment_url":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/comments{/number}","contents_url":"https://api.github.com/repos/NeuralEnsemble/elephant/contents/{+path}","compare_url":"https://api.github.com/repos/NeuralEnsemble/elephant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NeuralEnsemble/elephant/merges","archive_url":"https://api.github.com/repos/NeuralEnsemble/elephant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NeuralEnsemble/elephant/downloads","issues_url":"https://api.github.com/repos/NeuralEnsemble/elephant/issues{/number}","pulls_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls{/number}","milestones_url":"https://api.github.com/repos/NeuralEnsemble/elephant/milestones{/number}","notifications_url":"https://api.github.com/repos/NeuralEnsemble/elephant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NeuralEnsemble/elephant/labels{/name}","releases_url":"https://api.github.com/repos/NeuralEnsemble/elephant/releases{/id}","deployments_url":"https://api.github.com/repos/NeuralEnsemble/elephant/deployments","created_at":"2013-05-27T08:59:34Z","updated_at":"2018-10-11T09:41:35Z","pushed_at":"2018-10-11T09:52:12Z","git_url":"git://github.com/NeuralEnsemble/elephant.git","ssh_url":"git@github.com:NeuralEnsemble/elephant.git","clone_url":"https://github.com/NeuralEnsemble/elephant.git","svn_url":"https://github.com/NeuralEnsemble/elephant","homepage":"http://www.python-elephant.org","size":1300,"stargazers_count":39,"watchers_count":39,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":53,"mirror_url":null,"archived":false,"open_issues_count":25,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":53,"open_issues":25,"watchers":39,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/170"},"html":{"href":"https://github.com/NeuralEnsemble/elephant/pull/170"},"issue":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/170"},"comments":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/170/comments"},"review_comments":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/170/comments"},"review_comment":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/170/commits"},"statuses":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/statuses/221df64dd4596c871b3877ffe83dfa10f138d9c3"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"JuliaSprenger"}}