Skip to content

Instantly share code, notes, and snippets.

View leon-nn's full-sized avatar

leon nguyen leon-nn

View GitHub Profile
@leon-nn
leon-nn / ornsteinUhlenbeck.m
Last active November 26, 2017 08:54
Ornstein-Uhlenbeck Process
%% Ornstein-Uhlenbeck Process
% ...from the paper "FLUCTUATING SYNAPTIC CONDUCTANCES RECREATE IN
% VIVO-LIKE ACTIVITY IN NEOCORTICAL NEURONS"
% The stochastic differential equation is given by:
% dx/dt = 1/tau * (mu - x) + sqrt(D) * chi(t)
% where:
% x is the random variable
% D is the amplitude of the stochastic component
% chi(t) is a normally-distributed (zero-mean) noise source
% tau is the time constant (tau = 0 gives white noise, tau > 0 gives
@leon-nn
leon-nn / nonhomogenousPoisson.m
Last active May 13, 2017 16:25
Nonhomogenous Poisson spiking train in a spiking neural network framework
%% Non-homogenous Poisson spike train in a spiking neural network framework
% We generate inhomogenous Poisson spike trains for a set of output neurons
% in a spiking neural network. We use the "thinning" approach introduced in
% "Simulation of nonhomogeneous poisson processes by thinning" by Lewis and
% Shedler (1979).
% Number of output neurons
numOut = 10;
% Define a supremum for lambda(t). I.e., this should be the smallest upper
@leon-nn
leon-nn / mayaviRender.py
Created January 24, 2018 11:43
This demonstrates how to use Mayavi/mlab to render a mesh object in a precise pixel location within a viewport of predetermined size.
import os
os.environ["QT_API"] = "pyqt"
import numpy as np
import matplotlib.pyplot as plt
from mayavi import mlab
if __name__ == "__main__":
# Create a test 100x100 RGB image: all black and a red border. This is to demonstrate how to align the viewport.
img = np.zeros((100, 100, 3), dtype = np.uint8)
@leon-nn
leon-nn / openGLRender.py
Created January 26, 2018 20:30
This is a trivial example to demonstrate how to use modern OpenGL in Python via PyOpenGL to render offscreen to a texture buffer in a framebuffer object
from OpenGL.GL import *
from OpenGL.GLUT import *
import numpy as np
import matplotlib.pyplot as plt
# Global variables
shaderProgram = None
vertexBufferObject = None
indexBufferObject = None
framebufferObject = None