コード例 #1
0
ファイル: test_wc_unit.py プロジェクト: steeles/WC_sequence
def test_wc_add_stim_current():
    u2 = WCUnit(name="u2")
    stim = np.ones(10)
    u2.add_stim_current(stimulus=stim, weight=.5)
    assert u2.currents["stim"].weight == .5
    u2.currents["stim"].update()
    assert u2.stim[0] == 1
コード例 #2
0
ファイル: test_wc_unit.py プロジェクト: steeles/WC_sequence
def test_update_all():
    eps = .00001
    u1 = WCUnit(name="u1", tauA=300, gSFA=0.8)
    stim = np.ones(10)
    u1.add_stim_current(stimulus=stim, weight=.9)
    for ind in xrange(10):
        u1.update_all()
    assert u1.a[0] > 0
コード例 #3
0
ファイル: test_wc_unit.py プロジェクト: steeles/WC_sequence
def test_no_negative_firing_rates_bugfix():
    # TODO: if i get rid of my f0 offset so i can have f(0)=0 this breaks
    u1 = WCUnit(name="u1", tauA=300, gSFA=0.8)
    stim = np.ones(10) * -100
    u1.add_stim_current(stimulus=stim, weight=.9)
    for ind in xrange(10):
        u1.update_all()
    assert u1.r > 0
コード例 #4
0
ファイル: test_wc_unit.py プロジェクト: steeles/WC_sequence
def test_wc_higher_weight_update():
    u2 = WCUnit(name="u2")
    stim = np.ones(10)
    u2.add_stim_current(stimulus=stim, weight=.9)
    assert u2.currents["stim"].weight == .9
    u2.currents["stim"].t = 1
    u2.currents["stim"].update()
    u2.update()
    assert u2.r[0] < 0.1
    assert u2.r[0] > 0.098
コード例 #5
0
ファイル: test_wc_unit.py プロジェクト: steeles/WC_sequence
def test_add_intrinsic_currents_SFA():
    """
    i could wind up changing the defaults; i should just check that
    the logical relationships follow
    """
    eps = .00001
    u1 = WCUnit(name="u1", tauA=300, gSFA=0.8, gee=0)
    stim = np.ones(10)
    u1.add_stim_current(stimulus=stim, weight=.9)
    for ind in xrange(10):
        u1.update_all()
    assert u1.a[0] > 0
    assert u1.currents["SFA"].value > 0

    u2 = WCUnit(tauA=30, gSFA=0.8, gee=0)
    stim = np.ones(10)
    u2.add_stim_current(stimulus=stim, weight=.9)
    for ind in xrange(10):
        u2.update_all()
    # tauA is shorter so there should be more
    assert u2.a[0] > u1.a[0]

    u3 = WCUnit(tauA=30, gSFA=0.5, gee=0)
    stim = np.ones(10)
    u3.add_stim_current(stimulus=stim, weight=.9)
    for ind in xrange(10):
        u3.update_all()
    assert abs(u3.currents["SFA"].value -\
           u2.currents["SFA"].value) < eps
    assert abs(u3.a[0] - u2.a[0]) < eps
    assert u1.r[0] - u2.r[0] > eps
    assert u3.r[0] - u2.r[0] > eps
コード例 #6
0
ファイル: wc_sim.py プロジェクト: steeles/WC_sequence
            # drive the stimulus forward
            u1.currents["stim"].set_time(self.t_i)
            for current in self.unit.currents.values():
                current.update()
            # update response
            self.unit.update()
            # update traces
            for trace in self.traces.values():
                trace.update_trace()

            self.t_i += 1


if __name__ == '__main__':
    tic = time.time()
    u1 = WCUnit(name="u1", gSFA=0.3)
    # TODO: the stimulus should get made with the same dt as sim
    triplet = aba_triplet(iti=.08)
    u1.add_stim_current(stimulus=triplet, weight=0.8)
    #u1.add_SFA_current(weight=5)

    sim = WCTripletsSimulation(wc_unit=u1, T=0.32)
    sim.run()
    traces = [[t.trace] for t in sim.traces.values()]
    #print(traces)
    # print(np.concatenate(traces))
    generic_plot(sim.tax, np.concatenate(traces))
    toc = time.time()
    print toc - tic
    plt.show()