コード例 #1
0
ファイル: iaf_coupled_demo.py プロジェクト: bionet/ted.python
f = 100
bw = 2*np.pi*f
t = np.arange(0, dur, dt)

np.random.seed(0)

noise_power = None
comps = 10
if noise_power == None:
    fig_title = 'IAF Input Signal with No Noise'
else:
    fig_title = 'IAF Input Signal with %d dB of Noise' % noise_power
print fig_title
u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power, comps)
u /= max(u)
pl.plot_signal(t, u, fig_title,
               output_name + str(output_count) + output_ext)

b = 4
d = 0.75
k = 0.01

b1 = b      # bias
d1 = d      # threshold
k1 = k      # integration constant 
type1 = 1   # ON-type neuron

b2 = -b     # bias
d2 = -d     # threshold
k2 =  k     # integration constant
type2 = -1  # OFF-type neuron
コード例 #2
0
    Omega = 2*np.pi*2000
    T = 2*np.pi*M/Omega

    dt = 1e-5
    t = np.arange(0, T, dt)

    u = tp.gen_trig_poly(T, dt, M)
    am_rec = tp.get_dirichlet_coeffs(u, dt, M)

    # Try to recover the Dirichlet coefficients of the generated signal
    # using different methods. Note that this only works if u contains an
    # entire period of the signal (i.e., arange(0, T, dt)):
    print 'reconstructing signal from recovered coefficients..'
    u_rec = tp.gen_trig_poly(T, dt, am_rec)
    pl.plot_compare(t, u, u_rec, 'Signal Reconstruction',
                    output_name + str(output_count) + output_ext)
    output_count += 1

    # Create a filter:
    h = make_gammatone(t, 16, 0)
    hm = tp.get_dirichlet_coeffs(h, dt, M)
    h_rec = tp.gen_trig_poly(T, dt, hm)
    pl.plot_compare(t, h, h_rec, 'Filter Reconstruction',
                    output_name + str(output_count) + output_ext)
    output_count += 1

    # Filter the signal using FFTs:
    v_fft = filter_trig_poly_fft(u, h)
    pl.plot_signal(t, v_fft, 'Filtered Signal',
                   output_name + str(output_count) + output_ext)
コード例 #3
0
dur = 0.1
dt = 1e-6
f = 32
bw = 2 * np.pi * f
t = np.arange(0, dur, dt)

np.random.seed(0)

noise_power = None
if noise_power == None:
    fig_title = 'ASDM Input Signal with No Noise'
else:
    fig_title = 'ASDM Input Signal with %d dB of Noise' % noise_power
print fig_title
u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power)
pl.plot_signal(t, u, fig_title, output_name + str(output_count) + output_ext)

b = 3.5  # bias
d = 0.7  # threshold
k = 0.01  # scaling factor

M = 5  # number of bins for fast decoding algorithm

try:
    asdm.asdm_recoverable(u, bw, b, d, k)
except ValueError('reconstruction condition not satisfied'):
    sys.exit()

output_count += 1
fig_title = 'Signal Encoded Using ASDM Encoder'
print fig_title
コード例 #4
0
t_start = 0.02
t_end = t_start + T
if t_end > dur:
    raise ValueError('t_start is too large')
k_start = int(np.round(t_start / dt))
k_end = int(np.round(t_end / dt))
t_enc = np.arange(k_start, k_end, dtype=np.float) * dt

u_list = []
for i in xrange(M):
    fig_title_in = fig_title + ' (Signal #' + str(i + 1) + ')'
    print fig_title_in
    u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power, comps)
    u /= max(u)
    u *= 1.5
    pl.plot_signal(t_enc, u[k_start:k_end], fig_title_in,
                   output_name + str(output_count) + output_ext)
    u_list.append(u)
    output_count += 1

t = np.arange(len(u_list[0]), dtype=np.float) * dt


# Define neuron parameters:
def randu(a, b, *d):
    """Create an array of the given shape and propagate it with random
    samples from a uniform distribution over ``[a, b)``."""

    if a >= b:
        raise ValueError('b must exceed a')
    return a + (b - a) * np.random.rand(*d)
