Skip to content

Instantly share code, notes, and snippets.

View apleonhardt's full-sized avatar

Aljoscha Leonhardt apleonhardt

  • MPI for Neurobiology
  • Munich
View GitHub Profile
def decorated(func):
def r_func(*args, **kwargs):
print "Decorated call."
return func(*args, **kwargs)
return r_func
@decorated
def double(x):
@apleonhardt
apleonhardt / hh_aljoscha_cns.py
Created December 7, 2011 23:40
Hodgkin-Huxley
# Implementation of Hodgkin-Huxley model
# v2
import matplotlib.pyplot as plt
from numpy import *
from scipy import *
# Spike counting
@apleonhardt
apleonhardt / gist:2758913
Created May 20, 2012 17:52
Spike-triggered average implementation
function sta = spike_triggered_avg(spikes, stimulus, winlen)
slices = arrayfun(@(x) stimulus(x-winlen:x-1), ...
find(spikes(winlen:end)) + winlen, ...
'UniformOutput', 0);
sta = mean(cat(2, slices{:}), 2);
end
@apleonhardt
apleonhardt / part1.m
Created May 23, 2012 13:40
Exercise 4 (I+II)
%% EXERCISE 4 -- PART I: Firing rate estimation
clear all;
%% Parameters
rate = 40; % in Hz
dt = 0.001; % Time step in s
duration = 5; % in s
% NB, these are VERY wide kernels
@apleonhardt
apleonhardt / part1.m
Created May 28, 2012 15:30
Exercise 5 (I+II)
% EXERCISE SET 5 -- Part I
close all;
clear all;
%% Parameters
dt = 0.001; % s
dur = 1; % s
t = 0:dt:dur;
@apleonhardt
apleonhardt / generate_stimulus.m
Created December 10, 2012 15:16
TM2 simulation (MATLABified^2)
function [output] = generate_stimulus(stimulus_type)
n_spatial = 180;
timesteps = 5000;
precision = 6000;
output = zeros(n_spatial, timesteps);
switch stimulus_type
@apleonhardt
apleonhardt / powerspec.matlab
Created December 13, 2012 13:58
Power spectrum demo
%% Power spectrum demo
clear all;
dt = 0.01;
% Ten seconds at dt=0.01
t = 0:dt:10;
% Frequencies to be included in the signal. NB: Due
% Apply filter
for idx = 1:m-1
temp_signal = conv(s(:,idx), k);
f(:,idx) = highpass(s(:,idx), tau, dt) + temp_signal;
end
% Add DC
f = f + dc * s;
% ...
% Start a new session:
g = gnode.init('/path/to/configuration.json');
gnode.status(g);
gnode.shutdown(g);
gfsdafgdsafdsafdsa