1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- # -*- coding: utf-8 -*-
- '''
- Created on 25.06.2015
- @author: frank
- '''
- def create_pulse_times(start, n, duration, period):
- return reduce(lambda a, b: a+b,
- [[start+i*period, start+i*period+duration]
- for i in range(n)])
-
- def create_pulse_gen_dict(duration=2., period=10., amplitude=1000., n=10, start=10.):
- assert period >= duration
- pulse_times = [0.,] + create_pulse_times(start, n, duration, period)
- pulse_values = [0.,] + [amplitude, 0.]*n
- return {'amplitude_times': pulse_times, 'amplitude_values': pulse_values}
- def create_burst_gen_dict(duration=2.,
- n_spikes=5,
- spike_frequency=200.,
- period=500.,
- amplitude=1000.,
- n=5, start=10.,
- start_spike_amplitude=0.,
- start_spike_time=5.,
- start_spike_duration=2.):
- spike_period = 1000./spike_frequency
- single_burst_duration = spike_period*n_spikes
- assert duration < single_burst_duration
- assert period >= single_burst_duration
-
- pulse_times = reduce(lambda a, b: a+b, [create_pulse_times(start+i*period, n_spikes, duration, spike_period)
- for i in range(n)])
- pulse_values = [amplitude, 0.]*n*n_spikes
- pulse_times.insert(0, 0.)
- pulse_values.insert(0, 0.)
- if start_spike_amplitude > 0.:
- pulse_times.insert(1, start_spike_time)
- pulse_values.insert(1, start_spike_amplitude)
- pulse_times.insert(2, start_spike_time+start_spike_duration)
- pulse_values.insert(2, 0.)
-
- return {'amplitude_times': pulse_times, 'amplitude_values': pulse_values}
- if __name__=='__main__':
- import pylab as plt
- p = create_pulse_gen_dict()
- plt.plot(p['amplitude_times'], p['amplitude_values'], '.-')
- plt.title("simple regular pulses")
-
- plt.figure()
- p = create_burst_gen_dict(duration=2., n_spikes=5, spike_frequency=100., period=100., amplitude=1000., n=5, start=50.)
- plt.plot(p['amplitude_times'], p['amplitude_values'], '.-')
- plt.title("bursts")
-
- plt.figure()
- p = create_burst_gen_dict(duration=2., n_spikes=5, spike_frequency=100., period=100., amplitude=1000., n=2, start=50.,
- start_spike_amplitude=2000.)
- plt.plot(p['amplitude_times'], p['amplitude_values'], '.-')
- plt.title("bursts, with singular initial spike")
- plt.show()
-
|