コード例 #5
0
    Omega = 2 * np.pi * 2000
    T = 2 * np.pi * M / Omega

    dt = 1e-5
    t = np.arange(0, T, dt)

    u = tp.gen_trig_poly(T, dt, M)
    am_rec = tp.get_dirichlet_coeffs(u, dt, M)

    # Try to recover the Dirichlet coefficients of the generated signal
    # using different methods. Note that this only works if u contains an
    # entire period of the signal (i.e., arange(0, T, dt)):
    print 'reconstructing signal from recovered coefficients..'
    u_rec = tp.gen_trig_poly(T, dt, am_rec)
    pl.plot_compare(t, u, u_rec, 'Signal Reconstruction',
                    output_name + str(output_count) + output_ext)
    output_count += 1

    # Create a filter:
    h = make_gammatone(t, 16, 0)
    hm = tp.get_dirichlet_coeffs(h, dt, M)
    h_rec = tp.gen_trig_poly(T, dt, hm)
    pl.plot_compare(t, h, h_rec, 'Filter Reconstruction',
                    output_name + str(output_count) + output_ext)
    output_count += 1

    # Filter the signal using FFTs:
    v_fft = filter_trig_poly_fft(u, h)
    pl.plot_signal(t, v_fft, 'Filtered Signal',
                   output_name + str(output_count) + output_ext)
コード例 #6
0
ファイル: iaf_delay_demo.py プロジェクト: bionet/ted.python
t_start = 0.02
t_end = t_start+T
if t_end > dur:
    raise ValueError('t_start is too large')
k_start = int(np.round(t_start/dt))
k_end = int(np.round(t_end/dt))
t_enc = np.arange(k_start, k_end, dtype=np.float)*dt

u_list = []
for i in xrange(M):
    fig_title_in = fig_title + ' (Signal #' + str(i+1) + ')'
    print fig_title_in
    u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power, comps)
    u /= max(u)
    u *= 1.5
    pl.plot_signal(t_enc, u[k_start:k_end], fig_title_in,
                   output_name + str(output_count) + output_ext)
    u_list.append(u)
    output_count += 1

t = np.arange(len(u_list[0]), dtype=np.float)*dt

# Define neuron parameters:
def randu(a, b, *d):
    """Create an array of the given shape and propagate it with random
    samples from a uniform distribution over ``[a, b)``."""

    if a >= b:
        raise ValueError('b must exceed a')
    return a+(b-a)*np.random.rand(*d)

b_list = list(randu(2.3, 3.3, N))
コード例 #7
0
output_dir = 'images/'

# Define algorithm parameters and input signal:
dur = 0.1
dt = 1e-6
f = 32
bw = 2 * np.pi * f
t = np.arange(0, dur, dt)

np.random.seed(0)

noise_power = None
fig_title = 'IAF input signal'
print fig_title
u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power)
pl.plot_signal(t, u, fig_title, output_dir + 'overview_input' + output_ext)

b = 3.5  # bias
d = 0.7  # threshold
R = np.inf  # resistance
C = 0.01  # capacitance

try:
    iaf.iaf_recoverable(u, bw, b, d, R, C)
except ValueError('reconstruction condition not satisfied'):
    sys.exit()

fig_title = 'Signal encoded by IAF neuron'
print fig_title
s = func_timer(iaf.iaf_encode)(u, dt, b, d, R, C)
pl.plot_encoded(t, u, s, fig_title,
コード例 #8
0
output_dir = 'images/'

# Define algorithm parameters and input signal:
dur = 0.1
dt = 1e-6
f = 32
bw = 2*np.pi*f
t = np.arange(0, dur, dt)

np.random.seed(0)

noise_power = None
fig_title = 'IAF input signal';
print fig_title
u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power)
pl.plot_signal(t, u, fig_title, output_dir + 'overview_input' + output_ext)

b = 3.5     # bias
d = 0.7     # threshold
R = np.inf  # resistance
C = 0.01    # capacitance

try:
    iaf.iaf_recoverable(u, bw, b, d, R, C)
except ValueError('reconstruction condition not satisfied'):
    sys.exit()

fig_title = 'Signal encoded by IAF neuron'
print fig_title
s = func_timer(iaf.iaf_encode)(u, dt, b, d, R, C)
pl.plot_encoded(t, u, s, fig_title,