updated data overview

This commit is contained in:
saschuta 2024-02-29 14:26:25 +01:00
parent 15d372dd90
commit d40b6e14a8
12 changed files with 2432 additions and 38 deletions

1977
data_overview_mod.csv Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

BIN
data_overview_mod.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -69,7 +69,8 @@ def data_overview3():
#####################################################
#grid_lower_lower = gridspec.GridSpecFromSubplotSpec(1, 2, grid0[1], wspace = 0.5, hspace=0.55)#, height_ratios = [1,3]
cell_types = [' Ampullary', ' P-unit']#, ' P-unit',]#' P-unit',
cell_types = [' P-unit',' Ampullary', ]#, ' P-unit',]#' P-unit',
cell_types_name = ['P-units','Ampullary cells',]
species = ' Apteronotus leptorhynchus'
burst_corr_reset = 'response_modulation'
burst_fraction = [1000, 1000]# 50, # ,1,1]
@ -86,7 +87,7 @@ def data_overview3():
] # + '_diagonal_proj'
cell_types_name = ['Ampullary cells','P-units']
for c, cell_type_here in enumerate(cell_types):
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='range', species=species)
@ -143,9 +144,14 @@ def data_overview3():
ymin = 0
xmin = 0
if (' P-unit' in cell_type_here) & (x_axis[v] == 'cv_base' ):
xlimk = [0, 1.7]
else:
xlimk = None
cmap, _, y_axis = plt_burst_modulation_hists(axk, axl, var_item_names[v], axs, cell_type_here,
x_axis[v], frame_file, max_val, scores_here[v],
burst_fraction=burst_fraction[c], ha = 'right', x_pos = 1, xmin = xmin, ymin = ymin, burst_fraction_reset = burst_corr_reset,var_item=var_type)
burst_fraction=burst_fraction[c],xlim = xlimk, ha = 'right', x_pos = 1, xmin = xmin, ymin = ymin, burst_fraction_reset = burst_corr_reset,var_item=var_type)
if v == 0:
colors = colors_overview()
@ -155,8 +161,10 @@ def data_overview3():
axl.show_spines('')
axs.set_ylabel(score_name[v])
axs.set_xlabel(x_axis_names[v])
if (cell_type_here == ' P-unit') & (x_axis[v] == 'cv_base' ):
axs.set_xlim(0,1.7)
if (' P-unit' in cell_type_here) & (x_axis[v] == 'cv_base' ):
axs.set_xlim(xlimk)
axk.set_xlim(xlimk)
#embed()
#remove_yticks(axl)
if log:

View File

@ -5,7 +5,7 @@ import numpy as np
import pandas as pd
from plotstyle import plot_style, spines_params
from utils_suseptibility import model_sheme_in_one
from utils_all import default_figsize, model_sheme_split, remove_yticks, save_visualization
from utils_all import default_figsize, model_sheme_split2, remove_yticks, save_visualization
#from utils_all import default_settings, resave_small_files
#from plt_RAM import model_and_data, model_and_data_sheme, model_and_data_vertical2
import matplotlib.gridspec as gridspec
@ -18,7 +18,7 @@ def flowchart():
grid_orig = gridspec.GridSpec(1, 1, wspace=0.15, bottom=0.07,
hspace=0.1, left=0.05, right=0.96,
top=0.9) # , height_ratios = [0.4,3]
model_sheme_split(grid_orig[0]) # grid_sheme grid_lower[3]
model_sheme_split2(grid_orig[0]) # grid_sheme grid_lower[3]
# model_sheme_only(grid[2])
save_visualization()
#fig.savefig()

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

