def autocor(PSTH,N=None,T=20*br.ms,bin=None): if bin is None: bin = br.defaultclock.dt p = int(T/ bin) SAC = br.zeros(p) if N is None: SAC[0] = br.mean(PSTH * PSTH) else: # correction to exclude self-coincidences PSTHnoself = br.clip(PSTH - 1. / (bin * N), 0*br.kHz, br.Inf*br.kHz) SAC[0] = br.mean(PSTH * PSTHnoself) * N / (N - 1.) SAC[1:] = [br.mean(PSTH[:-i] * PSTH[i:]) for i in range(1,p)] SAC = br.hstack((SAC[::-1], SAC[1:])) out = (br.arange(len(SAC)) - len(SAC) / 2) * bin return out, SAC
def visualise_connectivity(S): Ns = len(S.source) Nt = len(S.target) b.figure(figsize=(10, 4)) b.subplot(121) b.plot(b.zeros(Ns), b.arange(Ns), 'ok', ms=10) b.plot(b.ones(Nt), b.arange(Nt), 'ok', ms=10) for i, j in zip(S.i, S.j): b.plot([0, 1], [i, j], '-k') b.xticks([0, 1], ['Source', 'Target']) b.ylabel('Neuron index') b.xlim(-0.1, 1.1) b.ylim(-1, max(Ns, Nt)) b.subplot(122) b.plot(S.i, S.j, 'ok') b.xlim(-1, Ns) b.ylim(-1, Nt) b.xlabel('Source neuron index') b.ylabel('Target neuron index')
import lmfit except ImportError: lmfit = None from numpy.testing import assert_equal, assert_almost_equal from brian2 import (zeros, Equations, NeuronGroup, StateMonitor, TimedArray, nS, mV, volt, ms, pA, pF, Quantity, set_device, get_device, Network, have_same_dimensions, DimensionMismatchError) from brian2.equations.equations import DIFFERENTIAL_EQUATION, SUBEXPRESSION from brian2modelfitting import (NevergradOptimizer, TraceFitter, MSEMetric, OnlineTraceFitter, Simulator, Metric, Optimizer, GammaFactor) from brian2.devices.device import reinit_devices, reset_device from brian2modelfitting.fitter import get_param_dic E = 40 * mV input_traces = zeros((10, 5)) * volt for i in range(5): input_traces[5:, i] = i * 10 * mV output_traces = 10 * nS * input_traces model = Equations(''' I = g*(v-E) : amp g : siemens (constant) ''') strmodel = ''' I = g*(v-E) : amp g : siemens (constant) '''