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
rat-h / compute_SPC_R2_meanFR.py
Last active Jun 3, 2021
Code for estimation R2 in a not-so-periodic network firing rate
View compute_SPC_R2_meanFR.py
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
rat-h / find_roots.py
Created May 17, 2021
Get roots of seqence
View find_roots.py
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)
@rat-h
rat-h / getderiv.py
Last active Sep 13, 2021
Get derivative of a series
View getderiv.py
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])
])
View CCS811_RPi.py
#
# CCS811_RPi
#
# Petr Lukas
# July, 11 2017
#
# Version 1.0
import struct, array, time, io, fcntl, logging