finished figure 3
This commit is contained in:
52
regimes.py
52
regimes.py
@@ -178,8 +178,14 @@ def decibel(x):
|
||||
return 10*np.log10(x/1e8)
|
||||
|
||||
|
||||
def plot_psd(ax, s, path, contrast, spikes, nfft, dt, beatf1, beatf2):
|
||||
offs = 4
|
||||
def peak_ampl(freqs, psd, f, df=2):
|
||||
psd_snippet = psd[(freqs > f - df) & (freqs < f + df)]
|
||||
return np.max(psd_snippet)
|
||||
|
||||
|
||||
def plot_psd(ax, s, path, contrast, spikes, nfft, dt, beatf1, beatf2, eodf):
|
||||
offs = 5
|
||||
offsm = 3
|
||||
freqs, psd = compute_power(path, contrast, spikes, nfft, dt)
|
||||
psd /= freqs[1]
|
||||
ax.plot(freqs, decibel(psd), **s.lsPower)
|
||||
@@ -187,19 +193,36 @@ def plot_psd(ax, s, path, contrast, spikes, nfft, dt, beatf1, beatf2):
|
||||
label=r'$r$', clip_on=False, **s.psF0)
|
||||
ax.plot(beatf1, decibel(peak_ampl(freqs, psd, beatf1)) + offs,
|
||||
label=r'$\Delta f_1$', clip_on=False, **s.psF01)
|
||||
ax.plot(beatf2, decibel(peak_ampl(freqs, psd, beatf2)) + 2*offs + 3,
|
||||
ax.plot(beatf2, decibel(peak_ampl(freqs, psd, beatf2)) + 2*offs + 2,
|
||||
label=r'$\Delta f_2$', clip_on=False, **s.psF02)
|
||||
ax.plot(beatf2 - beatf1, decibel(peak_ampl(freqs, psd, beatf2 - beatf1)) + offs,
|
||||
label=r'$\Delta f_2 - \Delta f_1$', clip_on=False, **s.psF01_2)
|
||||
ax.plot(beatf1 + beatf2, decibel(peak_ampl(freqs, psd, beatf1 + beatf2)) + offs,
|
||||
label=r'$\Delta f_1 + \Delta f_2$', clip_on=False, **s.psF012)
|
||||
ax.set_xlim(0, 300)
|
||||
ax.plot(eodf, decibel(peak_ampl(freqs, psd, eodf)) + offs,
|
||||
label=r'$f_{EOD}$', clip_on=False, **s.psFEOD)
|
||||
ax.plot(eodf + beatf1, decibel(peak_ampl(freqs, psd, eodf + beatf1)) + offsm, label=r'$f_{EOD} \pm k \Delta f_1$', **s.psFEODm)
|
||||
ax.plot(eodf - beatf1, decibel(peak_ampl(freqs, psd, eodf - beatf1)) + offsm, **s.psFEODm)
|
||||
if contrast > 0.02:
|
||||
ax.plot(2*beatf1, decibel(peak_ampl(freqs, psd, 2*beatf1)) + offsm, label=r'$k\Delta f_1$', **s.psF01m)
|
||||
ax.plot(eodf + 2*beatf1, decibel(peak_ampl(freqs, psd, eodf + 2*beatf1)) + offsm, **s.psFEODm)
|
||||
if contrast > 0.008:
|
||||
ax.plot(eodf - beatf2, decibel(peak_ampl(freqs, psd, eodf - beatf2)) + offsm, label=r'$f_{EOD} - \Delta f_2$', **s.psF0m)
|
||||
if contrast > 0.02:
|
||||
ax.plot(eodf - beatf2 + beatf1, decibel(peak_ampl(freqs, psd, eodf - beatf2 + beatf1)) + offsm, label=r'$f_{EOD} - \Delta f_2 \pm \Delta f_1$', **s.psF02m)
|
||||
ax.plot(eodf - beatf2 - beatf1, decibel(peak_ampl(freqs, psd, eodf - beatf2 - beatf1)) + offsm, **s.psF02m)
|
||||
if contrast > 0.05:
|
||||
ax.plot(3*beatf1, decibel(peak_ampl(freqs, psd, 3*beatf1)) + offsm, **s.psF01m)
|
||||
ax.plot(4*beatf1, decibel(peak_ampl(freqs, psd, 4*beatf1)) + offsm, **s.psF01m)
|
||||
ax.plot(eodf - 2*beatf1, decibel(peak_ampl(freqs, psd, eodf - 2*beatf1)) + offsm, **s.psFEODm)
|
||||
ax.set_xlim(0, 750)
|
||||
ax.set_ylim(-60, 0)
|
||||
ax.set_xticks_delta(200)
|
||||
ax.set_xlabel('Frequency', 'Hz')
|
||||
ax.set_ylabel('Power [dB]')
|
||||
|
||||
|
||||
def plot_example(axs, axr, axp, s, path, cell, alpha, beatf1, beatf2,
|
||||
def plot_example(axs, axr, axp, s, path, cell, alpha, beatf1, beatf2, eodf,
|
||||
nfft, trials):
|
||||
dt = 0.0001
|
||||
tmax = nfft*dt
|
||||
@@ -207,13 +230,7 @@ def plot_example(axs, axr, axp, s, path, cell, alpha, beatf1, beatf2,
|
||||
spikes = punit_spikes(cell, alpha, beatf1, beatf2, tmax, trials)
|
||||
plot_am(axs, s, alpha, beatf1, beatf2, t1)
|
||||
plot_raster(axr, s, spikes, t1)
|
||||
plot_psd(axp, s, path, alpha, spikes, nfft, dt, beatf1, beatf2)
|
||||
|
||||
|
||||
def peak_ampl(freqs, psd, f):
|
||||
df = 2
|
||||
psd_snippet = psd[(freqs > f - df) & (freqs < f + df)]
|
||||
return np.max(psd_snippet)
|
||||
plot_psd(axp, s, path, alpha, spikes, nfft, dt, beatf1, beatf2, eodf)
|
||||
|
||||
|
||||
def amplitude(power):
|
||||
@@ -296,6 +313,7 @@ if __name__ == '__main__':
|
||||
|
||||
parameters = load_models(data_path / 'punitmodels.csv')
|
||||
cell = cell_parameters(parameters, model_cell)
|
||||
eodf = cell['EODf']
|
||||
nfft = 2**18
|
||||
|
||||
print(f'Loaded data for cell {model_cell}: ')
|
||||
@@ -305,20 +323,20 @@ if __name__ == '__main__':
|
||||
|
||||
s = plot_style()
|
||||
fig, (axes, axa) = plt.subplots(2, 1, height_ratios=[4, 3],
|
||||
cmsize=(s.plot_width, 0.6*s.plot_width))
|
||||
cmsize=(s.plot_width, 0.65*s.plot_width))
|
||||
fig.subplots_adjust(leftm=8, rightm=2, topm=2, bottomm=3.5, hspace=0.6)
|
||||
axe = axes.subplots(3, 4, wspace=0.4, hspace=0.2,
|
||||
height_ratios=[1, 2, 3])
|
||||
height_ratios=[1, 2, 0.6, 3])
|
||||
fig.show_spines('lb')
|
||||
|
||||
# example power spectra:
|
||||
for c, alpha in enumerate(alphas):
|
||||
path = sims_path / f'{model_cell}-contrastspectrum-{1000*alpha:03.0f}.npz'
|
||||
plot_example(axe[0, c], axe[1, c], axe[2, c], s, path,
|
||||
cell, alpha, beatf1, beatf2, nfft, 100)
|
||||
cell, alpha, beatf1, beatf2, eodf, nfft, 100)
|
||||
axe[1, 0].xscalebar(1, -0.1, 20, 'ms', ha='right')
|
||||
axe[2, 0].legend(loc='center left', bbox_to_anchor=(0, -0.8),
|
||||
ncol=5, columnspacing=2)
|
||||
axe[2, 3].legend(loc='center right', bbox_to_anchor=(1, -0.8),
|
||||
ncol=10, columnspacing=1, handletextpad=0.1)
|
||||
fig.common_yspines(axe[0, :])
|
||||
fig.common_yticks(axe[2, :])
|
||||
fig.tag(axe[0, :], xoffs=-3, yoffs=1.6)
|
||||
|
||||
Reference in New Issue
Block a user