Skip to content

Instantly share code, notes, and snippets.

View JR1995_SingleColumn_Figure3.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
rat-h /
Last active Jun 3, 2021
Code for estimation R2 in a not-so-periodic network firing rate
import numpy as np
def compute_SPC_R2_meanFR(
spbins, #STH 1ms/bin
ksigma= 3., #sigma for Gaussian to smooth FR
kwidth=25., #kernel width
peaks=False #set True if peaks are neede
The function get network spike-time histogram as numpy array
rat-h /
Created May 17, 2021
Get roots of seqence
def find_roots(x,y):
Thanks to ImportanceOfBeingErnest
s = np.abs(np.diff(np.sign(y))).astype(bool)
return x[:-1][s] + np.diff(x)[s]/(np.abs(y[1:][s]/y[:-1][s])+1)
rat-h /
Last active Sep 13, 2021
Get derivative of a series
from numpy.polynomial.polynomial import polyval, polyder, polyfit
def getderiv(x,a,order=1):
b = [a[0]] + a.tolist() + [a[-1]]
y = [x[0]] + x.tolist() + [x[-1]]
return array ([
polyval(x1, polyder( polyfit([x0,x1,x2],[a0,a1,a2], order+1), order ) )
for a2,a1,a0,x2,x1,x0 in zip(b[2:],b[1:-1],b[:-2],y[2:],y[1:-1],y[:-2])
# CCS811_RPi
# Petr Lukas
# July, 11 2017
# Version 1.0
import struct, array, time, io, fcntl, logging