@ -47,8 +47,8 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
cells_all = [good_data[0]]
plot_style()
default_figsize(column=2, length=4.75) # 0.75
grid = gridspec.GridSpec(3, 4, wspace=0.85, bottom=0.07,
default_figsize(column=2, length=3.25) #4.75 0.75
grid = gridspec.GridSpec(2, 4, wspace=0.85, bottom=0.07,
hspace=0.18, left=0.09, right=0.93, top=0.94)
a = 0
@ -85,7 +85,7 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
#################################
# data cells
# embed()
grid_data = gridspec.GridSpecFromSubplotSpec(1, 1, grid[0, 1],
grid_data = gridspec.GridSpecFromSubplotSpec(1, 1, grid[0, 0],
hspace=hs)
#ypos_x_modelanddata()
@ -129,12 +129,12 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
'calc_RAM_model-2__nfft_whole_power_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_11_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
'calc_RAM_model-2__nfft_whole_power_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_500000_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
'calc_RAM_model-2__nfft_whole_power_1_afe_0.009_RAM_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_11_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
'calc_RAM_model-2__nfft_whole_power_1_afe_0.009_RAM_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_500000_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
]
#'calc_RAM_model-2__nfft_whole_power_1_afe_0.009_RAM_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_11_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
#'calc_RAM_model-2__nfft_whole_power_1_afe_0.009_RAM_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_500000_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
nrs_s = [2, 3, 6, 7, 10, 11]
nrs_s = [2, 3, 6, 7]#, 10, 11
#embed()
tr_name = trial_nr/1000000
if tr_name == 1:
@ -142,8 +142,9 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
titles = ['Model\n$N=11$ \n $c=1\,\%$', 'Model\n$N=%s $' % (tr_name) +'\,million \n $c=1\,\%$',
'Model\,('+noise_name().lower()+')' + '\n' + '$N=11$\n $c=0\,\%$',
'Model\,('+noise_name().lower()+')' + '\n' + '$N=%s$' % (tr_name) + '\,million \n $c=0\,\%$',
'Model\,('+noise_name().lower()+')' + '\n' + '$N=11$\n $c=1\,\%$',
'Model\,('+noise_name().lower()+')' + '\n' + '$N=%s$' % (tr_name) + '\,million\n $c=1\,\%$ ']#%
]#%
#'Model\,('+noise_name().lower()+')' + '\n' + '$N=11$\n $c=1\,\%$',
# 'Model\,('+noise_name().lower()+')' + '\n' + '$N=%s$' % (tr_name) + '\,million\n $c=1\,\%$ '
ax_model = []
for s, sav_name in enumerate(save_names):
@ -205,15 +206,15 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
#################################################
# Flowcharts
var_types = ['', 'additiv_cv_adapt_factor_scaled', 'additiv_cv_adapt_factor_scaled']
var_types = ['', 'additiv_cv_adapt_factor_scaled']#'additiv_cv_adapt_factor_scaled',
##additiv_cv_adapt_factor_scaled
a_fes = [0.009, 0, 0.009]
eod_fe = [750, 750, 750]
a_fes = [0.009, 0]#, 0.009
eod_fe = [750, 750]#, 750
ylim = [-0.5, 0.5]
c_sigs = [0, 0.9, 0.9]
grid_left = [[], grid[1, 0], grid[2, 0]]
c_sigs = [0, 0.9]#, 0.9
grid_left = [[], grid[1, 0]]#, grid[2, 0]
ax_ams = []
for g, grid_here in enumerate([grid[0, 0], grid[1, 0], grid[2, 0]]):
for g, grid_here in enumerate([grid[0, 1], grid[1, 1]]):#, grid[2, 0]
grid_lowpass = gridspec.GridSpecFromSubplotSpec(4, 1,
subplot_spec=grid_here, hspace=0.3,
height_ratios=[1, 1,1, 0.1])
@ -229,7 +230,7 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
noise_final_c, spike_times, stimulus, stimulus_here, time, v_dent_output, v_mem_output, frame = get_flowchart_params(
a_fes, a_fr, g, c_sigs[g], cell, deltat, eod_fr, model_params, stimulus_length, v_offset, var_types,
eod_fe=eod_fe)
# embed()
if (len(np.unique(frame.RAM_afe)) > 1) & (len(np.unique(frame.RAM_noise)) > 1):
grid_lowpass2 = gridspec.GridSpecFromSubplotSpec(4, 1,
@ -307,7 +308,7 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
ax_n, ff, pp, ff_am, pp_am = plot_lowpass2([grid_lowpass[2]], time, noise_final_c, deltat, eod_fr,
extract=False, color1='grey', lw=1)
remove_yticks(ax_n)
if g == 2:
if g == 1:
ax_n.set_xlabel('Time [ms]', labelpad = -0.5)
else:
remove_xticks(ax_n)
@ -330,25 +331,26 @@ def model_and_data2(eod_metrice = False, width=0.005, nffts=['whole'], powers=[1
ax_external.text(1, 1, 'RAM', ha='right', color='red', transform=ax_external.transAxes)
ax_intrinsic.text(start_pos_modeldata(), 1, signal_component_name(), ha='right', color='purple',
transform=ax_intrinsic.transAxes)
#embed()
set_same_ylim(ax_ams, up='up')
# embed()
axes = np.concatenate([ax_data, ax_model])
axes = [ax_ams[0], axes[0], axes[1], axes[2], ax_ams[1], axes[3], axes[4], ax_ams[2], axes[5],
axes[6], ]
axd1 = plt.subplot(grid[1, 1])
axd2 = plt.subplot(grid[2, 1])
axes = [ax_ams[0], axes[1], axes[2], ax_ams[1], axes[3], axes[4], ]#ax_ams[2], axes[5], axes[6],
#axd1 = plt.subplot(grid[1, 1])
#axd2 = plt.subplot(grid[2, 1])
#ax_data.extend([,])
axd1.show_spines('')
axd2.show_spines('')
#axd1.show_spines('')
#axd2.show_spines('')
#embed()
#axes = [[ax_ams[0],ax_data[0],axes[2], axes[3]],[ax_ams[1],axd1,axes[4], axes[5]],[axd2,axd2, axes[6], axes[7]]]
fig.tag([axes[0:4]], xoffs=-3, yoffs=1.6) # ax_ams[3],
fig.tag([[axes[4]]], xoffs=-3, yoffs=1.6, minor_index=0) # ax_ams[3],
fig.tag([axes[5:7]], xoffs=-3, yoffs=1.6, major_index = 1, minor_index = 2) # ax_ams[3],
fig.tag([[axes[7]]], xoffs=-3, yoffs=1.6, major_index=2,minor_index=0) # ax_ams[3],
fig.tag([axes[8::]], xoffs=-3, yoffs=1.6, major_index=2, minor_index=2) # ax_ams[3],
fig.tag([ax_data], xoffs=-3, yoffs=1.6) # ax_ams[3],
fig.tag([axes[0:3]], xoffs=-3, yoffs=1.6) # ax_ams[3],
#fig.tag([[axes[4]]], xoffs=-3, yoffs=1.6, minor_index=0) # ax_ams[3],
fig.tag([axes[3:6]], xoffs=-3, yoffs=1.6) #, major_index = 1, minor_index = 2 ax_ams[3],
#fig.tag([[axes[7]]], xoffs=-3, yoffs=1.6, major_index=2,minor_index=0) # ax_ams[3],
#fig.tag([axes[8::]], xoffs=-3, yoffs=1.6, major_index=2, minor_index=2) # ax_ams[3],
#fig.tag([axes[7::]], xoffs=-3, yoffs=1.6) # ax_ams[3],
#fig.tag([ax_ams[0],ax_data[0],axes[2], axes[3]], xoffs=-3, yoffs=1.6)#ax_ams[3],

View File

@ -623,8 +623,9 @@ The nonlinearity in this work were found in low-CV P-units. For this nonlinear e
%\subsubsection{A heterogeneous readout is required to cover all female-intruder combinations}
A heterogeneous readout might be not only physiologically plausible but also required since nonlinear effects depending on cell property \fbase{} and not on stimulus properties might be not behaviorally relevant. Nonlinear effects might facilitate the encoding of faint signals during a three fish setting, the electrosensory cocktail party. The EOD frequencies of the encoutered three fish would be drawn from the EOD frequency distribution of these fish and a stable faint signal detection would require a response irrespective of the individual EOD frequencies. In this work, nonlinear effects were always found only for specific frequencies in relation to \fbase{}, corresponding to findings from previous literature \citealp{Voronenko2017}. Weather integrating from a heterogeneous population with different \fbasesolid{} (50--450\,Hz, \citealp{Grewe2017, Hladnik2023}) would cover the behaviorally relevant range in the electrosensory cocktail party should be addressed in further studies.
A heterogeneous readout might be not only physiologically plausible but also required since nonlinear effects depending on cell property \fbase{} and not on stimulus properties might be not behaviorally relevant. Nonlinear effects might facilitate the encoding of faint signals during a three fish setting, the electrosensory cocktail party. The EOD frequencies of the encoutered three fish would be drawn from the EOD frequency distribution of these fish and a stable faint signal detection would require a response irrespective of the individual EOD frequencies. Weather integrating from a heterogeneous population with different \fbasesolid{} (50--450\,Hz, \citealp{Grewe2017, Hladnik2023}) would cover the behaviorally relevant range in the electrosensory cocktail party should be addressed in further studies.
%In this work, nonlinear effects were always found only for specific frequencies in relation to \fbase{}, corresponding to findings from previous literature \citealp{Voronenko2017}.
%Only a heterogeneous population could cover the whole stimulus space required during the electrosensory cocktail party.
%If pyramidal cells would integrate only from P-units with the same mean baseline firing rate \fbasesolid{} not all fish encounters, relevant for the context of the electrosensory cocktail party, could be covered.
@ -642,7 +643,9 @@ A heterogeneous readout might be not only physiologically plausible but also req
%These low-frequency modulations of the amplitude modulation are
\subsection{Encoding of secondary envelopes}%($\n{}=49$) Whether this population of envelope encoders was in addition bursty was not addressed in the corresponding study
The RAM stimulus used in this work is an approximation of the three-fish scenario, where the two generated beats are often slowly modulated at the difference between the two beat frequencies \bdiff{}, known as secondary or social envelope \citealp{Stamper2012Envelope}. In previous works it was demonstrated that low-frequency secondary envelopes are extracted not in P-units but downstream of them in the ELL \citealp{Middleton2006} utilizing threshold nonlinear response curves of the involved neuron \citealp{Middleton2007}. Based on our work we would predict that only a small class of cells, with very low CVs, should encode the social envolope at the difference frequency. The sample in that previous work \citealp{Middleton2007} was limited, and if it did not contain cells as low CVs as mentioned here, this might be in line with the findings that P-units were determined as no envelope encoders.
The RAM stimulus used in this work is an approximation of the three-fish scenario, where the two generated beats are often slowly modulated at the difference between the two beat frequencies \bdiff{}, known as secondary or social envelope \citealp{Stamper2012Envelope}.
In previous works it was demonstrated that low-frequency secondary envelopes are extracted not in P-units but downstream of them in the ELL \citealp{Middleton2006} utilizing threshold nonlinear response curves of the involved neuron \citealp{Middleton2007}. Based on our work we would predict that only a small class of cells, with very low CVs, should encode the social envelope at the difference frequency. If the sample in that previous work \citealp{Middleton2007} did not contain low CVs cells, This could explain the conclusion that P-units were identified not as envelope encoders.
On the other hand in previous literature the encoding of social envelopes was attributed to a subpopulation of P-units with strong nonlinearities, low firing rates and high CVs \citealp{Savard2011}. These findings are in contrast to the findings in the previously mentioned work \citealp{Middleton2007} and on first glance also to our findings. The missing link, that has not been considered in this work, might be bursting of P-units, the repeated firing of spikes after one EOD period interleaved with quiescence (unpublished work). Bursting was not explicitly addressed in the work \citealp{Savard2011}, still the high CVs of the envelope encoding P-units indicate a higher rate of bursting. How bursts influence the second-order susceptibility of P-units will be addressed in following works (in preparation).

View File

@ -1678,7 +1678,6 @@ def do_withenoise_stimulus(deltat, eod_fr, stimulus_length, a_fe=0.2):
stimulus_here[stimulus_here < 0] = 0
return stimulus_here
def model_sheme_split(grid_sheme_orig, time_transform=1000, ws=0.1, nfft=4096 * 6, stimulus_length=5, fft_type='mppsd',
a_fr=1, a_fe=0.2,
v_exp=1, exp_tau=0.1, counter=0, counterp=0, color='darkgrey', log=True,
@ -1727,6 +1726,411 @@ def model_sheme_split(grid_sheme_orig, time_transform=1000, ws=0.1, nfft=4096 *
# ult_settings(column=2, length=5)
# # fdefaig = plt.figure()
# for mult_nr in range(len(eod_fe)):
c_sigs = [1, 1, 1, 0.9]
c_sigs = [0, 0, 0, 0.9]
var_types = ['', '', '', 'additiv_cv_adapt_factor_scaled'] # ''#'additiv_cv_adapt_factor_scaled'
# 'additiv_visual_d_4_scaled', '']
# a_fes =
nrs = [1, 2, 3, 4]
a_fes = [0, 0.02, 0.1, 0]#alpha\alpha
titles = ['Baseline', r'Contrast$\,=2\,\%$', r'Contrast$\,=20\,\%$', noise_name()]
#########################################################################################
# first row for the stimulus, and then three cols for the sheme, and the power 1 and power 3
grid0 = gridspec.GridSpecFromSubplotSpec(1, len(a_fes) + 1, subplot_spec=grid_sheme_orig,
width_ratios=[1.5, 2, 2, 2, 2], wspace=0.45)
#####################################################
# Grid for the sheme
try:
grid_sheme = gridspec.GridSpecFromSubplotSpec(6, 1,
subplot_spec=grid0[0], wspace=0.2, hspace=0.9,
height_ratios=[1, 1, 1, 1, 0, 1]) # 0.95
except:
print('grid thing1')
embed()
axshemes = []
axsheme = plt.subplot(grid_sheme[0])
axshemes.append(axsheme)
plot_sheme_nonlinearity(axsheme, color_p3, color_p1, color_diagonal=color_diagonal)
axsheme = plt.subplot(grid_sheme[1])
axshemes.append(axsheme)
# axsheme.set_aspect('equal')
plot_sheme_lowpass(axsheme)
axsheme = plt.subplot(grid_sheme[2])
axshemes.append(axsheme)
plot_sheme_noise(axsheme)
axsheme = plt.subplot(grid_sheme[3])
axshemes.append(axsheme)
# axsheme.set_aspect('equal')
plot_sheme_IF(axsheme, exp_tau, v_exp)
###################################################################################
lw = 0.5
xlim = 0.065
axps = []
axps_lowpass = []
axps_stimulus = []
pps = []
pps_lowpass = []
pps_stimulus = []
ax_am_sp_s = []
ax_ams = []
ax_noise = []
colors_chosen = []
counter_g = 0
mult_nr = 0
# A grid for a single POWER column
axt_stims = []
for c, c_sig in enumerate(c_sigs):
a_fe = a_fes[c]
######################################
# colors = ['grey', 'grey', 'grey', 'grey']
# embed()
grid_power_col = gridspec.GridSpecFromSubplotSpec(6, 1,
subplot_spec=grid0[nrs[counter_here]], wspace=0.45,
hspace=0.5, height_ratios=[1, 1, 1, 1, 0, 1])
noise_final_c, spike_times, stimulus, stimulus_here, time, v_dent_output, v_mem_output,frame = get_flowchart_params(
a_fes, a_fr, c, c_sig, cell, deltat, eod_fr, model_params, stimulus_length, v_offset, var_types, eod_fe,
color_p1, color_p3, mult_nr=mult_nr, load_name=load_name, exp_tau=exp_tau, v_exp=v_exp)
print(len(stimulus_here))
##############################################
# titles = [titles[1]]
# for g, stimulus_here in enumerate([stimuli[1]]):
add = 0
color = colors[counter_here]
# FIRST Row: Rectified stimulus
plot_point = [[], [], [], 'yes']
# counter, ax_rec[counter_here], ff, pp, axp = plot_rec_stimulus(eod_fr,grid_lowpass, time_transform, stimulus_here, color, color,
# time, counter, eod_fr, titles, g, deltat,
# fft_type, nfft, log, counterp,shift = shift, delta_f = delta_f, plot_point = plot_point[counter_here], lw = lw, xlim = xlim)
power_extra = False
wr2 = [1, 1.2]
if power_extra:
wr = [1, 1.2]
col = 2
else:
col = 1
wr = [1]
####################################################################
# stimulus
grid_lowpass = gridspec.GridSpecFromSubplotSpec(1, col,
subplot_spec=grid_power_col[0], wspace=ws, hspace=1.3,
width_ratios=wr)
ax_rec[counter_here], ff, pp, ff_am, pp_am = plot_lowpass2(grid_lowpass, time, stimulus_here, deltat, eod_fr,
shift, nfft, time_transform, color, fft_type, lw=lw,
xlim=xlim)
# ax_rec[counter.]
ax_rec[counter_here].show_spines('b')
remove_xticks(ax_rec[counter_here])
axt_stims.append(ax_rec[counter_here])
pps_stimulus.append(pp_am)
if power_extra:
axp_p2 = plt.subplot(grid_lowpass[1])
axp_p2.set_xticks_blank()
axps_stimulus.append(axp)
colors_chosen.append(color)
# if counter_here == 0:
# ax_rec[counter_here].text(-7, 0, '0', color='black', ha='center', va='center')
# if colorful_title:
# rainbow_title(fig, ax_rec[counter_here], titles[g], add_pos[g], color_add_pos[g])
# else:#add_pos[g]
#embed()
ax_rec[counter_here].text(0, 0.935, titles[c] + '\n'+r'$\rm{CV}=%s$' %(
np.round(np.std(np.diff(spike_times)) / np.mean(np.diff(spike_times)), 2)) + '\n$f_{Base}=%s$' %(
int(np.round(1 / np.mean(np.diff(spike_times))))) + '\,Hz', transform=ax_rec[counter_here].transAxes,
va='bottom') # verticalalignment='right',
# And plot correspoding sheme
# if g == 0:
# REMAINING Rows: dendridic filter / LIF /EIF stimulus
# for ee, exponential in enumerate(exponentials):
# model
# v_offset, model_params, load_name= implement_three_core(cell,amp_frame, titles, g, cell_nr = cell_nr)
# for hard coding the offset here i check the change of the baseline
# if (ee == 0):
# SECOND Row: Dendridic Low pass filter
plot_point = [[], [], [], 'yes']
# ax_low[counter_here]
grid_lowpass = gridspec.GridSpecFromSubplotSpec(1, col,
subplot_spec=grid_power_col[1], wspace=ws, hspace=1.3,
width_ratios=wr)
axt2, ff, pp, ff_am, pp_am = plot_lowpass2(grid_lowpass, time, v_dent_output, deltat, eod_fr, shift, nfft,
time_transform, color, fft_type, lw=lw, xlim=xlim)
axt2.show_spines('b')
remove_xticks(axt2)
axt_stims.append(axt2)
pps_stimulus.append(pp_am)
if power_extra:
axp_p2 = plt.subplot(grid_lowpass[1])
axp_p2.set_xticks_blank()
axps_stimulus.append(axp_p2)
colors_chosen.append(color)
# if counter_here == 0:
# ax_low[counter_here].text(-7, 0, '0', color='black', ha='center', va='center')
####################################################################
# spikes
# embed()
grid_lowpass = gridspec.GridSpecFromSubplotSpec(1, 1,
subplot_spec=grid_power_col[-3], wspace=ws, hspace=1.3,
) # width_ratios=wr2
# add = adds[g][2+ee]
plot_point = ['yes', 'yes', [], 'yes']
# embed()
axt_spikes, axp_IF, ff, pp, axp_s, pp_s = plot_spikes(grid_lowpass, time_transform, v_mem_output, time, color,
spike_times, shift, deltat, fft_type, nfft, eod_fr,
xlim=xlim,
counter_here=counter_here, psd=False) # , add = add
grid_lowpass_p = gridspec.GridSpecFromSubplotSpec(1, 1,
subplot_spec=grid_power_col[-1], wspace=ws, hspace=1.3,
) # width_ratios=wr2
axp_s = plt.subplot(grid_lowpass_p[0])
in_omega = False
if in_omega:
axp_s.set_xlabel('$\omega/\omega_1$')
else:
arrow = True
name = r'$f/f_{EOD}$'#r'$\frac{f}{f_{EOD}}$'
if arrow:
set_xlabel_arrow_core(axp_s, name )
#axp_s.text(1.05, -0.25, name, ha='center', va='center',
# transform=axp_s.transAxes)
axp_s.arrow_spines('b')
else:
axp_s.set_xlabel(name)
# pps.append(pp)
# axps.append(axp_IF)
axps.append(axp_s)
pps.append(pp_s)
# colors_chosen.append(color)
colors_chosen.append('black')
# if ee == 0:
axt_spikes.show_spines('b')
axt_IF1.append(axt_spikes)
# axt_stims,axt_IF1
# else:
# axt_IF2.append(axt_IF)
# if g == 0:
################################
# plot noise split
noise = np.random.randn(len(stimulus))
# noise *= noise_strength / np.sqrt(deltat)
noise_strength = model_params["noise_strength"] # .iloc[0]
# if 'd_right' in load_name:
noise_length = len(stimulus)
# noise_final = np.random.randn(noise_length) # len(stimulus)
# noise_strength_new = np.sqrt(noise_strength * 2)
# noise_final *= noise_strength_new / np.sqrt(deltat) # 0.05370289258320868 0.0015532069917408744
no_noise = False
if no_noise:
c_noise = c_sig
noise_final_c = np.random.randn(noise_length) # len(stimulus)
variance = (noise_strength * c_noise) * 2 / deltat
noise_strength_new = np.sqrt(variance)
noise_final_c *= noise_strength_new # 0.0015532069917408744
grid_lowpass = gridspec.GridSpecFromSubplotSpec(1, col, width_ratios=wr,
subplot_spec=grid_power_col[2], wspace=ws,
hspace=1.45)
ax_n, ff, pp, ff_am, pp_am = plot_lowpass2(grid_lowpass, time, noise_final_c, deltat, eod_fr, shift, nfft,
time_transform, color, fft_type, extract=False, lw=lw, xlim=xlim)
ax_n.show_spines('b')
ax_noise.append(ax_n)
remove_xticks(ax_n)
pps_lowpass.append(pp)
if power_extra:
axp_p2 = plt.subplot(grid_lowpass[1])
axp_p2.set_xticks_blank()
axps_lowpass.append(axp_p2)
# pps_stimulus.append(pp)
# axps_stimulus.append(axp_p2)
# axps.append(axp_p2)
# pps.append(pp)
counter_g += 1
# embed()
# plt.show()
counter_here += 1
# embed()
# embed()
devide = np.max(np.max(pps))
# plot_points = np.array([[], [], [], 'yes',
# [], [], [], 'yes'
# ,'yes','yes',[],'yes'
# ,'yes','yes',[],'yes'])
# von oben nach unten von links nach rechts
# plot psd with shared log lim
####################################
# cut first parts
# because otherwise there is a dip at the beginning and thats a problem for the range thing
ff, pps_stimulus, pps_lowpass, pps = cut_first_parts(ff, pps_stimulus, pps_lowpass, pps, ll=0)
# here I calculate the log and do the same range for all power spectra
# this is kind of complicated but some cells spike even withouth thresholding and we want to keep their noise floor down
# not to see the peaks in the noise
# pp3_stimulus = create_same_max(np.concatenate([pps_stimulus, pps_lowpass]), same=True)
if power_extra:
pp3_stimulus = create_same_max(pps_stimulus, same=True)
pp3_noise = create_same_max(pps_lowpass, same=True)
pps3 = create_same_max(pps, same=True)
# pp3_stimulus = np.concatenate(pp3_stimulus)
# axps_stimulus = np.concatenate([axps_stimulus,axps_lowpass])
# pp3_stimulus = create_same_range_ps(axps, pps_stimulus)
pp3 = create_same_range(np.concatenate([pp3_stimulus, pp3_noise, pps3]))
axps_stimulus = np.concatenate([axps_stimulus, axps_lowpass, axps])
else:
axps_stimulus = axps
pp3 = pps
# embed()
# pp3[4] = np.array([float('nan')]*len(pp3[4]))
# embed()
# ok i do this because most cells dont spike, but they are not nice to show because of the very high offset between persynaptci potenatil and spike
# there are only few cells where the distance is not so high and this cells spike occationally but very randomly still we dont wanna se their power specturm
# therefore we dont show it
colors = [color_diagonal, color_p1, color_p1, color_p3,
color_diagonal, color_p1, color_p1, color_p3,
color_diagonal, color_p1, color_p1, color_p3, ]
plot_points = ['yes', 'yes', 'yes', 'yes',
'yes', 'yes', 'yes', 'yes',
'yes', 'yes', 'yes', 'yes',
'yes', 'yes', 'yes', 'yes', ]
plot_points = [[], 'yes', [], 'yes',
[], 'yes', [], 'yes',
[], 'yes', [], 'yes',
[], 'yes', [], 'yes', ]
axt_stims[0].get_shared_y_axes().join(*axt_stims)
axt_IF1[0].get_shared_y_axes().join(*axt_IF1)
ax_noise[0].get_shared_y_axes().join(*ax_noise)
set_same_ylim(ax_noise)
# embed()
ax = np.transpose([axt_stims[0::2], axt_stims[1::2],ax_noise, axt_IF1, axps_stimulus])
fig = plt.gcf()
#fig.tag(ax, xoffs=-3.5, yoffs = 1.5)
nr = 1.7#2#.24
tag2(fig, axshemes, xoffs=-3.5, yoffs=5.5)
tag2(fig, np.transpose(ax), xoffs=-3.5)#yoffs = [5.5,nr,nr,nr,nr-0.2]
# get_ylim_same
#########################################################
# plot psds
for a, axp in enumerate(axps_stimulus):
lw_p = 0.8
# gemeinsamen Limit setzten
pp_here = 2*10 * np.log10(pp3[a] / np.max(pp3))# der faktor 2 ist falsch
plot_power_common_lim(axp, pp_here, 0, ff / eod_fr, colors[a], lw_p, plot_points[a], delta_f / eod_fr,
log=False,
devide=devide)
axp.show_spines('b')
axp.set_ylim(-22, 1) # -8.5
if a == 3: # % 4 == 3:
axp.yscalebar(1.1, 0.6, 20, 'dB', va='center', ha='right')
#axp.yscalebar(1.1, 0.8, 20, 'dB', va='center', ha='right')
#embed()
axps_stimulus[0].get_shared_y_axes().join(*axps_stimulus)
# if power_extra:
# axps_stimulus[0].get_shared_y_axes().join(*axps_stimulus)
def model_sheme_split2(grid_sheme_orig, time_transform=1000, ws=0.1, nfft=4096 * 6, stimulus_length=5, fft_type='mppsd',
a_fr=1, a_fe=0.2,
v_exp=1, exp_tau=0.1, counter=0, counterp=0, color='darkgrey', log=True,
shift=0.25):
load_name = 'models_big_fit_d_right.csv'
cell_nr = 8 # 5#5#6#3
# model_params = load_model(load_name=load_name, cell_nr = cell_nr)
models = resave_small_files("models_big_fit_d_right.csv", load_folder='calc_model_core')
flowchart_cell = '2012-07-03-ak-invivo-1'
model_params = models[models['cell'] == flowchart_cell].iloc[0]
print('cell='+str(flowchart_cell))
# amp_frame = pd.read_csv('peak_amplitudes_power.csv')
cell = model_params.pop('cell') # .iloc[0]# Werte für das Paper nachschauen
eod_fr = model_params['EODf'] # .iloc[0]
deltat = model_params.pop("deltat") # .iloc[0]
v_offset = model_params.pop("v_offset") # .iloc[0]
sampling_rate = 1/deltat
nfft = 2**20#int(sampling_rate / 4)
#embed()
cell_nr = 8 # 5#5#6#3
# embed()
eod_fe = [eod_fr + 50] # eod_fr*1+50,, eod_fr * 2 + 50
mult_nr = 0
# REMAINING rows
color_p3 = 'grey' # 'red'#palette['red']
color_p1 = 'grey' # 'blue'#palette['blue']
color_diagonal = 'grey' # 'cyan'#palette['cyan']
colors = [color_diagonal, color_p1, color_p1, color_p3]
ax_rec = [[]] * 4
ax_n = [[]] * 4
axt_IF1 = []
axt_IF2 = []
adds = [[0, 0, 0, 0], [0, 0, 2, 10]]
nrs_grid = [0, 1, 3, 4]
# delta_f = (eod_fe[mult_nr] - eod_fr) - eod_fr
delta_f = [50] # create_beat_corr(np.array([eod_fe[mult_nr] - eod_fr]), np.array([eod_fr]))[0]
# time, stimulus_here, eod_fish_r, eod_fish_e, stimulus = make_paramters(
# stimulus_length, deltat, eod_fr, a_fr, a_fe, eod_fe, mult_nr)
counter_here = 0
# ult_settings(column=2, length=5)
# # fdefaig = plt.figure()
# for mult_nr in range(len(eod_fe)):
c_sigs = [1, 1, 0.9]#1,
c_sigs = [0, 0, 0.9]#'',0,