machines.extend(local_machines) for m in local_machines: Process(target=open_server, args=(m[1],1,0)).start() equations = Equations(''' dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second ''') input = loadtxt('current.txt') spikes = loadtxt('spikes.txt') results = modelfitting( model = equations, reset = 0, threshold = 1, data = spikes, input = input, dt = .1*ms, popsize = 1000, maxiter = 5, delta = 4*ms, unit_type = 'CPU', machines = machines, R = [1.0e9, 9.0e9], tau = [10*ms, 40*ms], refractory = [0*ms, 10*ms]) print_table(results) close_servers(local_machines)
''' Model fitting example. Fit an integrate-and-fire model to an in-vitro electrophysiological recording during one second. ''' from brian import loadtxt, ms, Equations from brian.library.modelfitting import * if __name__ == '__main__': equations = Equations(''' dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second ''') input = loadtxt('current.txt') spikes = loadtxt('spikes.txt') results = modelfitting(model=equations, reset=0, threshold=1, data=spikes, input=input, dt=.1 * ms, popsize=1000, maxiter=3, delta=4 * ms, R=[1.0e9, 9.0e9], tau=[10 * ms, 40 * ms], refractory=[0 * ms, 10 * ms]) print_table(results)
G.tau = 20*ms M = SpikeMonitor(G) G.I = TimedArray(input) run(duration) i, t = zip(*M.spikes) clear(True) reinit_default_clock() return t spikes0 = getspikes() spikes = [] for i in xrange(1): spikes.extend([(i, spike + 5*i*ms) for spike in spikes0]) results = modelfitting( model = model, reset = 0, threshold = 1, data = spikes, input = input, dt = .1*ms, popsize = 150000, maxiter = 50, gpu = 1, algorithm = CMAES, delta = 1*ms, R = [1.0e9, 9.0e9], tau = [10*ms, 40*ms], delays = [-20*ms, 20*ms], refractory=[0*ms, 0*ms, 10*ms, 10*ms]) print_table(results)
if __name__ == '__main__': model = Equations(''' dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second ''') input = loadtxt('examples/modelfitting/current.txt') spikes0 = loadtxt('examples/modelfitting/spikes.txt') spikes = [] for i in xrange(2): spikes.extend([(i, spike * second + 5 * i * ms) for spike in spikes0]) results = modelfitting(model=model, reset=0, threshold=1, data=spikes, input=input, dt=.1 * ms, popsize=1000, maxiter=3, cpu=1, delta=4 * ms, R=[1.0e9, 9.0e9], tau=[10 * ms, 40 * ms], delays=[-10 * ms, 10 * ms]) print_table(results)
if __name__ == '__main__': model = Equations(''' dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second ''') input = loadtxt('current.txt') spikes0 = loadtxt('spikes.txt') spikes = [] for i in xrange(2): spikes.extend([(i, spike*second + 5*i*ms) for spike in spikes0]) results = modelfitting( model = model, reset = 0, threshold = 1, data = spikes, input = input, dt = .1*ms, popsize = 1000, maxiter = 3, cpu = 1, delta = 4*ms, R = [1.0e9, 9.0e9], tau = [10*ms, 40*ms], delays = [-10*ms, 10*ms]) print_table(results)