# List of machines external IP addresses machines = [] local_machines = [('localhost', 2718+i) for i in xrange(nlocal)] 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])
Example showing how to fit a single model with different target spike trains (several groups). ''' from brian import loadtxt, ms, Equations, second from brian.library.modelfitting import * 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,
''' 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)
return criterion_values if __name__ == '__main__': from brian import loadtxt, ms, savetxt, loadtxt, Equations, NeuronGroup, run, SpikeMonitor,\ StateMonitor, Network from pylab import * equations = Equations(''' dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second ''') input = loadtxt('current.txt') trace = loadtxt('trace_artificial.txt') spikes = loadtxt('spikes_artificial.txt') # GAMMA FACTOR criterion = GammaFactor(delta=2 * ms) data = spikes # data[:,1] += 50*ms # LP ERROR criterion = LpError(p=2, varname='V') data = trace # SIMULATE, EVALUATE CRITERION AND RECORD TRACES ON GPU neurons = 5
g.I = TimedArray(input, dt=.1*ms) g.tau = 25*ms g.R = 3e9 SpM = SpikeMonitor(g) StM = StateMonitor(g, 'V', record=True) net = Network(g, SpM, StM) net.run(1*second) return StM.values[0], SpM.spikes equations = Equations(''' dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second ''') input = loadtxt('current.txt') # ARTIFICIAL DATA: R=3e9, tau=25*ms # spikes = loadtxt('spikes.txt') # real data # trace, spikes = generate_data() # savetxt('trace_artificial.txt', trace) # savetxt('spikes_artificial.txt', spikes) trace = loadtxt('trace_artificial.txt') spikes= loadtxt('spikes_artificial.txt') # GAMMA FACTOR criterion = GammaFactor(delta=2*ms) data = spikes # data[:,1] += 50*ms
SpM = SpikeMonitor(g) StM = StateMonitor(g, "V", record=True) net = Network(g, SpM, StM) net.run(1 * second) return StM.values[0], SpM.spikes equations = Equations( """ dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second #tau_metric : second """ ) input = loadtxt("current.txt") # ARTIFICIAL DATA: R=3e9, tau=25*ms # spikes = loadtxt('spikes.txt') # real data trace, spikes = generate_data() # savetxt('trace_artificial.txt', trace) # savetxt('spikes_artificial.txt', spikes) # trace = loadtxt('trace_artificial.txt') overlap = 10 * ms slices = 1 dt = 0.1 * ms input, trace = slice_trace(input, trace, slices=slices, dt=dt, overlap=overlap) # GAMMA FACTOR # criterion = GammaFactor(delta=2*ms)
g.tau = 25 * ms g.R = 3e9 SpM = SpikeMonitor(g) StM = StateMonitor(g, 'V', record=True) net = Network(g, SpM, StM) net.run(1 * second) return StM.values[0], SpM.spikes equations = Equations(''' dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second #tau_metric : second ''') input = loadtxt('current.txt') # ARTIFICIAL DATA: R=3e9, tau=25*ms # spikes = loadtxt('spikes.txt') # real data trace, spikes = generate_data() # savetxt('trace_artificial.txt', trace) # savetxt('spikes_artificial.txt', spikes) # trace = loadtxt('trace_artificial.txt') overlap = 10 * ms slices = 1 dt = .1 * ms input, trace = slice_trace(input, trace, slices=slices, dt=dt,
if __name__ == "__main__": from brian import loadtxt, ms, savetxt, loadtxt, Equations, NeuronGroup, run, SpikeMonitor, StateMonitor, Network from pylab import * equations = Equations( """ dV/dt=(R*I-V)/tau : 1 I : 1 R : 1 tau : second """ ) input = loadtxt("current.txt") trace = loadtxt("trace_artificial.txt") spikes = loadtxt("spikes_artificial.txt") # GAMMA FACTOR criterion = GammaFactor(delta=2 * ms) data = spikes # data[:,1] += 50*ms # LP ERROR criterion = LpError(p=2, varname="V") data = trace # SIMULATE, EVALUATE CRITERION AND RECORD TRACES ON GPU neurons = 5