{"action":"created","comment":{"url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/comments/27281469","id":27281469,"diff_hunk":"@@ -0,0 +1,131 @@\n+# -*- coding: utf-8 -*-\n+\"\"\"\n+Spike train correlation\n+\n+This modules provides functions to calculate correlations between spike trains.\n+\n+:copyright: Copyright 2014 by the Elephant team, see AUTHORS.txt.\n+:license: Modified BSD, see LICENSE.txt for details.\n+\"\"\"\n+from __future__ import division\n+import numpy as np\n+\n+\n+def corrcoef(binned_sts, binary=False):\n+    '''\n+    Calculate the NxN matrix of pairwise Pearson's correlation coefficients\n+    between all combinations of N binned spike trains.\n+\n+    For each pair of spike trains $(i,j)$, the correlation coefficient $C[i,j]$\n+    is given by the correlation coefficient between the vectors obtained by\n+    binning $i$ and $j$ at the desired bin size. Let $b_i$ and $b_j$ denote the\n+    binary vectors and $m_i$ and  $m_j$ their respective averages. Then\n+\n+    .math $$ C[i,j] = <b_i-m_i, b_j-m_j> /\n+                      \\sqrt{<b_i-m_i, b_i-m_i>*<b_j-m_j,b_j-m_j>} $$\n+\n+    where <..,.> is the scalar product of two vectors.\n+\n+    For an input of n spike trains, a n x n matrix is returned.\n+    Each entry in the matrix is a real number ranging between -1 (perfectly\n+    anti-correlated spike trains) and +1 (perfectly correlated spike trains).\n+\n+    If binary is True, the binned spike trains are clipped before computing the\n+    correlation coefficients, so that the binned vectors b_i, b_j are binary.\n+\n+    Parameters\n+    ----------\n+    binned_sts : elephant.conversion.BinnedSpikeTrain\n+        A binned spike train class containing the spike trains to be evaluated.\n+    binary : bool, optional\n+        If True, two spikes of a particular spike train falling in the same\n+        bin are counted as 1, resulting in binary binned vectors b_i. If False,\n+        the binned vectors $b_i$ contain the actually spike counts per bin.","path":"elephant/spike_train_correlation.py","position":43,"original_position":43,"commit_id":"73c1cd2329980950c91597625cc7ebb26f7f4ff7","original_commit_id":"73c1cd2329980950c91597625cc7ebb26f7f4ff7","user":{"login":"apdavison","id":260552,"avatar_url":"https://avatars.githubusercontent.com/u/260552?v=3","gravatar_id":"","url":"https://api.github.com/users/apdavison","html_url":"https://github.com/apdavison","followers_url":"https://api.github.com/users/apdavison/followers","following_url":"https://api.github.com/users/apdavison/following{/other_user}","gists_url":"https://api.github.com/users/apdavison/gists{/gist_id}","starred_url":"https://api.github.com/users/apdavison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apdavison/subscriptions","organizations_url":"https://api.github.com/users/apdavison/orgs","repos_url":"https://api.github.com/users/apdavison/repos","events_url":"https://api.github.com/users/apdavison/events{/privacy}","received_events_url":"https://api.github.com/users/apdavison/received_events","type":"User","site_admin":false},"body":"remove \"actually\"","created_at":"2015-03-27T08:42:39Z","updated_at":"2015-03-27T08:42:39Z","html_url":"https://github.com/NeuralEnsemble/elephant/pull/28#discussion_r27281469","pull_request_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/comments/27281469"},"html":{"href":"https://github.com/NeuralEnsemble/elephant/pull/28#discussion_r27281469"},"pull_request":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/28","id":31996280,"html_url":"https://github.com/NeuralEnsemble/elephant/pull/28","diff_url":"https://github.com/NeuralEnsemble/elephant/pull/28.diff","patch_url":"https://github.com/NeuralEnsemble/elephant/pull/28.patch","issue_url":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/28","number":28,"state":"open","locked":false,"title":"Correlation coefficient","user":{"login":"mdenker","id":3081044,"avatar_url":"https://avatars.githubusercontent.com/u/3081044?v=3","gravatar_id":"","url":"https://api.github.com/users/mdenker","html_url":"https://github.com/mdenker","followers_url":"https://api.github.com/users/mdenker/followers","following_url":"https://api.github.com/users/mdenker/following{/other_user}","gists_url":"https://api.github.com/users/mdenker/gists{/gist_id}","starred_url":"https://api.github.com/users/mdenker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdenker/subscriptions","organizations_url":"https://api.github.com/users/mdenker/orgs","repos_url":"https://api.github.com/users/mdenker/repos","events_url":"https://api.github.com/users/mdenker/events{/privacy}","received_events_url":"https://api.github.com/users/mdenker/received_events","type":"User","site_admin":false},"body":"This pull request provides a new module on spike train correlations. It provides a function to calculate the matrix of correlation coefficients for a list of BinnedSpikeTrain objects (using its internal sparse matrix representation, thus avoiding the need to construct large binned matrices).","created_at":"2015-03-26T08:08:18Z","updated_at":"2015-03-27T08:42:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4aa892fa97af2086c298709532af7a9ab6543f87","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/28/commits","review_comments_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/28/comments","review_comment_url":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/28/comments","statuses_url":"https://api.github.com/repos/NeuralEnsemble/elephant/statuses/73c1cd2329980950c91597625cc7ebb26f7f4ff7","head":{"label":"mdenker:correlation_coefficient","ref":"correlation_coefficient","sha":"73c1cd2329980950c91597625cc7ebb26f7f4ff7","user":{"login":"mdenker","id":3081044,"avatar_url":"https://avatars.githubusercontent.com/u/3081044?v=3","gravatar_id":"","url":"https://api.github.com/users/mdenker","html_url":"https://github.com/mdenker","followers_url":"https://api.github.com/users/mdenker/followers","following_url":"https://api.github.com/users/mdenker/following{/other_user}","gists_url":"https://api.github.com/users/mdenker/gists{/gist_id}","starred_url":"https://api.github.com/users/mdenker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdenker/subscriptions","organizations_url":"https://api.github.com/users/mdenker/orgs","repos_url":"https://api.github.com/users/mdenker/repos","events_url":"https://api.github.com/users/mdenker/events{/privacy}","received_events_url":"https://api.github.com/users/mdenker/received_events","type":"User","site_admin":false},"repo":{"id":16372545,"name":"elephant","full_name":"mdenker/elephant","owner":{"login":"mdenker","id":3081044,"avatar_url":"https://avatars.githubusercontent.com/u/3081044?v=3","gravatar_id":"","url":"https://api.github.com/users/mdenker","html_url":"https://github.com/mdenker","followers_url":"https://api.github.com/users/mdenker/followers","following_url":"https://api.github.com/users/mdenker/following{/other_user}","gists_url":"https://api.github.com/users/mdenker/gists{/gist_id}","starred_url":"https://api.github.com/users/mdenker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdenker/subscriptions","organizations_url":"https://api.github.com/users/mdenker/orgs","repos_url":"https://api.github.com/users/mdenker/repos","events_url":"https://api.github.com/users/mdenker/events{/privacy}","received_events_url":"https://api.github.com/users/mdenker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mdenker/elephant","description":"ElePhAnT - Electrophysiolog Analysis Toolkit","fork":true,"url":"https://api.github.com/repos/mdenker/elephant","forks_url":"https://api.github.com/repos/mdenker/elephant/forks","keys_url":"https://api.github.com/repos/mdenker/elephant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdenker/elephant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdenker/elephant/teams","hooks_url":"https://api.github.com/repos/mdenker/elephant/hooks","issue_events_url":"https://api.github.com/repos/mdenker/elephant/issues/events{/number}","events_url":"https://api.github.com/repos/mdenker/elephant/events","assignees_url":"https://api.github.com/repos/mdenker/elephant/assignees{/user}","branches_url":"https://api.github.com/repos/mdenker/elephant/branches{/branch}","tags_url":"https://api.github.com/repos/mdenker/elephant/tags","blobs_url":"https://api.github.com/repos/mdenker/elephant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdenker/elephant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdenker/elephant/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdenker/elephant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdenker/elephant/statuses/{sha}","languages_url":"https://api.github.com/repos/mdenker/elephant/languages","stargazers_url":"https://api.github.com/repos/mdenker/elephant/stargazers","contributors_url":"https://api.github.com/repos/mdenker/elephant/contributors","subscribers_url":"https://api.github.com/repos/mdenker/elephant/subscribers","subscription_url":"https://api.github.com/repos/mdenker/elephant/subscription","commits_url":"https://api.github.com/repos/mdenker/elephant/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdenker/elephant/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdenker/elephant/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdenker/elephant/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdenker/elephant/contents/{+path}","compare_url":"https://api.github.com/repos/mdenker/elephant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdenker/elephant/merges","archive_url":"https://api.github.com/repos/mdenker/elephant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdenker/elephant/downloads","issues_url":"https://api.github.com/repos/mdenker/elephant/issues{/number}","pulls_url":"https://api.github.com/repos/mdenker/elephant/pulls{/number}","milestones_url":"https://api.github.com/repos/mdenker/elephant/milestones{/number}","notifications_url":"https://api.github.com/repos/mdenker/elephant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdenker/elephant/labels{/name}","releases_url":"https://api.github.com/repos/mdenker/elephant/releases{/id}","created_at":"2014-01-30T09:01:52Z","updated_at":"2015-03-25T16:12:41Z","pushed_at":"2015-03-26T16:56:17Z","git_url":"git://github.com/mdenker/elephant.git","ssh_url":"git@github.com:mdenker/elephant.git","clone_url":"https://github.com/mdenker/elephant.git","svn_url":"https://github.com/mdenker/elephant","homepage":"","size":293,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"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":1,"default_branch":"master"}},"base":{"label":"NeuralEnsemble:master","ref":"master","sha":"ddc6fe94e3f79691a5399941535c4fcd3cca79fc","user":{"login":"NeuralEnsemble","id":1540309,"avatar_url":"https://avatars.githubusercontent.com/u/1540309?v=3","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,"name":"elephant","full_name":"NeuralEnsemble/elephant","owner":{"login":"NeuralEnsemble","id":1540309,"avatar_url":"https://avatars.githubusercontent.com/u/1540309?v=3","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},"private":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}","created_at":"2013-05-27T08:59:34Z","updated_at":"2015-03-25T08:55:47Z","pushed_at":"2015-03-26T08:08:18Z","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":"","size":812,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":6,"forks":17,"open_issues":6,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/28"},"html":{"href":"https://github.com/NeuralEnsemble/elephant/pull/28"},"issue":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/28"},"comments":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/NeuralEnsemble/elephant/statuses/73c1cd2329980950c91597625cc7ebb26f7f4ff7"}}}}