コード例 #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_wc_unit_init():
    wc = WCUnit()
    assert wc.tauNMDA == 100
    wc2 = WCUnit(tau=200, foo="bar")
    assert wc2.tau == 200
    assert wc2.foo == "bar"
    assert wc2.tauNMDA == 100
コード例 #3
0
ファイル: sensory_neuron.py プロジェクト: steeles/WC_sequence
 def __init__(self, name=None, best_frequency=440., spread=4., **kwargs):
     """
     all the same things as WCUnit, but also has a bf and selectivity
     Args:
         best_frequency (float): the frequency (in hz) that best excites the cell
         spread (float): inverse of selectivity, in terms of semitones to standard deviations
         **kwargs:
     """
     if not name:
         name = "S" + str(best_frequency) + "-" + str(spread)
     WCUnit.__init__(self, name=name, **kwargs)
     key = music.frequency_to_key(best_frequency)
     if music.key_to_frequency(key) != best_frequency:
         print(
             "warning- cell's response has been shifted to nearest semitone"
         )
     self.best_frequency = best_frequency
     self.spread = spread
     self.tuning_curve = self.fq_tuning_curve()
コード例 #4
0
ファイル: test_wc_unit.py プロジェクト: steeles/WC_sequence
def test_add_SFA_current():
    u2 = WCUnit(name="u2")
    u2.add_SFA_current(weight=.8)
    u2.r[0] = 1
    u2.currents['SFA'].update()
    assert u2.a[0] > 0
    assert u2.currents['SFA'].weight < 0
    assert u2.currents['SFA'].value > 0
    u2.update()
    assert u2.r[0] < 1
コード例 #5
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
コード例 #6
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
コード例 #7
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
コード例 #8
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
コード例 #9
0
ファイル: test_wc_unit.py プロジェクト: steeles/WC_sequence
def test_stim_current_init():
    u3 = WCUnit(name="u3")
    stim = np.ones(10)
    curr = StimCurrent(stim, .5, u3)
    assert curr.target.name == "u3"
コード例 #10
0
ファイル: test_wc_unit.py プロジェクト: steeles/WC_sequence
def test_non_default_pars():
    pars = {"foos": "bars", "gee": 42}
    u1 = WCUnit(**pars)
    assert u1.gee == 42
    u2 = WCUnit()
    assert u2.gee == .57
コード例 #11
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()