This file contains 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
# | |
# CCS811_RPi | |
# | |
# Petr Lukas | |
# July, 11 2017 | |
# | |
# Version 1.0 | |
import struct, array, time, io, fcntl, logging |
This file contains 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
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]) | |
]) |
This file contains 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 find_roots(x,y): | |
''' | |
Thanks to ImportanceOfBeingErnest | |
https://stackoverflow.com/a/46911822/1887559 | |
''' | |
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) |
This file contains 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
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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.