updating plots

This commit is contained in:
saschuta 2024-04-26 16:36:08 +02:00
parent 5a1e2fb120
commit ebae62cdae
20 changed files with 418 additions and 149 deletions

0
__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -47,9 +47,9 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
cells_all = [good_data[0]] cells_all = [good_data[0]]
plot_style() plot_style()
default_figsize(column=2, length=3.1) #.254.75 0.75 default_figsize(column=2, length=2.9) #.254.75 0.75# bottom=0.07, top=0.94,
grid = gridspec.GridSpec(2, 5, wspace=0.95, bottom=0.09, grid = gridspec.GridSpec(2, 5, wspace=0.95, bottom=0.13, hspace=0.40, top=0.88,
hspace=0.25, width_ratios = [2,0,2,2,2], left=0.09, right=0.93, top=0.9) width_ratios = [2,0,2,2,2], left=0.09, right=0.93, )#bottom=0.09, hspace=0.25, top=0.9,
a = 0 a = 0
maxs = [] maxs = []
@ -206,6 +206,7 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
stack = load_model_susept(path, cells_save, save_name.split(r'/')[-1] + cell_add) stack = load_model_susept(path, cells_save, save_name.split(r'/')[-1] + cell_add)
embed()
if len(stack)> 0: if len(stack)> 0:
add_nonlin_title, cbar, fig, stack_plot, im = plt_single_square_modl(ax_external, cell, stack, perc, titles[s], add_nonlin_title, cbar, fig, stack_plot, im = plt_single_square_modl(ax_external, cell, stack, perc, titles[s],
width, eod_metrice = eod_metrice, titles_plot=True, width, eod_metrice = eod_metrice, titles_plot=True,
@ -253,7 +254,7 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
ax_ams = [] ax_ams = []
for g, grid_here in enumerate([grid[0, 2], grid[1, 2]]):#, grid[2, 0] for g, grid_here in enumerate([grid[0, 2], grid[1, 2]]):#, grid[2, 0]
grid_lowpass = gridspec.GridSpecFromSubplotSpec(4, 1, grid_lowpass = gridspec.GridSpecFromSubplotSpec(4, 1,
subplot_spec=grid_here, hspace=0.3, subplot_spec=grid_here, hspace=0.2,
height_ratios=[1, 1,1, 0.1]) height_ratios=[1, 1,1, 0.1])
models = resave_small_files("models_big_fit_d_right.csv", load_folder='calc_model_core') models = resave_small_files("models_big_fit_d_right.csv", load_folder='calc_model_core')

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 96 KiB

View File

@ -4,8 +4,8 @@ def model_full(c1=10, mult_type='_multsorted2_', devs=['05'], end='all', chose_s
detections=['MeanTrialsIndexPhaseSort'], sorted_on='LocalReconst0.2NormAm', dfs = ['m1', 'm2']): detections=['MeanTrialsIndexPhaseSort'], sorted_on='LocalReconst0.2NormAm', dfs = ['m1', 'm2']):
plot_style() plot_style()
default_figsize(column=2, length=2.3) default_figsize(column=2, length=2.7)
grid = gridspec.GridSpec(1, 4, wspace=0.15, bottom = 0.2, width_ratios = [2,1, 1.5,1.5], hspace=0.15, top=0.92, left=0.075, right=0.98) grid = gridspec.GridSpec(1, 4, wspace=0.15, bottom = 0.2, width_ratios = [3,1, 1.5,1.5], hspace=0.15, top=0.85, left=0.075, right=0.98)
axes = [] axes = []
################################## ##################################
@ -18,7 +18,7 @@ def model_full(c1=10, mult_type='_multsorted2_', devs=['05'], end='all', chose_s
cell = '2012-07-03-ak-invivo-1' cell = '2012-07-03-ak-invivo-1'
perc,im,stack_final = plt_model_big(ax, ls = ls, lw = 0.75, cell = cell) perc, im, stack_final, stack_saved = plt_model_big(ax, ls = ls, lw = 0.75, cell = cell, lines = True)
fr_waves = 139 fr_waves = 139
fr_noise = 120 fr_noise = 120
f1 = 33 f1 = 33
@ -80,9 +80,9 @@ def model_full(c1=10, mult_type='_multsorted2_', devs=['05'], end='all', chose_s
################# #################
# power spectra data # power spectra data
log = 'log'#'log'#'log'#'log' log = ''#'log'#'log'#'log'#'log'
ylim_log = (-14.2, 3)#(-14.2, 3) ylim_log = (-14.2, 3)#(-14.2, 3)
nfft = 2 ** 13 nfft = 20000#2 ** 13
xlim_psd = [0, 300] xlim_psd = [0, 300]
DF1_desired_orig = [133, 166]#33 DF1_desired_orig = [133, 166]#33
@ -116,11 +116,11 @@ def model_full(c1=10, mult_type='_multsorted2_', devs=['05'], end='all', chose_s
else: else:
markers = ['o', 'o', 'o', 'o', ] markers = ['o', 'o', 'o', 'o', ]
DF1_frmult = [0.28, 1.28, 1, 1] DF1_frmult = [0.28, 0.28, 1, 1]
DF2_frmult = [1-0.28, 0.28, 0.28, 0.48] # 1.06949369 DF2_frmult = [1-0.28, 1.28, 0.28, 1.28] # 1.06949369
grid0 = gridspec.GridSpecFromSubplotSpec(2, 2, wspace=0.15, hspace=0.35, grid0 = gridspec.GridSpecFromSubplotSpec(2, 2, wspace=0.15, hspace=0.4,
subplot_spec=grid[2:3]) subplot_spec=grid[2::])
################# #################
################# #################
@ -137,7 +137,7 @@ def model_full(c1=10, mult_type='_multsorted2_', devs=['05'], end='all', chose_s
#DF1_frmult[1] = 0.4 #DF1_frmult[1] = 0.4
#DF2_frmult[1] = 0.6 #DF2_frmult[1] = 0.6
#ylim_log = (-25.2, 3) #ylim_log = (-25.2, 3)
ylim_log = (-10, 3) # ylim_log = (-20, 5) #
######################### #########################
# punkte die zur zweiten Reihe gehören # punkte die zur zweiten Reihe gehören
@ -163,21 +163,23 @@ def model_full(c1=10, mult_type='_multsorted2_', devs=['05'], end='all', chose_s
way = '' # 'mult'#'absolut' way = '' # 'mult'#'absolut'
ways = ['mult_minimum_1', 'absolut', 'mult_env_3', 'mult_f1_3', 'mult_f2_3', 'mult_minimum_3', 'mult_env_1', ways = ['mult_minimum_1', 'absolut', 'mult_env_3', 'mult_f1_3', 'mult_f2_3', 'mult_minimum_3', 'mult_env_1',
'mult_f1_1', 'mult_f2_1', ] 'mult_f1_1', 'mult_f2_1', ]
length = 2 # 5 length = 2*40 # 5
reshuffled = '' # , reshuffled = '' # ,
alphas = [1,0.5] alphas = [1,0.5]
a_size = 0.0125#25#0.04#0.015 a_size = 0.0125#25#0.04#0.015
a_size = 0.0085#125
# ATTENTION: Diese Zelle ('2012-07-03-ak-invivo-1') braucht längere Abschnitte, mindsetesn 5 Sekunden damit das Powerspectrum nicht so niosy ist! # ATTENTION: Diese Zelle ('2012-07-03-ak-invivo-1') braucht längere Abschnitte, mindsetesn 5 Sekunden damit das Powerspectrum nicht so niosy ist!
#embed()dev_spikes='original', #embed()dev_spikes='original',
fr, eod_fr_m = plt_model_full_model2(grid0, reshuffled=reshuffled, dev=0.0005, a_f1s=[a_size], af_2 = a_size, #embed()#stack_final
stimulus_length=length, plus_q=plus_q, fr_noise, eod_fr_mm, axes2 = plt_model_full_model2(grid0, stack_final = stack_final , reshuffled=reshuffled, dev=0.0005, a_f1s=[a_size], af_2 = a_size,
stimulus_length=length, plus_q=plus_q, stack_saved = stack_saved,
diagonal=diagonal, runs=1, nfft = nfft, xlim_psd = xlim_psd, ylim_log = ylim_log, diagonal=diagonal, runs=1, nfft = nfft, xlim_psd = xlim_psd, ylim_log = ylim_log,
cells=[cell], dev_spikes = '05', markers = markers, DF1_frmult = DF1_frmult, DF2_frmult = DF2_frmult, cells=[cell], dev_spikes = '05', markers = markers, DF1_frmult = DF1_frmult, DF2_frmult = DF2_frmult,
log = log, ms = ms, clip_on = True) #arrays_len a_f1s=[0.02]"2012-12-13-an-invivo-1"'2013-01-08-aa-invivo-1' log = log, ms = ms, clip_on = True, array_len = [1,1,1,1,1]) #arrays_len a_f1s=[0.02]"2012-12-13-an-invivo-1"'2013-01-08-aa-invivo-1'
@ -203,17 +205,25 @@ def model_full(c1=10, mult_type='_multsorted2_', devs=['05'], end='all', chose_s
markerfacecolor="None")#, alpha = alphas[f] markerfacecolor="None")#, alpha = alphas[f]
else: else:
#embed() #embed()
for f in range(len(DF1_frmult)): letters_plot = True
ax.plot((fr_noise*DF1_frmult[f]), (fr_noise*DF2_frmult[f]-1), markers[f], ms=5, markeredgecolor=color012, if letters_plot:
markerfacecolor="None")#, alpha = alphas[f] letters = ['B', 'C', 'D', 'E']
ax.plot(-(fr_noise*DF1_frmult[f]-1), (fr_noise*DF2_frmult[f]-1), markers[f], ms=5, markeredgecolor=color01_2, for f in range(len(DF1_frmult)):
markerfacecolor="None")#, alpha = alphas[f] ax.text((fr_noise*DF1_frmult[f]), (fr_noise*DF2_frmult[f]-1), letters[f], color = color012, ha = 'center', va = 'center')#, alpha = alphas[f]
ax.text(-(fr_noise*DF1_frmult[f]-1), (fr_noise*DF2_frmult[f]-1), letters[f], color = color01_2, ha = 'center', va = 'center')#, alpha = alphas[f]
else:
for f in range(len(DF1_frmult)):
ax.plot((fr_noise*DF1_frmult[f]), (fr_noise*DF2_frmult[f]-1), markers[f], ms=5, markeredgecolor=color012,
markerfacecolor="None")#, alpha = alphas[f]
ax.plot(-(fr_noise*DF1_frmult[f]-1), (fr_noise*DF2_frmult[f]-1), markers[f], ms=5, markeredgecolor=color01_2,
markerfacecolor="None")#, alpha = alphas[f]
#embed() #embed()
#tag2(fig=fig, xoffs=[-4.5, -4.5, -4.5, -5.5], yoffs=1.25) #tag2(fig=fig, xoffs=[-4.5, -4.5, -4.5, -5.5], yoffs=1.25)
#axes = plt.gca() #axes = plt.gca()
fig = plt.gcf()#[axes[0], axes[3], axes[4]] fig = plt.gcf()#[axes[0], axes[3], axes[4]]
fig.tag(axes, xoffs=-4.5, yoffs=1.4) # ax_ams[3], fig.tag([axes[0], axes2[0], axes2[1], axes2[2], axes2[3]], xoffs=-4.5, yoffs=1.2) # ax_ams[3],
save_visualization() save_visualization()
@ -401,6 +411,7 @@ def plt_model_full_model(axp, min=0.2, cells=[], a_f2 = 0.1, perc = 0.05, alpha
noverlap=nfft // 2) noverlap=nfft // 2)
if log: if log:
pp_mean = 10 * np.log10(pp_mean / np.max(pp_mean)) pp_mean = 10 * np.log10(pp_mean / np.max(pp_mean))
print(freqs_beat) print(freqs_beat)
print(labels) print(labels)
plt_peaks_several(freqs_beat, pp_mean, axp, pp_mean, f, labels, 0, colors, ha='center', plt_peaks_several(freqs_beat, pp_mean, axp, pp_mean, f, labels, 0, colors, ha='center',
@ -425,8 +436,8 @@ def plt_model_full_model(axp, min=0.2, cells=[], a_f2 = 0.1, perc = 0.05, alpha
return fr return fr
def plt_model_full_model2(grid0, reshuffled='reshuffled', af_2 = 0.1, dev=0.0005, a_f1s=[0.03], def plt_model_full_model2(grid0, reshuffled='reshuffled', af_2 = 0.1, dev=0.0005, a_f1s=[0.03],
printing=False, plus_q='minus', diagonal='diagonal', printing=False, plus_q='minus', diagonal='diagonal', stack_final = [],
stimulus_length=0.5, runs=1, cells=[], stimulus_length=0.5, runs=1, cells=[], stack_saved = [],
nfft=int(4096), beat='', nfft_for_morph=4096 * 4, gain=1, nfft=int(4096), beat='', nfft_for_morph=4096 * 4, gain=1,
DF2_frmult = [], DF1_frmult = [], DF2_frmult = [], DF1_frmult = [],
array_len = [20,20,20,20,20], array_len = [20,20,20,20,20],
@ -448,6 +459,7 @@ def plt_model_full_model2(grid0, reshuffled='reshuffled', af_2 = 0.1, dev=0.0005
freq1_ratio = DF1_frmult[g] freq1_ratio = DF1_frmult[g]
#embed() #embed()
ax = plt.subplot(grid0[g]) ax = plt.subplot(grid0[g])
axes.append(ax) axes.append(ax)
try: try:
trials_nr = array_len[g] trials_nr = array_len[g]
@ -470,6 +482,7 @@ def plt_model_full_model2(grid0, reshuffled='reshuffled', af_2 = 0.1, dev=0.0005
titles_amp = ['base eodf'] # ,'baseline to Zero',] titles_amp = ['base eodf'] # ,'baseline to Zero',]
for a, a_fr in enumerate(a_frs): for a, a_fr in enumerate(a_frs):
#embed()
model_params = model_cells[model_cells['cell'] == cell_here].iloc[0] model_params = model_cells[model_cells['cell'] == cell_here].iloc[0]
# model_params = model_cells.iloc[cell_nr] # model_params = model_cells.iloc[cell_nr]
@ -506,22 +519,19 @@ def plt_model_full_model2(grid0, reshuffled='reshuffled', af_2 = 0.1, dev=0.0005
# baseline_after,spikes_base,rate_adapted, rate_baseline_before, rate_baseline_after, np.array(spike_times), stimulus_power, v_dent_output[int(0.05 / deltat):-1], offset, v_mem_output # baseline_after,spikes_base,rate_adapted, rate_baseline_before, rate_baseline_after, np.array(spike_times), stimulus_power, v_dent_output[int(0.05 / deltat):-1], offset, v_mem_output
stimulus = eod_fish_r stimulus = eod_fish_r
stimulus_base = eod_fish_r stimulus_base = eod_fish_r
if 'Zero' in titles_amp[a]: #else:
power_here = 'sinz' + '_' + zeros power_here = 'sinz'
else:
power_here = 'sinz'
cvs, adapt_output, baseline_after_b, _, rate_adapted_b, rate_baseline_before_b, rate_baseline_after_b, \ cvs, adapt_output, baseline_after_b, _, rate_adapted_b, rate_baseline_before_b, rate_baseline_after_b, \
spikes_base[t], _, _, offset_new, _,noise_final = simulate(cell, offset, stimulus, spikes_base[t], _, _, offset_new, _,noise_final = simulate(cell, offset, stimulus,
deltat=deltat, deltat=deltat,
adaptation_variant=adapt_offset, **model_params)#adaptation_variant=adapt_offset,
adaptation_yes_j=f2, #adaptation_yes_j=f2,
adaptation_yes_e=f1, #adaptation_yes_e=f1,
adaptation_yes_t=t, #adaptation_yes_t=t,
power_variant=power_here, #power_variant=power_here,
power_alpha=alpha, #power_alpha=alpha,
power_nr=n, #power_nr=n,
**model_params)
if t == 0: if t == 0:
# here we record the changes in the offset due to the adaptation # here we record the changes in the offset due to the adaptation
@ -663,7 +673,7 @@ def plt_model_full_model2(grid0, reshuffled='reshuffled', af_2 = 0.1, dev=0.0005
p0_mean = p012[0]#np.mean(ps[j], axis=0) p0_mean = p012[0]#np.mean(ps[j], axis=0)
p0_means.append(p0_mean) p0_means.append(p0_mean)
try: try:
ax.plot(fs, p0_mean, color='black') # plt_peaks(ax[0], p01, fs, 'orange') ax.plot(fs, p0_mean, color='black', zorder = 100) # plt_peaks(ax[0], p01, fs, 'orange')
except: except:
print('m something') print('m something')
embed() embed()
@ -675,38 +685,87 @@ def plt_model_full_model2(grid0, reshuffled='reshuffled', af_2 = 0.1, dev=0.0005
embed() embed()
fr = results_diff.fr.iloc[j] fr = results_diff.fr.iloc[j]
#embed() #embed()
#for p in range(len(p0_means)): #for p in range(len(p0_means)): np.abs(DF2 * 2),
freqs = [np.abs(DF1), freqs = [np.abs(DF1),
np.abs(DF2), np.abs(DF2 * 2), np.abs(DF2),
np.abs(np.abs(DF1) - np.abs(DF2)), np.abs(np.abs(DF1) - np.abs(DF2)),
np.abs(DF1) + np.abs(DF2), fr] np.abs(DF1) + np.abs(DF2), fr]
colors = [color01, color02,color02, colors = [color01, color02,
color01_2, color012, color0]# np.abs(DF2 * 2), color02,'DF2_H1', color01_2, color012, color0]# color02,np.abs(DF2 * 2), color02,'DF2_H1',
labels = ['DF1', 'DF1_H3', 'DF2', labels = [deltaf1_label(), deltaf2_label(),
'DF2_H2', '|DF1-DF2|', '|DF1+DF2|', 'baseline'] diff_label(), sum_label(), fbasename()]
marker = markers[j]#'DF1_H1','DF1_H4', marker = markers[j]#'DF1_H1','DF1_H4',v
if len(stack_final) > 0:
adjust_factor = 5
pos_y = np.argmin(np.abs(stack_final.index - np.abs(DF2)))
pos_x = np.argmin(np.abs(stack_final.keys() - np.abs(DF1)))
xi2_sum = stack_final.iloc[pos_y, stack_final.keys()[pos_x]]
#stack_final.iloc[pos_x][stack_final.keys()[pos_y]]
xi2_sum = stack_final[stack_final.keys()[pos_x]].iloc[pos_y]
sum_peak = ((adjust_factor *a_f1 * a_f2 * np.abs(xi2_sum))** 2)/4
#embed()
#stack_final.keys()[pos_x_minus] + stack_final.index[pos_y]
pos_x_minus = np.argmin(np.abs(stack_final.keys() + np.abs(DF1)))
#xi2_diff = stack_final.iloc[pos_x, stack_final.keys()[pos_y_minus]]
vals = stack_final[stack_final.keys()[pos_x_minus]][stack_final[stack_final.keys()[pos_x_minus]].index > 0]
xi2_diff = stack_final[stack_final.keys()[pos_x_minus]].iloc[pos_y]#stack_final.iloc[pos_x, stack_final.keys()[pos_y_minus]]
#stack_final[stack_final.keys()[pos_x_minus]].iloc[pos_y-1]
diff_peak = ((adjust_factor *a_f1 * a_f2 * np.abs(xi2_diff))** 2)/4
#model_show = get_stack_initial(cell, cell_add, cells_save, creation_time_update, direct_load, path1, redo,
# save_name_rev, size_update)
#embed()
ax.scatter(np.abs(DF1)+np.abs(DF2), sum_peak, color = 'None', edgecolor='black')
ax.scatter(np.abs(np.abs(DF1) - np.abs(DF2)), diff_peak, color='None', edgecolor='black')
if len(stack_saved) > 0:
print('todo: tranfervalues noch nicht da')
#f_axis, vals = get_transferfunction(stack_saved)
#embed() #embed()
plt_peaks_several(freqs, p0_mean, ax, p0_mean, fs, labels, 0, colors, emb=False, marker=marker, add_log=2.5, p_passed = plt_peaks_several(freqs, p0_mean, ax, p0_mean, fs, labels, 0, colors, emb=False, marker=marker, add_log=2.5,
exact=False, perc_peaksize=0.08, ms=ms, clip_on=clip_on, log=log) exact=False, perc_peaksize=0, ms=ms, clip_on=clip_on, log=log, add_not_log = 350)# perc = 0.2
ax.set_xlim(0, 300) ax.set_xlim(0, 300)
if j == 0: #ax.text(1,1, 'rt_xi=' + str(np.round(sum_peak / diff_peak,2))+' rt_ps=' + str(np.round(p_passed[3] / p_passed[2],2)), ha = 'right', va = 'top', transform=ax.transAxes)
ax.text(1, 1, 'Model', ha='right', va='top', transform=ax.transAxes) print('sumpeak'+str(np.abs(xi2_sum))+'diffpeak'+str(np.abs(xi2_diff)))
if j == 0: #embed()#
#if j == 0:
# ax.text(1, 1, 'Model', ha='right', va='top', transform=ax.transAxes)
if j < 2:
remove_xticks(ax) remove_xticks(ax)
ax.set_xlabel('') ax.set_xlabel('')
else: else:
ax.set_xlabel('Frequency [Hz]') ax.set_xlabel('Frequency [Hz]')
if j == 0:
ax.legend(ncol = 6, loc = (-0.2, 1.35))#-0.5
if log == 'log': if log == 'log':
ax.set_xlim(xlim_psd)# ax.set_xlim(xlim_psd)#
ax.set_ylim(ylim_log) ax.set_ylim(ylim_log)
ax.set_ylabel('dB') if j in [1, 3]:
remove_yticks(ax)
else:
ax.set_ylabel('dB')
else:
if j in [1, 3]:
remove_yticks(ax)
else:
ax.set_ylabel('Frequency [Hz]')
join_y(axes)#[1::] join_y(axes)#[1::]
axes.append(ax) axes.append(ax)
return fr, eod_fr return fr, eod_fr, axes
@ -990,12 +1049,12 @@ def plt_data_full_model(c1, chose_score, detections, devs, dfs, end, grid, mult_
#labels = labels_all_motivation(DF1, DF2, fr_isi) #labels = labels_all_motivation(DF1, DF2, fr_isi)
labels = ['$f_{base}$', labels = ['$f_{base}$',
'$|\Delta f_{1}|$', deltaf1_label(),
'$|\Delta f_{2}|$', deltaf2_label(),
'$|\Delta f_{1} + \Delta f_{2}|$', sum_label(),
'$2|\Delta f_{1}|$', two_deltaf1_label(),
'$2|\Delta f_{2}|$', two_deltaf2_label(),
'$|\Delta f_{1} - \Delta f_{2}|$', diff_label(),
'fr_bc', 'fr_bc',
'fr_given_burst_corr_individual', 'highest_fr_burst_corr_individual', 'fr_given_burst_corr_individual', 'highest_fr_burst_corr_individual',
'fr', 'fr_given', 'fr', 'fr_given',

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -81,6 +81,7 @@ def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, dfs=['m1'
start = 'min' # start = 'min' #
cells = ['2021-08-03-ac-invivo-1'] cells = ['2021-08-03-ac-invivo-1']
tag_cells = [] tag_cells = []
ax_s = []
for c, cell in enumerate(cells): for c, cell in enumerate(cells):
counter_pic = 0 counter_pic = 0
contrasts = [c2] contrasts = [c2]
@ -210,6 +211,103 @@ def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, dfs=['m1'
grid00 = gridspec.GridSpecFromSubplotSpec(1, 4, wspace=0.15, hspace=0.35, grid00 = gridspec.GridSpecFromSubplotSpec(1, 4, wspace=0.15, hspace=0.35,
subplot_spec=grid[0, :]) subplot_spec=grid[0, :])
texts1 = ['', '$s_{1}(t)$', '$s_{2}(t)$', '$s_{1} +s_{2}(t)$']
texts2 = ['$r_{0}$', '$r_{0} +r_{1}(t)$', '$r_{0} +r_{2}(t)$', r'$r_{t} \neq r_{0}+r_{1}(t)+r_{2}(t)$']
for g in range(4):
horizontal = True
if horizontal:
grid000 = gridspec.GridSpecFromSubplotSpec(1, 3, wspace=0, hspace=0,
subplot_spec=grid00[g], width_ratios = [2,0.7,2])
else:
grid000 = gridspec.GridSpecFromSubplotSpec(3, 1, wspace=0, hspace=0,
subplot_spec=grid00[g])
ax0 = plt.subplot(grid000[0])
color = 'black' # color_beats()
#ax0.plot(time_array, sine, color=color, clip_on=False)
ax0.show_spines('')
#ax0.set_title('$s(t)$') # xy=(0.2, 0.2),
ax0.show_spines('')
# xytext=(0.8, 0.8),
lw = 1.5
ws = ws_nonlin_systems()
fs = 8
if horizontal:
start = 0.7
if g != texts1[g]:
ax0.annotate('', ha='center', xycoords='axes fraction',
xy=(1, 0.5), textcoords='axes fraction',
xytext=(start, 0.5),
arrowprops={"arrowstyle": "->",
"linestyle": "-",
"linewidth": lw,
"color":
'black'},
zorder=1, annotation_clip=False, transform=ax0.transAxes, )
ax0.text(start, 0.5, texts1[g], transform=ax0.transAxes, ha='right',
va='center', fontsize = fs)
else:
start = 1.5
if g != texts1[g]:
ax0.annotate('', ha='center', xycoords='axes fraction',
xy=(0.5, start), textcoords='axes fraction',
xytext=(0.5, 0),
arrowprops={"arrowstyle": "<-",
"linestyle": "-",
"linewidth": lw,
"color":
'black'},
zorder=1, annotation_clip=False, transform=ax0.transAxes, )
ax0.text(0.5, start, texts1[g], transform=ax0.transAxes, ha = 'center', va = 'center')
ax_s.append(ax0)
# embed()
# fig.texts.append(ax[0].texts.pop())
###################################
ax1 = plt.subplot(grid000[1])
circle_plot(ax1, ax0, ws, lw)
ax1.show_spines('')
#ax1.set_xlim(-20, 40)
#ax1.set_ylim(0, 20)
ax1.set_xlim(0, 20)
ax1.set_ylim(-20, 40)
####################################texts1[g]texts2[g]
ax2 = plt.subplot(grid000[2])
if horizontal:
end = 0.3
ax2.annotate('', ha='center', xycoords='axes fraction',
xy=(end, 0.5), textcoords='axes fraction',
xytext=(0, 0.5),
arrowprops={"arrowstyle": "->",
"linestyle": "-",
"linewidth": lw,
"color":
'black'},
zorder=1, annotation_clip=False, transform=ax2.transAxes, )
ax2.text(end, 0.5, texts2[g], transform=ax2.transAxes, ha='left', va='center', fontsize = fs)
else:
end = -0.5
ax2.annotate('', ha='center', xycoords='axes fraction',
xy=(0.5, end), textcoords='axes fraction',
xytext=(0.5, 1),
arrowprops={"arrowstyle": "->",
"linestyle": "-",
"linewidth": lw,
"color":
'black'},
zorder=1, annotation_clip=False, transform=ax2.transAxes, )
ax2.text(0.5, end, texts2[g], transform=ax2.transAxes, ha='center', va='center')
ax2.show_spines('')
########################################################################## ##########################################################################
# part with the power spectra # part with the power spectra
grid0 = gridspec.GridSpecFromSubplotSpec(5, 4, wspace=0.15, hspace=0.35, grid0 = gridspec.GridSpecFromSubplotSpec(5, 4, wspace=0.15, hspace=0.35,
@ -362,7 +460,9 @@ def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, dfs=['m1'
#fig.tag(ax_w[0:3], xoffs=-2.3, yoffs=1.7) #fig.tag(ax_w[0:3], xoffs=-2.3, yoffs=1.7)
#fig.tag(ax_w[3::], xoffs=-1.9, yoffs=1.4) #fig.tag(ax_w[3::], xoffs=-1.9, yoffs=1.4)
fig.tag(ax_w, xoffs=-1.9, yoffs=1.4)
fig.tag(ax_s, xoffs=-1.9, yoffs=1.4)
#fig.tag(ax_w, xoffs=-1.9, yoffs=1.4)
# ax_w, np.transpose(ax_as), ax_ps # ax_w, np.transpose(ax_as), ax_ps
if save: if save:
save_visualization(individual_tag=individual_tag, show=show, pdf=True) save_visualization(individual_tag=individual_tag, show=show, pdf=True)

View File

@ -2317,6 +2317,16 @@ article{Egerland2020,
publisher={Taylor \& Francis} publisher={Taylor \& Francis}
} }
@article{Marmarelis1999,
title={Principal dynamic mode analysis of nonlinear transduction in a spider mechanoreceptor},
author={Marmarelis, Vasilis Z and Juusola, Mikko and French, Andrew S},
journal={Annals of biomedical engineering},
volume={27},
pages={391--402},
year={1999},
publisher={Springer}
}
@Article{Freund2002, @Article{Freund2002,
Title = {Behavioral Stochastic Resonance: How the Noise from a Daphnia Swarm Enhances Individual Prey Capture by Juvenile Paddlefish.}, Title = {Behavioral Stochastic Resonance: How the Noise from a Daphnia Swarm Enhances Individual Prey Capture by Juvenile Paddlefish.},
Author = {Jan A. Freund and Lutz Schimanski-Geier and Beatrix Beisner and Alexander Neiman and David F. Russell and Tatyana Yakusheva and Frank Moss}, Author = {Jan A. Freund and Lutz Schimanski-Geier and Beatrix Beisner and Alexander Neiman and David F. Russell and Tatyana Yakusheva and Frank Moss},

View File

@ -2317,6 +2317,16 @@ article{Egerland2020,
publisher={Taylor \& Francis} publisher={Taylor \& Francis}
} }
@article{Marmarelis1999,
title={Principal dynamic mode analysis of nonlinear transduction in a spider mechanoreceptor},
author={Marmarelis, Vasilis Z and Juusola, Mikko and French, Andrew S},
journal={Annals of biomedical engineering},
volume={27},
pages={391--402},
year={1999},
publisher={Springer}
}
@Article{Freund2002, @Article{Freund2002,
Title = {Behavioral Stochastic Resonance: How the Noise from a Daphnia Swarm Enhances Individual Prey Capture by Juvenile Paddlefish.}, Title = {Behavioral Stochastic Resonance: How the Noise from a Daphnia Swarm Enhances Individual Prey Capture by Juvenile Paddlefish.},
Author = {Jan A. Freund and Lutz Schimanski-Geier and Beatrix Beisner and Alexander Neiman and David F. Russell and Tatyana Yakusheva and Frank Moss}, Author = {Jan A. Freund and Lutz Schimanski-Geier and Beatrix Beisner and Alexander Neiman and David F. Russell and Tatyana Yakusheva and Frank Moss},

View File

@ -618,7 +618,7 @@ Only those P-units that exhibit low coefficients of variation (CV) of the inters
The CV serves as a proxy for the intrinsic noise in the cells. In both cell types, we observe a negative correlation between \nli{} and the CV, indicating that it is the level of intrinsic noise that plays a role here. These findings are in line with previous studies that propose that noise linearizes the system\cite{Roddey2000, Chialvo1997, Voronenko2017}. More intrinsic noise has been demonstrated to increase the CV and reduce nonlinear phase-locking in vestibular afferents\cite{Schneider2011}. Reduced noise, on the other hand, has been associated with stronger nonlinearity in pyramidal cells of the ELL\cite{Chacron2006}. Further support for the notion of noise limiting the nonlinearity comes from our P-unit LIF model that faithfully reproduces P-unit activity\cite{Barayeu2023}. We can use this model and the noise-split according to the Furutsu-Novikov theorem\cite{Novikov1965,Furutsu1963} to increase the signal-to-noise ratio in the cell while keeping the overall response variability constant (see methods). Treating 90\% of the total noise as signal and simulating large numbers of trial uncovers the full nonlinearity structure (\figref{model_and_data}) seen in LIF neurons and the analytical derivations when driven with sine-wave stimuli\cite{Voronenko2017}. The CV serves as a proxy for the intrinsic noise in the cells. In both cell types, we observe a negative correlation between \nli{} and the CV, indicating that it is the level of intrinsic noise that plays a role here. These findings are in line with previous studies that propose that noise linearizes the system\cite{Roddey2000, Chialvo1997, Voronenko2017}. More intrinsic noise has been demonstrated to increase the CV and reduce nonlinear phase-locking in vestibular afferents\cite{Schneider2011}. Reduced noise, on the other hand, has been associated with stronger nonlinearity in pyramidal cells of the ELL\cite{Chacron2006}. Further support for the notion of noise limiting the nonlinearity comes from our P-unit LIF model that faithfully reproduces P-unit activity\cite{Barayeu2023}. We can use this model and the noise-split according to the Furutsu-Novikov theorem\cite{Novikov1965,Furutsu1963} to increase the signal-to-noise ratio in the cell while keeping the overall response variability constant (see methods). Treating 90\% of the total noise as signal and simulating large numbers of trial uncovers the full nonlinearity structure (\figref{model_and_data}) seen in LIF neurons and the analytical derivations when driven with sine-wave stimuli\cite{Voronenko2017}.
\subsection*{Noise stimulation approximates the real three-fish interaction} \subsection*{Noise stimulation approximates the real three-fish interaction}
Our analysis is based on the neuronal responses to white noise stimulus sequences. For the P-units, the stimulus was a random amplitude modulation (RAM) while it was a direct noise stimulus for the ampullary cells. These broad-band stimuli have the advantage that all behaviorally relevant frequencies can be measured with a single stimulus presentation and is a widely used approach to characterize sensory coding\cite{French1973, Borst1999, Chacron2005, Grewe2017}. However, these stimuli also increase the total level of noise in the system and may have a linearizing effect on signal transmission. In a our P-unit models, we were able to make use of the Furutsu-Novikov theorem to estimate nonlinear signal transmission for zero-amplitude stimulation. Only with this procedure and many trials, we find for low-CV P-units all the pronounced ridges in the second-order susceptibility that we would expect according to theory \cite{Voronenko2017}. Our analysis is based on the neuronal responses to white noise stimulus sequences. For the P-units, the stimulus was a random amplitude modulation (RAM) while it was a direct noise stimulus for the ampullary cells. These broad-band stimuli have the advantage that all behaviorally relevant frequencies can be measured with a single stimulus presentation and is a widely used approach to characterize sensory coding\cite{French1973,Marmarelis1999, Borst1999, Chacron2005, Grewe2017}. However, these stimuli also increase the total level of noise in the system and may have a linearizing effect on signal transmission. In a our P-unit models, we were able to make use of the Furutsu-Novikov theorem to estimate nonlinear signal transmission for zero-amplitude stimulation. Only with this procedure and many trials, we find for low-CV P-units all the pronounced ridges in the second-order susceptibility that we would expect according to theory \cite{Voronenko2017}.
In the natural situation, the stimuli are periodic signals defined by the difference frequencies. Ho well can we extrapolate from the white noise analysis to the pure sinewave situation? \notejg{Predictions from the X2 matrix and the equations in Voronekov} In the natural situation, the stimuli are periodic signals defined by the difference frequencies. Ho well can we extrapolate from the white noise analysis to the pure sinewave situation? \notejg{Predictions from the X2 matrix and the equations in Voronekov}

View File

@ -618,7 +618,7 @@ Only those P-units that exhibit low coefficients of variation (CV) of the inters
The CV serves as a proxy for the intrinsic noise in the cells. In both cell types, we observe a negative correlation between \nli{} and the CV, indicating that it is the level of intrinsic noise that plays a role here. These findings are in line with previous studies that propose that noise linearizes the system\cite{Roddey2000, Chialvo1997, Voronenko2017}. More intrinsic noise has been demonstrated to increase the CV and reduce nonlinear phase-locking in vestibular afferents\cite{Schneider2011}. Reduced noise, on the other hand, has been associated with stronger nonlinearity in pyramidal cells of the ELL\cite{Chacron2006}. Further support for the notion of noise limiting the nonlinearity comes from our P-unit LIF model that faithfully reproduces P-unit activity\cite{Barayeu2023}. We can use this model and the noise-split according to the Furutsu-Novikov theorem\cite{Novikov1965,Furutsu1963} to increase the signal-to-noise ratio in the cell while keeping the overall response variability constant (see methods). Treating 90\% of the total noise as signal and simulating large numbers of trial uncovers the full nonlinearity structure (\figref{model_and_data}) seen in LIF neurons and the analytical derivations when driven with sine-wave stimuli\cite{Voronenko2017}. The CV serves as a proxy for the intrinsic noise in the cells. In both cell types, we observe a negative correlation between \nli{} and the CV, indicating that it is the level of intrinsic noise that plays a role here. These findings are in line with previous studies that propose that noise linearizes the system\cite{Roddey2000, Chialvo1997, Voronenko2017}. More intrinsic noise has been demonstrated to increase the CV and reduce nonlinear phase-locking in vestibular afferents\cite{Schneider2011}. Reduced noise, on the other hand, has been associated with stronger nonlinearity in pyramidal cells of the ELL\cite{Chacron2006}. Further support for the notion of noise limiting the nonlinearity comes from our P-unit LIF model that faithfully reproduces P-unit activity\cite{Barayeu2023}. We can use this model and the noise-split according to the Furutsu-Novikov theorem\cite{Novikov1965,Furutsu1963} to increase the signal-to-noise ratio in the cell while keeping the overall response variability constant (see methods). Treating 90\% of the total noise as signal and simulating large numbers of trial uncovers the full nonlinearity structure (\figref{model_and_data}) seen in LIF neurons and the analytical derivations when driven with sine-wave stimuli\cite{Voronenko2017}.
\subsection*{Noise stimulation approximates the real three-fish interaction} \subsection*{Noise stimulation approximates the real three-fish interaction}
Our analysis is based on the neuronal responses to white noise stimulus sequences. For the P-units, the stimulus was a random amplitude modulation (RAM) while it was a direct noise stimulus for the ampullary cells. These broad-band stimuli have the advantage that all behaviorally relevant frequencies can be measured with a single stimulus presentation and is a widely used approach to characterize sensory coding\cite{French1973, Borst1999, Chacron2005, Grewe2017}. However, these stimuli also increase the total level of noise in the system and may have a linearizing effect on signal transmission. In a our P-unit models, we were able to make use of the Furutsu-Novikov theorem to estimate nonlinear signal transmission for zero-amplitude stimulation. Only with this procedure and many trials, we find for low-CV P-units all the pronounced ridges in the second-order susceptibility that we would expect according to theory \cite{Voronenko2017}. Our analysis is based on the neuronal responses to white noise stimulus sequences. For the P-units, the stimulus was a random amplitude modulation (RAM) while it was a direct noise stimulus for the ampullary cells. These broad-band stimuli have the advantage that all behaviorally relevant frequencies can be measured with a single stimulus presentation and is a widely used approach to characterize sensory coding\cite{French1973,Marmarelis1999, Borst1999, Chacron2005, Grewe2017}. However, these stimuli also increase the total level of noise in the system and may have a linearizing effect on signal transmission. In a our P-unit models, we were able to make use of the Furutsu-Novikov theorem to estimate nonlinear signal transmission for zero-amplitude stimulation. Only with this procedure and many trials, we find for low-CV P-units all the pronounced ridges in the second-order susceptibility that we would expect according to theory \cite{Voronenko2017}.
In the natural situation, the stimuli are periodic signals defined by the difference frequencies. Ho well can we extrapolate from the white noise analysis to the pure sinewave situation? \notejg{Predictions from the X2 matrix and the equations in Voronekov} In the natural situation, the stimuli are periodic signals defined by the difference frequencies. Ho well can we extrapolate from the white noise analysis to the pure sinewave situation? \notejg{Predictions from the X2 matrix and the equations in Voronekov}
@ -778,20 +778,6 @@ Leaky integrate-and-fire (LIF) models with a carrier were constructed to reprodu
\end{equation} \end{equation}
with the EOD frequency $f_{EOD}$ and an amplitude normalized to one. with the EOD frequency $f_{EOD}$ and an amplitude normalized to one.
%\subsection*{Stimuli for the model}
The model neurons were driven with similar stimuli as the real neurons in the original experiments. To mimic the interaction with one or two foreign animals the receiving fish's EOD (\Eqnref{eq:eod}) was normalized to an amplitude of one and the respective EODs of a second or third fish were added.%\Eqnref{ eq.\,\ref{eq:eod}
The random amplitude modulation (RAM) input to the model was created by drawing random amplitude and phases from Gaussian distributions for each frequency component in the range 0--300 Hz. An inverse Fourier transform was applied to get the final amplitude RAM time-course. The input to the model was then
\begin{equation}
\label{eq:ram_equation}
y(t) = (1+ s(t)) \cdot \cos(2\pi f_{EOD} t)
\end{equation}
\note{fix stimulus x and y notation and RAM}
From each simulation run, the first second was discarded and the analysis was based on the last second of the data. The resulting spectra thus have a spectral resolution of 1\,Hz.
% \subsection{Second-order susceptibility analysis of the model}
% %\subsubsection{Model second-order nonlinearity}
% The second-order susceptibility in the model was calculated with \Eqnref{eq:susceptibility}, resulting in matrices as in \figrefb{model_and_data} and \figrefb{fig:model_full}. For this, the model neuron was presented the input $x(t)$ for 2\,s, with the first second being dismissed as the transient. The second-order susceptibility calculation was performed on the last second, resulting in a frequency resolution of 1\,Hz.
In the model, the input $x(t)$ was then first thresholded to model the synapse between the primary receptor cells and the afferent. In the model, the input $x(t)$ was then first thresholded to model the synapse between the primary receptor cells and the afferent.
\begin{equation} \begin{equation}
\label{eq:threshold2} \label{eq:threshold2}
@ -850,6 +836,20 @@ The model's ODEs were integrated by the Euler forward method with a time-step of
\subsection*{Model parameters}\label{paramtext} \subsection*{Model parameters}\label{paramtext}
The eight free parameters of the P-unit model $\beta$, $\tau_m$, $\mu$, $D$, $\tau_A$, $\Delta_A$, $\tau_d$, and $t_{ref}$, were fitted to both the baseline activity (baseline firing rate, CV of ISIs, serial correlation of ISIs at lag one, and vector strength of spike coupling to EOD) and the responses to step-like increases and decreases in EOD amplitude (onset-state and steady-state responses, effective adaptation time constant). For each simulation, the start parameters $A$, $V_{d}$ and $V_{m}$ were drawn from a random starting value distribution, estimated from a 100\,s baseline simulation after an initial 100\,s of simulation that was discarded as a transient. The eight free parameters of the P-unit model $\beta$, $\tau_m$, $\mu$, $D$, $\tau_A$, $\Delta_A$, $\tau_d$, and $t_{ref}$, were fitted to both the baseline activity (baseline firing rate, CV of ISIs, serial correlation of ISIs at lag one, and vector strength of spike coupling to EOD) and the responses to step-like increases and decreases in EOD amplitude (onset-state and steady-state responses, effective adaptation time constant). For each simulation, the start parameters $A$, $V_{d}$ and $V_{m}$ were drawn from a random starting value distribution, estimated from a 100\,s baseline simulation after an initial 100\,s of simulation that was discarded as a transient.
\subsection*{Stimuli for the model}
The model neurons were driven with similar stimuli as the real neurons in the original experiments. To mimic the interaction with one or two foreign animals the receiving fish's EOD (\Eqnref{eq:eod}) was normalized to an amplitude of one and the respective EODs of a second or third fish were added.%\Eqnref{ eq.\,\ref{eq:eod}
The random amplitude modulation (RAM) input to the model was created by drawing random amplitude and phases from Gaussian distributions for each frequency component in the range 0--300 Hz. An inverse Fourier transform was applied to get the final amplitude RAM time-course. The input to the model was then
\begin{equation}
\label{eq:ram_equation}
y(t) = (1+ s(t)) \cdot \cos(2\pi f_{EOD} t)
\end{equation}
\note{fix stimulus x and y notation and RAM}
From each simulation run, the first second was discarded and the analysis was based on the last second of the data. The resulting spectra thus have a spectral resolution of 1\,Hz.
% \subsection{Second-order susceptibility analysis of the model}
% %\subsubsection{Model second-order nonlinearity}
% The second-order susceptibility in the model was calculated with \Eqnref{eq:susceptibility}, resulting in matrices as in \figrefb{model_and_data} and \figrefb{fig:model_full}. For this, the model neuron was presented the input $x(t)$ for 2\,s, with the first second being dismissed as the transient. The second-order susceptibility calculation was performed on the last second, resulting in a frequency resolution of 1\,Hz.
\subsection*{Model noise split into a noise and a stimulus component}\label{intrinsicsplit_methods} \subsection*{Model noise split into a noise and a stimulus component}\label{intrinsicsplit_methods}
According to the Furutsu-Novikov Theorem \cite{Novikov1965, Furutsu1963} the total noise of a LIF model ($\xi$) can be split up into several independent noise processes with the same correlation function. Here we split the internal noise into two parts: (i) One part is treated as a driving input signal $s_\xi(t)$ \note{hier umschreiben das xi muss ein RAM sein} and used to calculate the cross-spectra in \Eqnref{eq:crosshigh} and (ii) the remaining noise $\sqrt{2D \, c_{\rm{noise}}} \cdot \xi(t)$ that is treated as pure noise. In this way the effective signal-to-noise ratio can be increased while maintaining the total noise in the system. $\rho$ a scaling factor that compensates (see below) for the signal transformations the amplitude modulation stimulus undergoes in the model, i.e. the threshold and the dendritic lowpass. In our case the model has a carrier (the fish's self-generated EOD) and we thus want to drive the model with an amplitude modulation stimulus According to the Furutsu-Novikov Theorem \cite{Novikov1965, Furutsu1963} the total noise of a LIF model ($\xi$) can be split up into several independent noise processes with the same correlation function. Here we split the internal noise into two parts: (i) One part is treated as a driving input signal $s_\xi(t)$ \note{hier umschreiben das xi muss ein RAM sein} and used to calculate the cross-spectra in \Eqnref{eq:crosshigh} and (ii) the remaining noise $\sqrt{2D \, c_{\rm{noise}}} \cdot \xi(t)$ that is treated as pure noise. In this way the effective signal-to-noise ratio can be increased while maintaining the total noise in the system. $\rho$ a scaling factor that compensates (see below) for the signal transformations the amplitude modulation stimulus undergoes in the model, i.e. the threshold and the dendritic lowpass. In our case the model has a carrier (the fish's self-generated EOD) and we thus want to drive the model with an amplitude modulation stimulus

0
test_project.py Normal file
View File

Binary file not shown.

View File

@ -166,6 +166,7 @@ def trialnr(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1], cells
ax.scatter(trial_nrs_here, perc95, color = 'black', clip_on = False) ax.scatter(trial_nrs_here, perc95, color = 'black', clip_on = False)
#embed()
ax.set_xscale('log') ax.set_xscale('log')
ax.set_yscale('log') ax.set_yscale('log')
ax.set_xlabel('Trials [$N$]') ax.set_xlabel('Trials [$N$]')

View File

@ -2268,6 +2268,8 @@ def plt_squares_special(params, col_desired=2, var_items=['contrasts'], show=Fal
def plt_single_square_modl(ax, cell, model, perc, titles, width, bias_factor=1, fr_print=False, eod_metrice=True, nr=3, def plt_single_square_modl(ax, cell, model, perc, titles, width, bias_factor=1, fr_print=False, eod_metrice=True, nr=3,
titles_plot=False, xpos=1.1, resize=False, ls=8): titles_plot=False, xpos=1.1, resize=False, ls=8):
model_show, stack_plot, stack_plot_wo_norm = get_stack(cell, model, bias_factor=bias_factor) model_show, stack_plot, stack_plot_wo_norm = get_stack(cell, model, bias_factor=bias_factor)
print(np.max(np.max(stack_plot)))
embed()
if resize: if resize:
stack_plot, add_nonlin_title, resize_val = rescale_colorbar_and_values(stack_plot) stack_plot, add_nonlin_title, resize_val = rescale_colorbar_and_values(stack_plot)
else: else:
@ -2294,7 +2296,8 @@ def plt_single_square_modl(ax, cell, model, perc, titles, width, bias_factor=1,
transform=ax.transAxes) # , fontsize7= + cell_type# cell[0:13] + stack_final.celltype.unique()[0] + 'S.Nr ' + str( transform=ax.transAxes) # , fontsize7= + cell_type# cell[0:13] + stack_final.celltype.unique()[0] + 'S.Nr ' + str(
im = plt_RAM_perc(ax, perc, stack_plot) im = plt_RAM_perc(ax, perc, stack_plot)
#print(np.max(np.max(stack_plot)))
#embed()
plt_triangle(ax, model_show.fr.iloc[0], np.round(model_show.fr_stim.iloc[0]), 300, model_show.eod_fr.iloc[0], plt_triangle(ax, model_show.fr.iloc[0], np.round(model_show.fr_stim.iloc[0]), 300, model_show.eod_fr.iloc[0],
eod_metrice=eod_metrice, nr=nr) eod_metrice=eod_metrice, nr=nr)
ax.set_aspect('equal') ax.set_aspect('equal')
@ -4433,9 +4436,9 @@ def base_cells_susept(ax_isi, ax_p, c, cell, cell_type, cells_plot, colors, eod_
if base_extra: if base_extra:
if titles[c] == '': if titles[c] == '':
add_nrs = r'$\mathrm{f_{base}}=%.0f$\,Hz,' % fr + r' $\mathrm{CV_{base}}=%.2f$' % cv add_nrs = r'$\mathrm{f'+basename_small()+'}=%.0f$\,Hz,' % fr + r' $\mathrm{CV'+basename_small()+'}=%.2f$' % cv
else: else:
add_nrs = r'$\mathrm{f}_{base}}=%.0f$\,Hz,' % fr + r' $\mathrm{CV_{base}}=%.2f$' % cv add_nrs = r'$\mathrm{f}'+basename_small()+'}=%.0f$\,Hz,' % fr + r' $\mathrm{CV'+basename_small()+'}=%.2f$' % cv
ax_isi.text(pos, 1.25, titles[c] + add_nrs, ax_isi.text(pos, 1.25, titles[c] + add_nrs,
transform=ax_isi.transAxes) # str(np.std(isi) / np.mean(isi)) transform=ax_isi.transAxes) # str(np.std(isi) / np.mean(isi))
@ -5168,11 +5171,29 @@ def get_xlim_psd(axis_d, xlim):
def plt_transferfunction(alpha, axo, color, stack_final, zorder=1, label='', normval=1, log_transfer=False): def plt_transferfunction(alpha, axo, color, stack_final, zorder=1, label='', normval=1, log_transfer=False):
f_axis, vals = get_transferfunction(stack_final)
if log_transfer:
means_all = 10 * np.log10(vals)
else:
means_all = 10 * np.log10(vals)
max_lim = calc_cut_offs(stack_final.file_name.iloc[0]) / normval
axis = f_axis / normval
if normval != 1:
pass
if max_lim:
axo.plot(axis[axis < max_lim], means_all[axis < max_lim], color=color, zorder=zorder, alpha=alpha, label=label)
else:
axo.plot(axis, means_all, color=color, alpha=alpha, zorder=zorder, label=label)
def get_transferfunction(stack_final):
osf = stack_final['osf'] osf = stack_final['osf']
isf = stack_final['isf'] isf = stack_final['isf']
f = find_f(stack_final) f = find_f(stack_final)
f_axis = f[0:len(isf.iloc[0][0])] f_axis = f[0:len(isf.iloc[0][0])]
# csd pds berechnung # csd pds berechnung
counter = 0 counter = 0
for t in range(len(osf)): for t in range(len(osf)):
@ -5186,21 +5207,7 @@ def plt_transferfunction(alpha, axo, color, stack_final, zorder=1, label='', nor
counter += 1 counter += 1
vals = vals / counter vals = vals / counter
vals = np.abs(vals) / (powers / counter) vals = np.abs(vals) / (powers / counter)
return f_axis, vals
if log_transfer:
means_all = 10 * np.log10(vals)
else:
means_all = 10 * np.log10(vals)
max_lim = calc_cut_offs(stack_final.file_name.iloc[0]) / normval
axis = f_axis / normval
if normval != 1:
pass
if max_lim:
axo.plot(axis[axis < max_lim], means_all[axis < max_lim], color=color, zorder=zorder, alpha=alpha, label=label)
else:
axo.plot(axis, means_all, color=color, alpha=alpha, zorder=zorder, label=label)
def plt_power_trace(alpha, axo, color, db, stack_final, stack_osf, test_limits, xmax, eod_fr=1, def plt_power_trace(alpha, axo, color, db, stack_final, stack_osf, test_limits, xmax, eod_fr=1,
@ -5950,9 +5957,9 @@ def cells_eigen(base_extra=False, amp_desired=[0.5, 1, 5], xlim=[0, 1.1], cells_
def fr_name_rm(): def fr_name_rm():
rm_var = rem_variable() rm_var = rem_variable()
if rm_var['rm']: if rm_var['rm']:
val = r'$f\rm{_{base}}$' val = r'$f\rm{'+basename_small()+'}$'
else: else:
val = r'$f_{base}$' val = r'$f'+basename_small()+'$'
return val return val
def ampullary_punit(permuted=False, eod_metrice=True, base_extra=False, color_same=True, fr_name='$f_{Base}$', def ampullary_punit(permuted=False, eod_metrice=True, base_extra=False, color_same=True, fr_name='$f_{Base}$',
@ -8951,7 +8958,7 @@ def plt_psds_ROC(arrays, ax00, ax_ps, cell, colors_p, f, grid0, group_mean, nfft
def labels_all_motivation(DF1, DF2, fr_isi): def labels_all_motivation(DF1, DF2, fr_isi):
labels = [r'$f\rm{_{base}}=%s$' % (int(np.round(fr_isi))) + '\,Hz', labels = [r'$f'+basename_small()+'=%s$' % (int(np.round(fr_isi))) + '\,Hz',
df1_core(DF2), df1_core(DF2),
df2_core(DF1), df2_core(DF1),
fsum_core(DF1, DF2), fsum_core(DF1, DF2),
@ -13210,8 +13217,8 @@ def data_overview():
# Modulation, cell type comparison # Modulation, cell type comparison
var_types = ['burst_fraction_burst_corr_base', 'cv_base'] var_types = ['burst_fraction_burst_corr_base', 'cv_base']
x_axis = ['cv_base', 'burst_fraction_burst_corr_base', ] x_axis = ['cv_base', 'burst_fraction_burst_corr_base', ]
var_item_names = ['Burst Fraction', 'CV$_{Base}$'] var_item_names = ['Burst Fraction', 'CV$'+basename()+'$']
x_axis_names = ['CV$_{Base}$', 'Burst Fraction', ] x_axis_names = ['CV$'+basename()+'$', 'Burst Fraction', ]
for v, var_type in enumerate(var_types): for v, var_type in enumerate(var_types):
ax = plt.subplot(grid_lower[0, v]) ax = plt.subplot(grid_lower[0, v])
@ -13241,7 +13248,7 @@ def data_overview():
var_item_names = ['Burst Fraction', 'Modulatoin'] var_item_names = ['Burst Fraction', 'Modulatoin']
x_axis = ['cv_base', 'burst_fraction_burst_corr_base'] x_axis = ['cv_base', 'burst_fraction_burst_corr_base']
x_axis_names = ['Burst Fraction$_{Base}$', 'Burst Fraction$_{Base}$'] # 'CV$_{Base}$' x_axis_names = ['Burst Fraction$'+basename()+'$', 'Burst Fraction$'+basename()+'$'] # 'CV$'+basename()+'$'
scores_here = ['coherence_', 'burst_fraction_burst_corr_stim'] # 'wo_burstcorr' scores_here = ['coherence_', 'burst_fraction_burst_corr_stim'] # 'wo_burstcorr'
for v, var_type in enumerate(var_types): for v, var_type in enumerate(var_types):
if scores_here[v] in frame_file.keys(): if scores_here[v] in frame_file.keys():
@ -14965,6 +14972,22 @@ def get_axis_on_full_matrix(full_matrix, stack_final):
def get_stack_one_quadrant(cell, cell_add, cells_save, path1, save_name_rev, direct_load=False, redo=False, def get_stack_one_quadrant(cell, cell_add, cells_save, path1, save_name_rev, direct_load=False, redo=False,
creation_time_update=False, size_update=True): creation_time_update=False, size_update=True):
stack_saved = get_stack_initial(cell, cell_add, cells_save, path1,
save_name_rev, direct_load=direct_load, redo=redo,
creation_time_update=creation_time_update, size_update=size_update)
stack_plot = change_model_from_csv_to_plots(stack_saved)
try:
stack_plot1 = RAM_norm(stack_plot, model_show=stack_saved)
except:
print('model thing2')
embed()
return stack_plot1, stack_saved
def get_stack_initial(cell, cell_add, cells_save, path1, save_name_rev, direct_load=False, redo=False,
creation_time_update=False, size_update=True):
if direct_load: if direct_load:
if '.pkl' in path1: if '.pkl' in path1:
model = pd.read_pickle(path1) # pd.read_pickle(path) model = pd.read_pickle(path1) # pd.read_pickle(path)
@ -14973,16 +14996,9 @@ def get_stack_one_quadrant(cell, cell_add, cells_save, path1, save_name_rev, dir
else: else:
model = load_model_susept(path1, cells_save, save_name_rev.split(r'/')[-1] + cell_add, redo=redo, model = load_model_susept(path1, cells_save, save_name_rev.split(r'/')[-1] + cell_add, redo=redo,
creation_time_update=creation_time_update, size_update=size_update) creation_time_update=creation_time_update, size_update=size_update)
#embed()
model_show = model[(model.cell == cell)] # & (model_cell.file_name == file)& (model_cell.power == power)] model_show = model[(model.cell == cell)] # & (model_cell.file_name == file)& (model_cell.power == power)]
return model_show
stack_plot = change_model_from_csv_to_plots(model_show)
try:
stack_plot1 = RAM_norm(stack_plot, model_show=model_show)
except:
print('model thing2')
embed()
return stack_plot1
def find_noise_names(b, base=''): def find_noise_names(b, base=''):
@ -15544,7 +15560,7 @@ def diagonal_xlabel_nothz():
def NLI_scorename2(): def NLI_scorename2():
return 'PNL$(f_{Base})$' return 'PNL$(f'+basename()+')$'
def NLI_name2(): def NLI_name2():
@ -15552,7 +15568,7 @@ def NLI_name2():
def NLI_scorename(): def NLI_scorename():
return 'NLI$(f_{Base})$' return 'NLI$(f'+basename()+')$'
def join_x(axts_all): def join_x(axts_all):
@ -20487,7 +20503,7 @@ def plt_show_nonlin_effect_didactic_final2(min=0.2, cells=[], single_waves=['_Si
colors_w, colors_wo, color_base, color_01, color_02, color_012 = colors_cocktailparty_all() colors_w, colors_wo, color_base, color_01, color_02, color_012 = colors_cocktailparty_all()
colors = [color_01, color_02, color_012] # 'blue' colors = [color_01, color_02, color_012] # 'blue'
labels = ['$f_{1}=%d$' % beat1 + '\,Hz', '$f_{2}=%d$' % beat2 + '\,Hz', labels = ['$f_{1}=%d$' % beat1 + '\,Hz', '$f_{2}=%d$' % beat2 + '\,Hz',
'$f_{1} + f_{2}=f_{Base}=%d$' % ( '$f_{1} + f_{2}=f'+basename()+'=%d$' % (
beat1 + beat2 - 1) + '\,Hz'] # small , '|B1-B2|' beat1 + beat2 - 1) + '\,Hz'] # small , '|B1-B2|'
add_texts = [nr, nr + 0.35, nr + 0.2] # [1.1,1.1,1.1] add_texts = [nr, nr + 0.35, nr + 0.2] # [1.1,1.1,1.1]
texts_left = [-7, -7, -7, -7] texts_left = [-7, -7, -7, -7]
@ -21141,7 +21157,7 @@ def labels_didactic():
def labels_didactic2(): def labels_didactic2():
labels = [r' $f_{Stim}$ ', '$2f_{Stim}$, $f_{Base}$ ', r' $3f_{Stim}$ ', ' $4f_{Stim}$, $2 f_{Base}$'] labels = [r' $f_{Stim}$ ', '$2f_{Stim}$, $f'+basename()+'$ ', r' $3f_{Stim}$ ', ' $4f_{Stim}$, $2 f'+basename()+'$']
return labels # $\cdot$ return labels # $\cdot$
@ -26157,7 +26173,7 @@ def plt_power_spectrum2(grid0, color01, color02, color012, color0, fr, results_d
[color02, color02, color01, color012, color012, color0, color0, color0122, ]] # color01_2, [color02, color02, color01, color012, color012, color0, color0, color0122, ]] # color01_2,
labels_all = [['DF2', 'DF2 H1'], labels_all = [['DF2', 'DF2 H1'],
[r'$\Delta \mathrm{f_{Female}}$', '', r'$\Delta \mathrm{f_{Intruder}}$', sum_intruder_core(), [r'$\Delta \mathrm{f_{Female}}$', '', r'$\Delta \mathrm{f_{Intruder}}$', sum_intruder_core(),
'', r'$\mathrm{f_{Base}}$', '', '', r'$\mathrm{f'+basename()+'}$', '',
r'$2|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$']] # '$|Intruder-Female|$', r'$2|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$']] # '$|Intruder-Female|$',
else: else:
p_arrays = [p02, p012] p_arrays = [p02, p012]
@ -26174,7 +26190,7 @@ def plt_power_spectrum2(grid0, color01, color02, color012, color0, fr, results_d
r'$|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$', r'$|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$',
'', '',
'', '',
'', ]] # r'$\mathrm{f_{Base}}$''$|Intruder-Female|$',r'$2|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$' '', ]] # r'$\mathrm{f'+basename()+'}$''$|Intruder-Female|$',r'$2|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$'
axs = plt_spectra_given(DF1, add_to, color0, color01, colors_all, female, fr, freqs_all, fs, grid0, labels_all, axs = plt_spectra_given(DF1, add_to, color0, color01, colors_all, female, fr, freqs_all, fs, grid0, labels_all,
@ -26207,7 +26223,7 @@ def plt_power_spectrum(grid0, color01, color02, color012, color0, fr, results_di
[color02, color02, color01, color012, color012, color0, color0, color0122, ]] # color01_2, [color02, color02, color01, color012, color012, color0, color0, color0122, ]] # color01_2,
labels_all = [['DF2', 'DF2 H1'], labels_all = [['DF2', 'DF2 H1'],
[r'$\Delta \mathrm{f_{Female}}$', '', r'$\Delta \mathrm{f_{Intruder}}$', sum_intruder_core(), [r'$\Delta \mathrm{f_{Female}}$', '', r'$\Delta \mathrm{f_{Intruder}}$', sum_intruder_core(),
'', r'$\mathrm{f_{Base}}$', '', '', r'$\mathrm{f'+basename()+'}$', '',
r'$2|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$']] # '$|Intruder-Female|$', r'$2|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$']] # '$|Intruder-Female|$',
else: else:
p_arrays = [p02, p012] p_arrays = [p02, p012]
@ -26225,7 +26241,7 @@ def plt_power_spectrum(grid0, color01, color02, color012, color0, fr, results_di
r'$|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$', r'$|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$',
'', '',
'', '',
'', ]] # r'$\mathrm{f_{Base}}$''$|Intruder-Female|$',r'$2|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$' '', ]] # r'$\mathrm{f'+basename()+'}$''$|Intruder-Female|$',r'$2|\Delta \mathrm{f_{Female}}|+|\Delta \mathrm{f_{Intruder}}|$'
axs = plt_spectra_given(DF1, add_to, color0, color01, colors_all, female, fr, freqs_all, fs, grid0, labels_all, axs = plt_spectra_given(DF1, add_to, color0, color01, colors_all, female, fr, freqs_all, fs, grid0, labels_all,
mult_val, p0, p_arrays, wierd_charing, xlim=xlim_ROC_talk2(), counter=counter, mult_val, p0, p_arrays, wierd_charing, xlim=xlim_ROC_talk2(), counter=counter,
@ -30766,8 +30782,8 @@ def plt_gain_area(ax1, c, cell, cells, colors_w, colors_wo, df1, df2, ff, frame_
ax.set_xlim(xlim) ax.set_xlim(xlim)
titles = [ titles = [
' $ \Delta \mathrm{f_{Female}} + \Delta \mathrm{f_{Intruder}} $\n' + '$ = \mathrm{f_{Base}}$' + r'$\numcircled{1}$ ', ' $ \Delta \mathrm{f_{Female}} + \Delta \mathrm{f_{Intruder}} $\n' + '$ = \mathrm{f'+basename()+'}$' + r'$\numcircled{1}$ ',
' $ \Delta \mathrm{f_{Female}} + \Delta \mathrm{f_{Intruder}} $\n ' + r' $\neq \mathrm{f_{Base}}$' + r'$\numcircled{2}$ '] ' $ \Delta \mathrm{f_{Female}} + \Delta \mathrm{f_{Intruder}} $\n ' + r' $\neq \mathrm{f'+basename()+'}$' + r'$\numcircled{2}$ ']
ax.set_title(titles[ff]) ax.set_title(titles[ff])
@ -33037,12 +33053,13 @@ def plt_peaks_several(freqs, p_arrays, axs_p, p0_means, fs, labels=None, j=1, co
add_log=2, add_log=2,
rots=None, several_peaks_nr=2, exact=True, text_extra=False, perc_peaksize=0.04, rel='rel', rots=None, several_peaks_nr=2, exact=True, text_extra=False, perc_peaksize=0.04, rel='rel',
alphas=None, alphas=None,
extend=False, ms=25, clip_on=False, several_peaks=True, alpha=1, log=''): extend=False, ms=25, clip_on=False, several_peaks=True, alpha=1, log='', add_not_log = 0):
df_passed = [] # , df_passed = [] # ,
p_passed = []
for ff, f in enumerate(range(len(freqs))): for ff, f in enumerate(range(len(freqs))):
add, add_text = get_add_for_several_peaks(add_log, df_passed, emb, exact, f, freqs, j, log, p_arrays, add, add_text = get_add_for_several_peaks(add_log, df_passed, emb, exact, f, freqs, j, log, p_arrays,
perc_peaksize, rel) perc_peaksize, rel, add_not_log = add_not_log)
if alphas is not None: if alphas is not None:
if len(alphas)> 0: if len(alphas)> 0:
@ -33098,16 +33115,17 @@ def plt_peaks_several(freqs, p_arrays, axs_p, p0_means, fs, labels=None, j=1, co
else: else:
label = labels[f] label = labels[f]
#embed() #embed()
plt_peaks(axs_p, p0_means, freqs[f], fs, fr_color=color, s=ms, f_scatter, p_scatter = plt_peaks(axs_p, p0_means, freqs[f], fs, fr_color=color, s=ms,
label=label, marker=marker, zorder=zorder, markeredgecolor=markeredgecolor, ha=ha, label=label, marker=marker, zorder=zorder, markeredgecolor=markeredgecolor, ha=ha,
several_peaks_nr=several_peaks_nr, limit=limit, rot=rot, text_left=text_left, add_text=add_text, several_peaks_nr=several_peaks_nr, limit=limit, rot=rot, text_left=text_left, add_text=add_text,
text_extra=text_extra, extend=extend, add=add, alpha=alpha, clip_on=clip_on, text_extra=text_extra, extend=extend, add=add, alpha=alpha, clip_on=clip_on,
several_peaks=several_peaks) several_peaks=several_peaks)
df_passed.append(int(freqs[f])) df_passed.append(int(freqs[f]))
p_passed.append(p_scatter)
return p_passed
def get_add_for_several_peaks(add_log, df_passed, emb, exact, f, freqs, j, log, p_arrays, perc, rel, add_not_log = 0, j_extra=False):
def get_add_for_several_peaks(add_log, df_passed, emb, exact, f, freqs, j, log, p_arrays, perc, rel, j_extra=False):
if rel == 'rel': if rel == 'rel':
peak_in_peaks = check_if_peak_occured(df_passed, exact, f, freqs) peak_in_peaks = check_if_peak_occured(df_passed, exact, f, freqs)
@ -33119,7 +33137,7 @@ def get_add_for_several_peaks(add_log, df_passed, emb, exact, f, freqs, j, log,
if log == 'log': if log == 'log':
add = (np.max(np.max(p_arrays)) * perc) + add_log * count add = (np.max(np.max(p_arrays)) * perc) + add_log * count
else: else:
add = (np.max(np.max(p_arrays)) * perc * count) add = (np.max(np.max(p_arrays)) * perc * count)+add_not_log*count
add_ext = 30 add_ext = 30
add_text = add + add_ext * count add_text = add + add_ext * count
@ -33463,7 +33481,7 @@ def plt_RAM_explained_single3():
# model part # model part
ax = plt.subplot(grid2[:]) ax = plt.subplot(grid2[:])
perc, im, stack_final = plt_model_big(ax) perc, im, stack_final, stack_saved = plt_model_big(ax)
set_clim_same([im], mats=[np.abs(stack_final)], lim_type='up', nr_clim='perc', clims='', percnr=95) set_clim_same([im], mats=[np.abs(stack_final)], lim_type='up', nr_clim='perc', clims='', percnr=95)
plt.subplots_adjust(hspace=0.85, wspace=0.25) plt.subplots_adjust(hspace=0.85, wspace=0.25)
@ -33495,7 +33513,7 @@ def plt_RAM_explained_single2(exponential=''):
# model part # model part
ax = plt.subplot(grid2[:]) ax = plt.subplot(grid2[:])
perc, im, stack_final = plt_model_big(ax) perc, im, stack_final, stack_saved = plt_model_big(ax)
set_clim_same([im], mats=[np.abs(stack_final)], lim_type='up', nr_clim='perc', clims='', percnr=95) set_clim_same([im], mats=[np.abs(stack_final)], lim_type='up', nr_clim='perc', clims='', percnr=95)
fig = plt.gcf() fig = plt.gcf()
fig.tag([fig.axes[1], fig.axes[-2]], xoffs=-5.5, yoffs=0.7) fig.tag([fig.axes[1], fig.axes[-2]], xoffs=-5.5, yoffs=0.7)
@ -33873,10 +33891,10 @@ def plt_model_small(ax, pos_rel=-0.07, ls='--', lw=0.5, cell='2012-07-03-ak-invi
# path = 'model_full_nfft_whole_p_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TS_1000000_a_fr_1__TrialsNr_1_2012-07-03-ak-invivo-1.csv' # path = 'model_full_nfft_whole_p_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TS_1000000_a_fr_1__TrialsNr_1_2012-07-03-ak-invivo-1.csv'
# #
stack_rev = get_stack_one_quadrant(cell, cell_add, cells_save, path_rev, save_name_rev, redo=False, stack_rev, stack_saved = get_stack_one_quadrant(cell, cell_add, cells_save, path_rev, save_name_rev, redo=False,
creation_time_update=True, size_update=True) # direct_load = True, creation_time_update=True, size_update=True) # direct_load = True,
stack = get_stack_one_quadrant(cell, cell_add, cells_save, path, save_name) # direct_load = True stack, stack_saved = get_stack_one_quadrant(cell, cell_add, cells_save, path, save_name) # direct_load = True
# embed() # embed()
full_matrix = create_full_matrix2(np.array(stack), np.array(stack_rev)) full_matrix = create_full_matrix2(np.array(stack), np.array(stack_rev))
stack_final = stack#get_axis_on_full_matrix(full_matrix, stack) stack_final = stack#get_axis_on_full_matrix(full_matrix, stack)
@ -33895,7 +33913,7 @@ def plt_model_small(ax, pos_rel=-0.07, ls='--', lw=0.5, cell='2012-07-03-ak-invi
return perc, im, stack_final return perc, im, stack_final
def plt_model_big(ax, pos_rel=-0.07, ls='--', lw=0.5, cell='2012-07-03-ak-invivo-1', colorx='black', colory='black'): def plt_model_big(ax, pos_rel=-0.07, ls='--', lw=0.5, cell='2012-07-03-ak-invivo-1', colorx='black', colory='black', lines = True):
cells_given = [cell] cells_given = [cell]
# doch das müsste jetzt mit denen hier funkionieren # doch das müsste jetzt mit denen hier funkionieren
@ -33913,16 +33931,17 @@ def plt_model_big(ax, pos_rel=-0.07, ls='--', lw=0.5, cell='2012-07-03-ak-invivo
# path = 'model_full_nfft_whole_p_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TS_1000000_a_fr_1__TrialsNr_1_2012-07-03-ak-invivo-1.csv' # path = 'model_full_nfft_whole_p_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TS_1000000_a_fr_1__TrialsNr_1_2012-07-03-ak-invivo-1.csv'
# #
stack_rev = get_stack_one_quadrant(cell, cell_add, cells_save, path_rev, save_name_rev, redo=False, stack_rev, stack_saved = get_stack_one_quadrant(cell, cell_add, cells_save, path_rev, save_name_rev, redo=False,
creation_time_update=True, size_update=True) # direct_load = True, creation_time_update=True, size_update=True) # direct_load = True,
stack = get_stack_one_quadrant(cell, cell_add, cells_save, path, save_name) # direct_load = True stack, stack_saved = get_stack_one_quadrant(cell, cell_add, cells_save, path, save_name, redo = True) # direct_load = True
# embed() #embed()
full_matrix = create_full_matrix2(np.array(stack), np.array(stack_rev)) full_matrix = create_full_matrix2(np.array(stack), np.array(stack_rev))
stack_final = get_axis_on_full_matrix(full_matrix, stack) stack_final = get_axis_on_full_matrix(full_matrix, stack)
stack_final, add_nonlin_title, resize_val = rescale_colorbar_and_values(stack_final,
add_nonlin_title='k') # , add_nonlin_title = 'k'
add_nonlin_title = '' add_nonlin_title = ''
stack_final, add_nonlin_title, resize_val = rescale_colorbar_and_values(stack_final,
add_nonlin_title= add_nonlin_title) # , add_nonlin_title = 'k'
im = plt_RAM_perc(ax, perc, np.abs(stack_final)) im = plt_RAM_perc(ax, perc, np.abs(stack_final))
set_clim_same([im], mats=[np.abs(stack_final)], lim_type='up', nr_clim='perc', clims='', percnr=95) set_clim_same([im], mats=[np.abs(stack_final)], lim_type='up', nr_clim='perc', clims='', percnr=95)
@ -33930,10 +33949,14 @@ def plt_model_big(ax, pos_rel=-0.07, ls='--', lw=0.5, cell='2012-07-03-ak-invivo
set_ylabel_arrow(ax, xpos=pos_rel, ypos=0.97, color=colory) set_ylabel_arrow(ax, xpos=pos_rel, ypos=0.97, color=colory)
cbar, left, bottom, width, height = colorbar_outside(ax, im, add=5, width=0.01) cbar, left, bottom, width, height = colorbar_outside(ax, im, add=5, width=0.01)
cbar.set_label(nonlin_title(add_nonlin_title=' [' + add_nonlin_title), rotation=90, labelpad=8) cbar.set_label(nonlin_title(add_nonlin_title=' [' + add_nonlin_title), rotation=90, labelpad=8)
ax.axhline(0, color='white', linewidth=lw, linestyle=ls) #embed()
ax.axvline(0, color='white', linewidth=lw, linestyle=ls) if lines:
ax.axhline(0, color='white', linewidth=lw, linestyle=ls)
ax.axvline(0, color='white', linewidth=lw, linestyle=ls)
return perc, im, stack_final stack_final = stack_final * resize_val
return perc, im, stack_final, stack_saved
def FI_curves_plot(contrast_labels, onset_function, onset_state, steady_function, steady_state, def FI_curves_plot(contrast_labels, onset_function, onset_state, steady_function, steady_state,
@ -33982,6 +34005,19 @@ def second_sine(f0, time_array, amp=1.25, phase=1):
return sine return sine
def circle_plot(ax, ax_prev, ws=None, lw=1.5):
if not ws:
ws = ws_nonlin_systems()
#rectangle = plt.Circle((0, 0), fc='black', ec="black")
rectangle = plt.Rectangle((0, 0), 20, 20, fc='black', ec="black")
ax.add_patch(rectangle)
#ax.set_title('$H\{s(t)\}$')
#embed()
ax.show_spines('')
def rectangle_plot(ax, ax_prev, ws=None, lw=1.5): def rectangle_plot(ax, ax_prev, ws=None, lw=1.5):
if not ws: if not ws:
ws = ws_nonlin_systems() ws = ws_nonlin_systems()
@ -34109,15 +34145,15 @@ def title_motivation():
r'$' + f_eod_name_core_rm() + '$ \& $f_{1}$', r'$' + f_eod_name_core_rm() + '$ \& $f_{1}$',
r'$' + f_eod_name_core_rm() + '$ \& $f_{2}$', r'$' + f_eod_name_core_rm() + '$ \& $f_{2}$',
r'$f' + f_eod_name_core_rm() + '$ \& $f_{1}$ \& $f_{2}$', r'$' + f_eod_name_core_rm() + '$ \& $f_{1}$ \& $f_{2}$',
[]] ##'receiver + ' + 'receiver + receiver []] ##'receiver + ' + 'receiver + receiver
return titles return titles
def rem_variable(rm_var = {'rm':True}): def rem_variable(rm_var = {'rm':True, 'size': 'small'}):
return rm_var return rm_var
def f_eod_name_rm(): def f_eod_name_rm():
return r'$f' + f_eod_name_core_rm() + '$' return r'$' + f_eod_name_core_rm() + '$'
def f_eod_name_core_rm(): def f_eod_name_core_rm():
rm_var = rem_variable() rm_var = rem_variable()
@ -34816,7 +34852,7 @@ def plt_fr_cv_base(ax0, ax_cv, ax_fr, add, frame_load,
frame_g = ptl_fr_cv(add[gg], alpha, annotate, ax0, cell_type_type, cell_types, frame_load, s, cv=y_axis, fr=x_axis, frame_g = ptl_fr_cv(add[gg], alpha, annotate, ax0, cell_type_type, cell_types, frame_load, s, cv=y_axis, fr=x_axis,
color_given=color_given) color_given=color_given)
add_namex = [cv_base_name(), cv_base_name_corr()] add_namex = [cv_base_name(), cv_base_name_corr()]
add_namey = [fbasename(), fbasecorrectedname()] add_namey = [fbasenamehz(), fbasecorrectedname()]
ax0.set_xlabel(add_namex[gg]) ax0.set_xlabel(add_namex[gg])
ax0.set_ylabel(add_namey[gg]) ax0.set_ylabel(add_namey[gg])
ax0.set_ylim(0, fr_lim) ax0.set_ylim(0, fr_lim)
@ -34833,14 +34869,42 @@ def fbasecorrectedname():
return val return val
def fbasenamehz():
rm_var = rem_variable()
if rm_var['rm']:
val = fbasename() + ' [Hz]'
else:
val = fbasename() + ' [Hz]'
return val
def fbasename(): def fbasename():
return r'$f' + basename() + '$'
def stimname():
rm_var = rem_variable() rm_var = rem_variable()
if rm_var['rm']: if rm_var['rm']:
val = r'$f\rm{_{Base}}$ [Hz]' val = r'\rm{_{Stim}}'
else: else:
val = r'$f_{Base}$ [Hz]' val = r'_{Stim}'
return val return val
def basename():
rm_var = rem_variable()
if rm_var['rm']:
val = r'\rm{_{Base}}'
else:
val = r'_{Base}'
return val
def basename_small():
rm_var = rem_variable()
if rm_var['rm']:
val = r'\rm{_{base}}'
else:
val = r'_{base}'
return val
def cv_base_name_corr(): def cv_base_name_corr():
rm_var = rem_variable() rm_var = rem_variable()
@ -34984,7 +35048,7 @@ def data_overview_punit(cell_types=[' P-unit']):
var_item_names = [var_it, var_it, var_it2] # ,var_it2]#['Response Modulation [Hz]',] var_item_names = [var_it, var_it, var_it2] # ,var_it2]#['Response Modulation [Hz]',]
var_types = [''] # ,'response_modulation','']#,'']#'response_modulation' var_types = [''] # ,'response_modulation','']#,'']#'response_modulation'
max_x = max_xs[c] max_x = max_xs[c]
x_axis_names = [x_axis_talk(), 'CV$_{stim}$', 'Response Modulation [Hz]'] # $_{Base}$,'Fr$_{Base}$',] x_axis_names = [x_axis_talk(), 'CV$_{stim}$', 'Response Modulation [Hz]'] # $'+basename()+'$,'Fr$'+basename()+'$',]
score = scores[c] score = scores[c]
scores_here = [score, score, score] # ,score] scores_here = [score, score, score] # ,score]
@ -35392,7 +35456,7 @@ def cellscompar2(cells_plot2, amp_desired=[5, 20]): # [0, 1.1]
var_item_names = [var_it, var_it] # ,var_it2]#['Response Modulation [Hz]',] var_item_names = [var_it, var_it] # ,var_it2]#['Response Modulation [Hz]',]
var_types = [''] # ,'response_modulation','']#,'']#'response_modulation' var_types = [''] # ,'response_modulation','']#,'']#'response_modulation'
max_x = max_xs[c] max_x = max_xs[c]
x_axis_names = [x_axis_talk()]#, 'CV$_{stim}$', 'Response Modulation [Hz]'] # $_{Base}$,'Fr$_{Base}$',] x_axis_names = [x_axis_talk()]#, 'CV$_{stim}$', 'Response Modulation [Hz]'] # $'+basename()+'$,'Fr$'+basename()+'$',]
score = scores[c] score = scores[c]
scores_here = [score]#, score_burst_corr, score] # ,score] scores_here = [score]#, score_burst_corr, score] # ,score]
score_name = ['Nonlinearity($f_{BaseCorr}$)']#nonlinearity_name_talk()]#, NLI_name2(),NLI_scorename2()] # NLI_scorename()] # 'Fr/Med''Perc99/Med' score_name = ['Nonlinearity($f_{BaseCorr}$)']#nonlinearity_name_talk()]#, NLI_name2(),NLI_scorename2()] # NLI_scorename()] # 'Fr/Med''Perc99/Med'
@ -35619,7 +35683,7 @@ def cellscompar(amp_desired=[5, 20], xlim=[],
var_item_names = [var_it, var_it] # ,var_it2]#['Response Modulation [Hz]',] var_item_names = [var_it, var_it] # ,var_it2]#['Response Modulation [Hz]',]
var_types = [''] # ,'response_modulation','']#,'']#'response_modulation' var_types = [''] # ,'response_modulation','']#,'']#'response_modulation'
max_x = max_xs[c] max_x = max_xs[c]
x_axis_names = [x_axis_talk(), 'CV$_{stim}$', 'Response Modulation [Hz]'] # $_{Base}$,'Fr$_{Base}$',] x_axis_names = [x_axis_talk(), 'CV$_{stim}$', 'Response Modulation [Hz]'] # $'+basename()+'$,'Fr$'+basename()+'$',]
# score = scores[0] # score = scores[0]
score = scores[c] score = scores[c]
scores_here = [score, score, score] # ,score] scores_here = [score, score, score] # ,score]
@ -35684,4 +35748,28 @@ def cellscompar(amp_desired=[5, 20], xlim=[],
def default_lw_RAM_talks(): def default_lw_RAM_talks():
plt.rcParams['lines.linewidth'] = 3 plt.rcParams['lines.linewidth'] = 3
#plt.rcParams['axes.linewidth'] = 22 #plt.rcParams['axes.linewidth'] = 22
def diff_label():
return '$|\Delta f_{1} - \Delta f_{2}|$'
def two_deltaf2_label():
return '$2|\Delta f_{2}|$'
def two_deltaf1_label():
return '$2|\Delta f_{1}|$'
def sum_label():
return '$|\Delta f_{1} + \Delta f_{2}|$'
def deltaf2_label():
return '$|\Delta f_{2}|$'
def deltaf1_label():
return '$|\Delta f_{1}|$'