Beispiel #1
0
    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
s = func_timer(asdm.asdm_encode)(u, dt, b, d, k)
pl.plot_encoded(t, u, s, fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using ASDM Decoder'
print fig_title
u_rec = func_timer(asdm.asdm_decode)(s, dur, dt, bw, b, d, k)
pl.plot_compare(t, u, u_rec, fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Threshold-Insensitive ASDM Decoder'
print fig_title
u_rec_ins = func_timer(asdm.asdm_decode_ins)(s, dur, dt, bw, b)
pl.plot_compare(t, u, u_rec_ins, fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Decoded Using Fast ASDM Decoder'
print fig_title
u_rec = func_timer(asdm.asdm_decode_fast)(s, dur, dt, bw, M, b, d, k)
pl.plot_compare(t, u, u_rec, fig_title,
                output_name + str(output_count) + output_ext)
Beispiel #2
0
a = 1.0/0.015
c = 1.0/3.0
h_list = [[0,0],[0,0]]
h_list[0][0] = lambda t : 0
h_list[0][1] = lambda t : -c*np.exp(-a*t)*((a*t)**5/120.0-(a*t)**7/5040.0)*(t>=0)
h_list[1][0] = lambda t : c*np.exp(-a*t)*((a*t)**5/120.0-(a*t)**7/5040.0)*(t>=0)
h_list[1][1] = lambda t : 0

fig_title = 'Signal Encoded Using Coupled IAF Encoder'
print fig_title
s_list = func_timer(iaf.iaf_encode_coupled)(u, dt, [b1, b2], [d1, d2],
                                               [k1, k2], h_list, [type1, type2])
output_count += 1
pl.plot_encoded(t, u, s_list[0], fig_title + ' #1',
                output_name + str(output_count) + output_ext)
output_count += 1
pl.plot_encoded(t, u, s_list[1], fig_title + ' #2',
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Coupled IAF Decoder'
print fig_title
u_rec = func_timer(iaf.iaf_decode_coupled)(s_list, dur, dt, 
                                              [b1, b2], [d1, d2], [k1, k2],
                                              h_list)
pl.plot_compare(t, u, u_rec, fig_title,
                output_name + str(output_count) + output_ext)


w_list = map(list, np.reshape(randu(0.5, 1.0, N * M), (N, M)))

T_block = T / 2.0
T_overlap = T_block / 3.0
fig_title = 'Signal Encoded Using Real-Time Delayed IAF Encoder'
print fig_title
s_list = func_timer(rt.iaf_encode_delay)(u_list, T_block, t_start, dt, b_list,
                                         d_list, k_list, a_list, w_list)

for i in xrange(M):
    for j in xrange(N):
        fig_title_out = fig_title + '\n(Signal #' + str(i+1) + \
                        ', Neuron #' + str(j+1) + ')'
        pl.plot_encoded(t_enc, u_list[i][k_start:k_end],
                        s_list[j][np.cumsum(s_list[j]) < T], fig_title_out,
                        output_name + str(output_count) + output_ext)
        output_count += 1

fig_title = 'Signal Decoded Using Real-Time Delayed IAF Decoder'
print fig_title
u_rec_list = func_timer(rt.iaf_decode_delay)(s_list, T_block, T_overlap, dt,
                                             b_list, d_list, k_list, a_list,
                                             w_list)

for i in xrange(M):
    fig_title_out = fig_title + ' (Signal #' + str(i + 1) + ')'
    pl.plot_compare(t_enc, u_list[i][k_start:k_end],
                    u_rec_list[i][0:k_end - k_start], fig_title_out,
                    output_name + str(output_count) + output_ext)
    output_count += 1
    M = 250
    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)
Beispiel #5
0
    asdm.asdm_recoverable(u, bw, b, d, k)
except ValueError('reconstruction condition not satisfied'):
    sys.exit()

output_count += 1
fig_title = 'Signal Encoded Using Real-Time ASDM Encoder'
print fig_title
encoder = rt.ASDMRealTimeEncoder(dt, b, d, k)
s = func_timer(encoder)(u)
pl.plot_encoded(t, u, s, fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Real-Time ASDM Decoder'
print fig_title
decoder = rt.ASDMRealTimeDecoder(dt, bw, b, d, k, N, M, K)
u_rec = func_timer(decoder)(s)
end = min(len(u), len(u_rec))
pl.plot_compare(t[:end], u[:end], u_rec[:end], fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Real-Time\nThreshold-Insensitive ASDM Decoder'
print fig_title
decoder = rt.ASDMRealTimeDecoderIns(dt, bw, b, N, M, K)
u_rec_ins = func_timer(decoder)(s)
end = min(len(u), len(u_rec_ins))
pl.plot_compare(t[:end], u[:end], u_rec_ins[:end], fig_title,
                output_name + str(output_count) + output_ext)

Beispiel #6
0
    M = 250
    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)
Beispiel #7
0
a_list = map(list, np.reshape(np.random.exponential(0.003, N*M), (N, M)))
w_list = map(list, np.reshape(randu(0.5, 1.0, N*M), (N, M)))

fig_title = 'Signal Encoded Using Delayed IAF Encoder'
print fig_title
s_list = func_timer(iaf.iaf_encode_delay)(u_list, t_start, dt, b_list, d_list,
                                          k_list, a_list, w_list)

for i in xrange(M):
    for j in xrange(N):
        fig_title_out = fig_title + '\n(Signal #' + str(i+1) + \
                        ', Neuron #' + str(j+1) + ')'
        pl.plot_encoded(t_enc, u_list[i][k_start:k_end],
                        s_list[j][np.cumsum(s_list[j])<T],
                        fig_title_out,
                        output_name + str(output_count) + output_ext)
        output_count += 1
    
fig_title = 'Signal Decoded Using Delayed IAF Decoder'
print fig_title
u_rec_list = func_timer(iaf.iaf_decode_delay)(s_list, T, dt,
                                              b_list, d_list, k_list,
                                              a_list, w_list)

for i in xrange(M):
    fig_title_out = fig_title + ' (Signal #' + str(i+1) + ')'
    pl.plot_compare(t_enc, u_list[i][k_start:k_end],
                    u_rec_list[i][0:k_end-k_start], fig_title_out, 
                    output_name + str(output_count) + output_ext)
    output_count += 1
Beispiel #8
0
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,
                output_dir + 'overview_encoded' + output_ext)

fig_title = 'Decoded signal and reconstruction error'
print fig_title
u_rec = func_timer(iaf.iaf_decode)(s, dur, dt, bw, b, d, R, C)
pl.plot_compare(t, u, u_rec, fig_title,
                output_dir + 'overview_decoded' + output_ext)
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,
                output_dir + 'overview_encoded' + output_ext)

fig_title = 'Decoded signal and reconstruction error'
print fig_title
u_rec = func_timer(iaf.iaf_decode)(s, dur, dt, bw, b, d, R, C)
pl.plot_compare(t, u, u_rec, fig_title,
                output_dir + 'overview_decoded' + output_ext)