Last active
October 12, 2017 17:32
-
-
Save edeno/bbc1c810edc1ced5ef7418ce78ccd454 to your computer and use it in GitHub Desktop.
Analytic spike-field and spike-spike coherence adjustment for conditions with different mean firing rates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def coherence_rate_adjustment(firing_rate_condition1, | |
firing_rate_condition2, spike_power_spectrum, | |
homogeneous_poisson_noise=0, dt=1): | |
'''Correction for the spike-field or spike-spike coherence when the | |
conditions have different firing rates. | |
When comparing the coherence of two conditions, a change in firing rate | |
results in a change in coherence without an increase in coupling. | |
This adjustment modifies the coherence of one of the conditions, so | |
that a difference in coherence between conditions indicates a change | |
in coupling, not firing rate. See [1] for details. | |
If using to compare spike-spike coherence, not that the coherence | |
adjustment must be applied twice, once for each spike train. | |
Adjusts `firing_rate_condition1` to `firing_rate_condition2`. | |
Parameters | |
---------- | |
firing_rate_condition1, firing_rate_condition2 : float | |
Average firing rates for each condition. | |
spike_power_spectrum : ndarray, shape (n_frequencies,) | |
Power spectrum of the spike train in condition 1. | |
homogeneous_poisson_noise : float, optional | |
Beta in [1]. | |
dt : float, optional | |
Size of time step. | |
Returns | |
------- | |
rate_adjustment_factor : ndarray, shape (n_frequencies) | |
References | |
---------- | |
.. [1] Aoi, M.C., Lepage, K.Q., Kramer, M.A., and Eden, U.T. (2015). | |
Rate-adjusted spike-LFP coherence comparisons from spike-train | |
statistics. Journal of Neuroscience Methods 240, 141-153. | |
''' | |
# alpha in [1] | |
firing_rate_ratio = firing_rate_condition2 / firing_rate_condition1 | |
adjusted_firing_rate = ( | |
(1 / firing_rate_ratio - 1) * firing_rate_condition1 + | |
homogeneous_poisson_noise / firing_rate_ratio ** 2) * dt ** 2 | |
return 1 / np.sqrt(1 + (adjusted_firing_rate / spike_power_spectrum)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment