test labrotation freq phenomenon
This commit is contained in:
parent
5af4117d4c
commit
3c06be9917
65
test.py
65
test.py
@ -22,29 +22,42 @@ from matplotlib import gridspec
|
|||||||
from plottools.axes import labelaxes_params
|
from plottools.axes import labelaxes_params
|
||||||
|
|
||||||
|
|
||||||
def demo():
|
|
||||||
""" Run a demonstration of the axes module.
|
|
||||||
"""
|
|
||||||
|
# sp = self.spikes(index)
|
||||||
def afigure():
|
# binary = np.zeros(t.shape)
|
||||||
fig = plt.figure()
|
# spike_indices = ((sp - t[0]) / dt).astype(int)
|
||||||
gs = gridspec.GridSpec(2, 3, width_ratios=[5, 1.5, 2.4])
|
# binary[spike_indices[(spike_indices >= 0) & (spike_indices < len(binary))]] = 1
|
||||||
gs.update(left=0.075, bottom=0.14, right=0.985, top=0.9, wspace=0.6, hspace=0.6)
|
# g = gaussian_kernel(kernel_width, dt)
|
||||||
ax1 = fig.add_subplot(gs[:, 0])
|
# rate = np.convolve(binary, g, mode='same')
|
||||||
ax2 = fig.add_subplot(gs[0, 1:])
|
|
||||||
ax3 = fig.add_subplot(gs[1, 1])
|
fit = ModelFit("results/final_2/2012-07-12-ag-invivo-1/start_parameter_4_err_6.11/")
|
||||||
ax4 = fig.add_subplot(gs[1, 2])
|
model = fit.get_model()
|
||||||
for ax in [ax1, ax2, ax3, ax4]:
|
|
||||||
ax.set_xlabel('xlabel')
|
base_stim = SinusoidalStepStimulus(fit.get_cell_data().get_eod_frequency(), 0, 0)
|
||||||
ax.set_ylabel('ylabel')
|
time_list = []
|
||||||
return fig, (ax1, ax2, ax3, ax4)
|
freq_list = []
|
||||||
|
con_freq_list = []
|
||||||
labelaxes_params(xoffs='auto', yoffs=-1, labels='A', font=dict(fontweight='bold'))
|
duration = 10
|
||||||
|
step = model.get_sampling_interval()
|
||||||
fig, axs = afigure()
|
g = gaussian_kernel(0.005, step)
|
||||||
# axs[0].text(0.5, 0.5, 'fig.label_axes()', transform=axs[0].transAxes, ha='center')
|
for i in range(20):
|
||||||
# axs[0].text(0.0, 0.0, 'X', transform=fig.transFigure, ha='left', va='bottom')
|
print(i)
|
||||||
fig.label_axes()
|
v1, spikes = model.simulate(base_stim, duration)
|
||||||
plt.show()
|
|
||||||
|
binary = np.zeros(int(np.rint(duration / step)))
|
||||||
demo()
|
for s in spikes:
|
||||||
|
binary[int(np.rint(s/step))] = 1
|
||||||
|
rate = np.convolve(binary, g, mode='same')
|
||||||
|
con_freq_list.append(rate)
|
||||||
|
|
||||||
|
time, freq = hF.calculate_time_and_frequency_trace(spikes, model.get_sampling_interval())
|
||||||
|
time_list.append(time)
|
||||||
|
freq_list.append(freq)
|
||||||
|
rates = np.array(con_freq_list)
|
||||||
|
mean_rate = np.mean(rates, axis=0)
|
||||||
|
mean_time, mean_freq = hF.calculate_mean_of_frequency_traces(time_list, freq_list, model.get_sampling_interval())
|
||||||
|
plt.plot(np.arange(0, 10, step), mean_rate, alpha=0.5)
|
||||||
|
plt.plot(mean_time, mean_freq, alpha=0.5)
|
||||||
|
plt.show()
|
Loading…
Reference in New Issue
Block a user