removed files for second respository

This commit is contained in:
saschuta 2024-02-26 10:20:44 +01:00
parent ae914056aa
commit 1f76a90e8e
22 changed files with 1405 additions and 8181 deletions

Binary file not shown.

View File

@ -1,624 +0,0 @@
#from plt_RAM import plt_squares_bursts_single_psd
from utils_suseptibility import *
def plt_squares_bursts_single_psd2(col = 6, cells = ['2012-07-12-ap-invivo-1', '2018-06-26-ah-invivo-1',
'2012-12-20-ae-invivo-1',
'2012-06-27-ah-invivo-1', '2011-10-25-ad-invivo-1',
'2012-12-21-ai-invivo-1',
'2012-05-10-ad-invivo-1', '2012-12-20-ad-invivo-1',
'2012-04-20-ak-invivo-1',
'2012-12-13-ah-invivo-1', '2012-12-20-ab-invivo-1'],nr_clim=10, many=False, width=0.02, row='no', HZ50=True, fs=8, hs=0.39, redo=False, nffts=['whole'],
powers=[1], col_desired=2, var_items=['contrasts'], show=False,
contrasts=[0], noises_added=[''], fft_i='forward', fft_o='forward', spikes_unit='Hz', mV_unit='mV',
D_extraction_method=['additiv_visual_d_4_scaled'], internal_noise=['eRAM'],
external_noise=['eRAM'], level_extraction=['_RAMdadjusted'], cut_off2=300, repeats=[1000000],
receiver_contrast=[1], dendrids=[''], ref_types=[''], adapt_types=[''], c_noises=[0.1], c_signal=[0.9],
cut_offs1=[300],burst_corrs = [''], clims='all', restrict='restrict', label=r'$\frac{1}{mV^2S}$'):
plot_style()
duration_noise = '_short',
formula = 'code' ##'formula'
# ,int(2 ** 16) int(2 ** 16), int(2 ** 15),
stimulus_length = 1 # 20#550 # 30 # 15#45#0.5#1.5 15 45 100
trials_nrs = [1] # [100, 500, 1000, 3000, 10000, 100000, 1000000] # 500
stimulus_type = '_StimulusOrig_' # ,#
# ,3]#, 3, 1, 1.5, 0.5, ] # ,1,1.5, 0.5] #[1,1.5, 0.5] # 1.5,0.5]3, 1,
variant = 'sinz'
mimick = 'no'
cell_recording_save_name = ''
trans = 1 # 5
aa = 0
for burst_corr, cell, var_type, stim_type_afe, trials_stim, stim_type_noise, power, nfft, dendrid, cut_off1, trial_nrs, c_sig, c_noise, ref_type, adapt_type, noise_added, extract, a_fr, a_fe, in it.product(
burst_corrs, cells, D_extraction_method, external_noise
, repeats, internal_noise, powers, nffts, dendrids, cut_offs1, trials_nrs, c_signal,
c_noises,
ref_types, adapt_types, noises_added, level_extraction, receiver_contrast, contrasts, ):
#print(cell, burst_corr, cell, var_type, stim_type_afe, trials_stim,stim_type_noise, power, nfft, a_fe,a_fr, dendrid, cut_off1,trial_nrs)
# print(trial_nrs, stim_type_noise, trials_stim, power, nfft, a_fe, a_fr, var_type, cut_off1,trial_nrs)
aa += 1
default_figsize(column=2, length=4.2) #5.25.5. 6.8 2+2.25+2.25
a = 0
maxs = []
mins = []
ims = []
perc05 = []
perc95 = []
iternames = [D_extraction_method, external_noise,
internal_noise, powers, nffts, dendrids, cut_offs1, trials_nrs, c_signal,
c_noises,
ref_types, adapt_types, noises_added, level_extraction, receiver_contrast, contrasts, ]
nr = '2'
n = 2
b = 0
ax_lines = []
ax_psds = []
ax_diagonals = []
axss = []
resize_val = None
for c, cell in enumerate(cells):
axps = []
axpsl = []
#pss = []
lines = []
diags = []
pss = []
mats = []
a = 0
#fig = plt.figure(figsize=(12, 5.5))
fig = plt.figure()
for all in it.product(*iternames):
var_type, stim_type_afe, stim_type_noise, power, nfft, dendrid, cut_off1, trial_nrs, c_sig, c_noise, ref_type, adapt_type, noise_added, extract, a_fr, a_fe = all
# print(trials_stim,stim_type_noise, power, nfft, a_fe,a_fr, dendrid, var_type, cut_off1,trial_nrs)
#072
grid0 = gridspec.GridSpec(4, 1, wspace=0.24, bottom=0.1,
hspace=0.04, left=0.08, right=0.93, top=0.98, height_ratios = [1.1,1.3,1,5.8])#7.8
carrier, corrs_all, spikes_tr, spikes_tr_bef = save_spikes_burst_add(
a_fe, a_fr, adapt_type, burst_corr, c_noise, c_sig, cell, cell_recording_save_name, cut_off1,
cut_off2, dendrid, duration_noise, extract, fft_i, fft_o, formula, mimick, nfft, noise_added,
power, ref_type, stim_type_afe, stim_type_noise, stimulus_length, stimulus_type, trans,
trial_nrs, var_type, variant, trial_nrs_base=1, burst_corrs=burst_corrs)
# embed()
grid_stim = gridspec.GridSpecFromSubplotSpec(1, 1, grid0[0], wspace=0.34,
hspace=0.3)
ax_stim = plt.subplot(grid_stim[0])
model_cells = resave_small_files("models_big_fit_d_right.csv", load_folder='calc_model_core')
model_params = model_cells[model_cells.cell == cell].iloc[0]
cell = model_params.pop('cell')
eod_fr = model_params['EODf']
deltat = model_params.pop("deltat")
carrier = np.array(carrier['0'])
time_s = np.arange(0, len(carrier)*deltat, deltat)
carrier_RAM = np.random.normal(0, 1, size=len(time_s )) # *0.2
#sine = np.sin(2*np.pi*750)*(1+carrier_RAM*0.2)
extracted_am, time_am = extract_am(carrier, time_s, norm=False)
time_am = time_s * 1000
ax_stim.plot(time_am, extracted_am + 0.05, color='red')
ax_stim.plot(time_am, carrier, color = 'grey', linewidth = '0.5')
ax_stim.set_xlim(0, 200)
ax_stim.show_spines('')
grid_upper = gridspec.GridSpecFromSubplotSpec(1, 1, grid0[1], wspace=0.34,
hspace=0.3)
ax_spikes = plt.subplot(grid_upper[0])
#tags.append(ax_spikes)
#axss = plt.subplot(grid_data[0])
#todo: das modell hier einmal machen für eine variante
alpha = 1/(len(burst_corrs)+1)
#ax_spikes = plt.subplot(1,1,1)
colors = colors_overview()
for i in range(len(corrs_all)):
ax_spikes.eventplot(np.array(corrs_all[i]) * 1000, lineoffsets = len(corrs_all)-i, linelengths = 0.85, alpha =alphafunc_burstadd(
alpha, i), color=colors[' P-unit'])
#ax_upper.eventplot(spikes_tr_bef, color='red')
ax_spikes.set_xlim(0, 200)
ax_spikes.xscalebar(0.9, -0.02, 20, 'ms', va='right', ha='bottom')
#ax_diagonal.xscalebar(1, 0.5, 20, 'dB', va='center', ha='right')
ax_spikes.show_spines('')
#ax_spikes.set_yticks([])
##################################
grid_lower = gridspec.GridSpecFromSubplotSpec(row,col,grid0[3], wspace=0.25,
hspace=0.3)
labelpad = 0
for r, trials_stim in enumerate(repeats):
for b, burst_corr in enumerate(burst_corrs):
save_name = save_ram_model(stimulus_length, cut_off1, duration_noise, nfft, a_fe, formula,
stim_type_noise, mimick, variant, trials_stim, power,
stimulus_type,
cell_recording_save_name, nr=nr, fft_i=fft_i, fft_o=fft_o, Hz=spikes_unit,
mV=mV_unit, burst_corr=burst_corr, stim_type_afe=stim_type_afe, extract=extract,
noise_added=noise_added,
c_noise=c_noise, c_sig=c_sig, ref_type=ref_type, adapt_type=adapt_type,
var_type=var_type, cut_off2=cut_off2, dendrid=dendrid, a_fr=a_fr,
trials_nr=trial_nrs, trans=trans, zeros='ones')
path = save_name + '.pkl' # '../'+
print(save_name)
print(a)
grid_data = grid_matrices(a, grid_lower)
#grid1 = gridspec.GridSpecFromSubplotSpec(1, 2, grid[c], hspace=0)
##########596#####################
#frame = frame.sort_values(by='cv')
#fr = frame[frame.cell == cell].fr # np.array(model_cells['cell'])
#cv = frame[frame.cell == cell].cv
model_cells = resave_small_files("models_big_fit_d_right.csv", load_folder='calc_model_core')
model_params = model_cells[model_cells.cell == cell].iloc[0]
eod_fr = model_params['EODf']
#if cont_cell: # cont_cell
#grid_p_i = gridspec.GridSpecFromSubplotSpec(1, 2, grid_data[1])
#axp = plt.subplot(grid_p_i[0])
#axp.set_xlim(0,600)
sampling_calc = 40000
spikes_mat = [[]]*len(spikes_tr)
p_arrays = []
nfft_here = 2**16
diffs = []
f_array = []
#embed()
#spikes_tr = np.array(spikes_tr)
for s, sp in enumerate(corrs_all[b]):
if len(sp)>0:
#try:
np.isnan(sp[-1])
if np.isnan(sp[-1]):
sp = sp[~np.isnan(sp)]
spikes_mat[s] = cr_spikes_mat(np.array(sp), sampling_rate=sampling_calc,
length=int(sampling_calc * np.array(sp[-1])))
#embed()
p_ar, f_array = ml.psd(spikes_mat[s] - np.mean(spikes_mat[s]), Fs=sampling_calc,
NFFT=nfft_here,
noverlap=nfft_here / 2)
p_arrays.append(p_ar)
diffs.extend(np.diff(sp))
ps = np.mean(p_arrays, axis = 0)[f_array<600]
fss = f_array[f_array<600]
#axi, axs = hist_part(grid1, cell_type, burst_corrs[b], colors, cell, spikes, eod_fr, )
###############################
# square
axs = plt.subplot(grid_data[0])
axss.append(axs)
model = load_model_susept(path, cells, save_name)
#if cont:,
if len(model) > 0:
titles = ''
model_show = model[
(model.cell == cell)] # & (model_cell.file_name == file)& (model_cell.power == power)]
#embed()
new_keys = model_show.index.unique() # [0:490]
# np.abs(
try:
stack_plot = model_show[list(map(str, new_keys))]
except:
stack_plot = model_show[new_keys]
stack_plot = stack_plot.iloc[np.arange(0, len(new_keys), 1)]
stack_plot.columns = list(map(float, stack_plot.columns))
axs.set_xlim(0, 300)
axs.set_ylim(0, 300)
axs.set_xticks_delta(100)
axs.set_yticks_delta(100)
axs.set_aspect('equal')
model_params = model_cells[model_cells['cell'] == cell]
if len(model_show) > 0:
noise_strength = model_params.noise_strength.iloc[0] # **2/2
stack_plot = RAM_norm(stack_plot, trials_stim,model_show=model_show)
if many == True:
titles = titles + ' Ef=' + str(int(model_params.EODf.iloc[0]))
color = title_color(cell)
#embed()
stack_plot, add_nonlin_title, resize_val = rescale_colorbar_and_values(stack_plot, resize_val = resize_val)
#cbar[0].set_label(nonlin_title(add_nonlin_title)) # , labelpad=100
fr = int(np.round(model_show.fr.iloc[0]))
#burst_corr +
axs.text(1, 1.15, titles + ' $f_{Base}=%s$' %(int(np.round(model_show.fr_stim.iloc[0]))) + '\,Hz \n'+ r'$\rm{CV}=%s$' %(
np.round(model_show.cv_stim.iloc[0], 2)), ha = 'right', va = 'center',
transform=axs.transAxes, alpha=alphafunc_burstadd(
alpha, a), color=colors[' P-unit']) # color=color,fontsize=fs,+\n $cv_{B}$='$_{stim} + str(np.round(model_show.cv.iloc[0], 2)) + ' $fr_{B}$=' + str(fr) + '\n $D_{sig}$=' + str( np.round(D_derived, 5)) + ' s=' + str(np.round(model_show.ser_sum_stim.iloc[0], 2)
perc = '' # 'perc'
im = plt_RAM_perc(axs, perc, stack_plot)
pos = np.argmin(np.abs(stack_plot.index -fr/2))
# wenn _ am Anfang des Labels ist verändert das irgendwas, deswgen muss man das auswechseln!
if burst_corr == '':
burst_corr_name = 'no burst corr'
else:
burst_corr_name = burst_corr.replace('_', '-')
######################################
# psds
lines.append(stack_plot.iloc[pos])
diag, diagonals_prj_l = get_mat_diagonals(np.array(stack_plot))
diags.append(diagonals_prj_l)
pss.append(ps)
# embed()
##########################################
ims.append(im)
mats.append(stack_plot)
maxs.append(np.max(np.array(stack_plot)))
mins.append(np.min(np.array(stack_plot)))
perc05.append(np.percentile(stack_plot, 5))
perc95.append(np.percentile(stack_plot, 95))
plt_triangle(axs, model_show.fr.iloc[0], np.round(model_show.fr_stim.iloc[0]),
model_show.eod_fr.iloc[0], 300)
#plt_peaks_several(['',''], [model_show.fr.iloc[0],np.round(model_show.fr_stim.iloc[0])],ps,0,axp,ps,['brown','red'], fss)
axs.set_aspect('equal')
if a in np.arange(col - 1, 100, col):
cbar = colorbar_outside(axs, im, fig, add=0, width=width)
cbar[0].set_label(nonlin_title(' ['+add_nonlin_title))#, labelpad=100
#if b > col-1:
# axs.set_xlabel(F1_xlabel(), labelpad=20)
#axs.text(1.05, -0.35, F1_xlabel(), ha='center', va='center',
# transform=axs.transAxes)
set_xlabel_arrow(axs, ypos=-0.28)
#else:
# remove_xticks(axs)
#axs.set_ylabel(F2_xlabel())
#if a in np.arange(0, 10, 1) * col:
if b in np.arange(0, 100,col):
#axs.set_ylabel(F2_xlabel())
axs.text(-0.35, 0.97, F2_xlabel(), ha='center', va='center',
transform=axs.transAxes, rotation=90)
else:
remove_yticks(axs)
axs.arrow_spines('lb')
#else:
# remove_tick_ymarks(axs)
else:
print('no model there')
embed()
axs.set_title(var_type[7::] + ' \n' + burst_corr, fontsize=fs,
color=color) # + '\n $D_{sig}$=' + str( np.round(D_derived, 5)) + ' s=' + str(np.round(model_show.ser_sum_stim.iloc[0], 2)
#####################################################
####################################################
# plt psds
save_name = save_ram_model(stimulus_length, cut_off1, duration_noise, nfft, a_fe, formula,
stim_type_noise, mimick, variant, trials_stim, power,
stimulus_type,
cell_recording_save_name, nr=nr, fft_i=fft_i, fft_o=fft_o,
Hz=spikes_unit,
mV=mV_unit, burst_corr=burst_corr, stim_type_afe=stim_type_afe,
extract=extract,
noise_added=noise_added,
c_noise=c_noise, c_sig=c_sig, ref_type=ref_type, adapt_type=adapt_type,
var_type=var_type, cut_off2=cut_off2, dendrid=dendrid, a_fr=a_fr,
trials_nr=trial_nrs, trans=trans, zeros='ones')
path = save_name + '.pkl' # '../'+
grid_data = grid_matrices(a, grid_lower)
#grid_data = gridspec.GridSpecFromSubplotSpec(2, 1, grid_lower[b],
# hspace=1, height_ratios = [1.4,1]) #1.2 height_ratios=[1,1,1, 6],
grid_pds = gridspec.GridSpecFromSubplotSpec(1, 1, grid_data[1], wspace=0.34,
hspace = 0.8)#1.5
#ax_psd = plt.subplot(grid_pds[0])
#ax_psds.append(ax_psd)
ax_diagonal = plt.subplot(grid_pds[0])
ax_diagonals.append(ax_diagonal)
line = False
if line:
ax_line = plt.subplot(grid_pds[2])
ax_lines.append(ax_line)
colors = colors_overview()
psd_all = False
if psd_all:
psd_plot = False
if psd_plot:
##############################
# psd
max_val = pss[a] # np.array(diagonals_prj_l)
loag_val = 10 * np.log10(max_val / np.max(pss)) # / np.max(max_val)
ax_psd.plot(fss[fss < np.max(stack_plot.columns)], loag_val[fss < np.max(stack_plot.columns)],
zorder=100 - a, alpha=alphafunc_burstadd(
alpha, a), color=colors[' P-unit'])
else:
model = load_model_susept(path, cells, save_name)
#frame = pd.read_pickle('../calc_model/noise2__nfft_whole_power_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_10000_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV.pkl')
# if cont:,
if len(model) > 0:
titles = ''
model_show = model[
(model.cell == cell)] # & (model_cell.file_name == file)& (model_cell.power == power)]
try:
model_show['io_cross'] = model_show['io_cross'].astype('complex')
except:
print('io cross something')
embed()
vals = np.abs(np.array(model_show['io_cross']))/model_show['isf_psd']
#embed()
ax_psd.plot(stack_plot.columns, vals, alpha=alphafunc_burstadd(
alpha, a),
color=colors[' P-unit'])#[fss < np.max(stack_plot.columns)]
arrow = False
if arrow:
if b == 3:
set_xlabel_arrow(tranfer_xlabel(),xpos=1.15, ypos=-0.35)
#ax_psd.set_xlabel(tranfer_xlabel(), labelpad = labelpad)
else:
set_xlabel_arrow('', xpos=1.15, ypos=-0.35)
ax_psd.text(0.45, -0.6, tranfer_xlabel(), va='center', ha = 'center', transform=ax_psd.transAxes)
if b == 0:
ax_psd.set_ylabel(trasnfer_ylabel())
else:
remove_yticks(ax_psd)
#vals = np.abs(vals) / (powers / counter)
#if 'osf' in model_show.keys():
# plt_transferfunction(alpha, ax_psd, color, model_show, eod_fr=eod_fr)
#######################################
# line throuhg
if line:
max_val = np.array(lines[a]) # stack_plot.iloc[pos]
loag_val = 10 * np.log10(max_val / np.max(lines)) # / np.max(max_val)
ax_line.plot(np.array(stack_plot.columns), loag_val, label=burst_corr_name, zorder=100 - b,
alpha=alphafunc_burstadd(
alpha, a), color=colors[' P-unit'])
colors = colors_overview()
# diag, diagonals_prj_l = get_mat_diagonals(np.array(stack_plot))
axis_d = axis_projection(stack_plot, axis='')
if psd_all:
ax_psd.show_spines('lb')
ax_psd.set_xlim(0, axis_d[-1])
a += 1
alpha = 1 / (len(burst_corrs) + 1)
a = 0
for b, burst_corr in enumerate(burst_corrs):
#######################################
# diagonal
axis_d = axis_projection(stack_plot, axis='')
max_val = np.array(diags[b])
loag_val = 10 * np.log10(max_val / np.max(diags)) # / np.max(max_val)
colors = colors_overview()
print(np.max(loag_val))
ax_diagonal = ax_diagonals[b]
ax_diagonal.plot(axis_d, loag_val,
label=burst_corr_name, zorder=100 - a, alpha=alphafunc_burstadd(
alpha, a),
color=colors[' P-unit'])
a += 1
ax_diagonal.set_xlim(0, axis_d[-1])
#remove_xticks(ax_psd)
#ax_psd.set_ylim(-12, 0)
ax_diagonal.set_ylim(-14, 0)
scalebar = False
if scalebar:
if b == 0:
ax_diagonal.text(-0.2, 0.5, chi_name(), ha='center', va='center', rotation=90,
transform=ax_diagonal.transAxes) # diagonal_xlabel())
if b == 3:#a == len(lines) - 1:
ax_diagonal.show_spines('b')
ax_diagonal.yscalebar(1, 0.5, 10, 'dB', va='center', ha='right')
# ax_line.yscalebar(1, 0.1, 10, 'dB', va='top', ha='right')
#ax_psd.yscalebar(1, 0.5, 10, 'dB', va='center', ha='right')
#ax_diagonal.text(1.25, 0.5, 'Projection', ha='center', va='center',
# transform=ax_diagonal.transAxes, rotation=90)
#ax_psd.text(1.25, 0.5, 'Output', ha='center', va='center',
# transform=ax_psd.transAxes, rotation=90)
if line:
ax_line.text(1.25, 0.5, 'Line', ha='center', va='center',
transform=ax_line.transAxes, rotation=90)
ax_line.show_spines('b')
else:
if b == 0:
ax_diagonal.set_ylabel('dB', va='center', ha='right')
else:
remove_yticks(ax_diagonal)
# ax_line.yscalebar(1, 0.1, 10, 'dB', va='top', ha='right')
# ax_psd.yscalebar(1, 0.5, 10, 'dB', va='center', ha='right')
# ax_diagonal.text(1.25, 0.5, 'Projection', ha='center', va='center',
# transform=ax_diagonal.transAxes, rotation=90)
# ax_psd.text(1.25, 0.5, 'Output', ha='center', va='center',
# transform=ax_psd.transAxes, rotation=90)
#if line:
# ax_line.text(1.25, 0.5, 'Line', ha='center', va='center',
# transform=ax_line.transAxes, rotation=90)
# ax_line.show_spines('b')
# else:
if line:
ax_line.set_xlim(0, axis_d[-1])
ax_line.set_ylim(-25, 0)
remove_xticks(ax_diagonal)
else:
arrow = False
if arrow:
if b == 3:
set_xlabel_arrow(diagonal_xlabel(), xpos=1.15, ypos=-0.35)
else:
set_xlabel_arrow(diagonal_xlabel(), xpos=1.15, ypos=-0.35)
#ax_diagonal.text(0.45, -0.6,diagonal_xlabel(), va='center', ha='center', transform=ax_diagonal.transAxes)
#ax_psd.text(0.45, -0.6, tranfer_xlabel(), va='center', ha='center', transform=ax_psd.transAxes)
ax_diagonal.set_xlabel(diagonal_xlabel(), labelpad = labelpad)
for a in axps:
a.set_ylim(0,np.max(axpsl))
#set_clim_same_remainer(clims, ims, maxs, mins, nr_clim, perc05, perc95)
#set_same_clim_perc(ims, perc05, perc95)
set_clim_same_here(ims, nr_clim='perc',mats = mats, percnr = 85,perc05=perc05, perc95=perc95, lim_type='up')
if line:
ax_lines[0].get_shared_y_axes().join(*ax_lines)
ax_diagonals[0].get_shared_y_axes().join(*ax_diagonals)
#ax_psds[0].get_shared_y_axes().join(*ax_psds)ax_psds,
tags = np.transpose([axss])#,ax_diagonals,
xoffs = -3.1#2.9
fig.tag(ax_stim, xoffs=xoffs)
fig.tag(ax_spikes,xoffs=xoffs)#,-4.5
tag2(fig,axss,xoffs=xoffs, yoffs = 1.9)#.35#, -0.2
save_visualization(pdf=True)
def grid_matrices(a, grid_lower):
grid_data = gridspec.GridSpecFromSubplotSpec(2, 1, grid_lower[a], hspace=0.5,
height_ratios=[1.7, 1]) # height_ratios=[1,1,1, 6],
return grid_data
def alphafunc_burstadd(alpha, i):
return 1 - alpha * i
def set_same_clim_perc(ims, perc05, perc95):
for i, im in enumerate(ims):
im.set_clim(np.min(perc05), np.max(perc95))
def set_clim_same_remainer(clims, ims, maxs, mins, nr_clim, perc05, perc95):
if 'all' in clims:
remainer = clims.replace('all', '')
if remainer == '':
remainer = 0
else:
remainer = int(remainer)
# embed()
# remainer = 0
# set_clim_same_here()
for i, im in enumerate(ims):
if i < remainer:
# im.set_clim(np.min(np.min(mins)) * nr_clim, np.max(np.max(maxs) / nr_clim))
im.set_clim(perc05[i], perc95[i])
else:
if nr_clim == 'perc':
im.set_clim(perc05[i], perc95[i])
else:
im.set_clim(np.min(perc05), np.max(perc95))
# im.set_clim(mins[i] * nr_clim, maxs[i] / nr_clim)
else:
for i, im in enumerate(ims):
if nr_clim == 'perc':
im.set_clim(perc05[i], perc95[i])
else:
im.set_clim(mins[i] * nr_clim, maxs[i] / nr_clim)
#####################################################
if __name__ == '__main__':
##################################################
# compare all scales with 0.2, 0.25, 0.3, 0.35
model = resave_small_files("models_big_fit_d_right.csv", load_folder = 'calc_model_core')
#e#mbed()
cells = model.cell.unique()
cells_m = np.array(model.cell)
cells = []
cells = ['2018-05-08-af-invivo-1', '2018-05-08-ad-invivo-1', '2012-12-20-ae-invivo-1', '2015-01-20-af-invivo-1',
'2012-07-12-ap-invivo-1', '2018-05-08-ae-invivo-1',
'2014-12-11-aa-invivo-1',
'2015-01-15-ab-invivo-1', '2018-06-25-ad-invivo-1',
'2011-10-25-ad-invivo-1', '2018-05-08-ad-invivo-1',
'2018-05-08-ab-invivo-1', '2014-06-06-ag-invivo-1',
'2014-06-06-ac-invivo-1', '2012-04-20-ak-invivo-1',
'2018-05-08-aa-invivo-1']
cells.extend(cells_m)
cells = ["2013-01-08-aa-invivo-1"]
#cells = ['2012-04-20-ak-invivo-1']
burst_corrs = ['', '_burst_added1_','_burst_added2_','_burst_added3_',]#'_burst_added2only_',]#'_burst_added2_',
params = {'burst_corrs': burst_corrs}
########
# das mit den niedriegeren CVs machen
redo = True
show = True
repeats = [1000000] #250000 250000**params,
#repeats = [10000]
D_extraction_method = ['additiv_cv_adapt_factor_scaled0.2','additiv_cv_adapt_factor_scaled0.25',
'additiv_cv_adapt_factor_scaled0.3','additiv_cv_adapt_factor_scaled0.35',]
D_extraction_method = ['additiv_cv_adapt_factor_scaled0.3','additiv_cv_adapt_factor_scaled0.35',
'additiv_cv_adapt_factor_scaled0.4','additiv_cv_adapt_factor_scaled0.45',]
D_extraction_method = ['additiv_cv_adapt_factor_scaled0.4','additiv_cv_adapt_factor_scaled0.45',]
D_extraction_method = ['additiv_cv_adapt_factor_scaled',
]#'additiv_visual_d_4_scaled',
#cells = ['2018-05-08-ad-invivo-1','2018-05-08-af-invivo-1','2018-06-25-ad-invivo-1']
#todo:hier das mit dem psd machen
#embed()#'perc'
plt_squares_bursts_single_psd2(row = 1, level_extraction=[''], col = 4, cells = cells, burst_corrs=burst_corrs, D_extraction_method=D_extraction_method, nr_clim=10,
many=False,internal_noise=['RAM'],
external_noise=['RAM'], width=0.005, HZ50=False, fs=7, hs=0.8, redo=redo,
var_items=[k for k in params], clims='all0', repeats=repeats, show=show, label=r'$\frac{1}{S}$')#r'$\frac{1}{mV^2S}$'
#embed()

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

View File

@ -1,388 +0,0 @@
from utils_suseptibility import *#p_units_to_show,burst_cells
#from plt_RAM import plt_punit
# plt_cellbody_singlecell
def plt_cellbody_singlecell_bursts2(grid1, frame, save_names, cells_plot, cell_type_type, plus=1, ax3=[],
burst_corr='_burst_corr_individual', cells_plot2 = []):
#plt.rcParams["font.family"] = "Times New Roman"
colors = colors_overview()
stack = []
axis = []
ims = []
tags_cell = []
#titles = ['Low CV P-unit', 'High CV P-unit', 'Ampullary cell']
for c, cell in enumerate(cells_plot):
print(cell)
frame_cell = frame[(frame['cell'] == cell)]
frame_cell = unify_cell_names(frame_cell, cell_type=cell_type_type)
try:
cell_type = frame_cell[cell_type_type].iloc[0]
except:
print('cell type prob')
embed()
spikes = frame_cell.spikes.iloc[0]
wss = [0.15, 0.66]
# embed()
# eod, sampling_rate, ds, time_eod = find_eod(frame_cell)
tags = []
spikes_base = []
isi = []
frs_calc = []
fr = frame_cell.fr.iloc[0]
cv = frame_cell.cv.iloc[0]
vs = frame_cell.vs.iloc[0]
eod_fr = frame_cell.EODf.iloc[0]
print('EODF' + str(eod_fr))
spikes_base, isi, frs_calc, cont_spikes = load_spikes(spikes, eod_fr)
save_name_type = ['_allspikes_', '_burstIndividual_']
colors_b = ['grey', colors[cell_type]]
ims = []
wr_l = [1, 0.1, 1, 1]
wr_l = wr_l_cells_susept()
wr_u = [1, 0.1, 1, 1]
grid_cell, grid_upper = grids_upper_susept_pics(c, grid1, hs=0.75, row = 2, hr = [1, 0.8], wr_u = wr_u)
wss = ws_for_susept_pic()
# todo: das wenn die zwei ungleich ist ist noch ein Problem
widht_ratios = [2 + wss[0], 2 + wss[1]]
grid_lower = gridspec.GridSpecFromSubplotSpec(1, len(save_names), grid_cell[1], hspace=0.1, wspace=0.15,
width_ratios=widht_ratios)
'''grid_s1 = gridspec.GridSpecFromSubplotSpec(2, 2, grid_lower[0],
hspace=0.1, wspace=wss[0],
width_ratios=[0.8,
1]) # height_ratios=[1.5, 1.5, 5],
# plot the same also to the next plot
grid_s2 = gridspec.GridSpecFromSubplotSpec(2, 2, grid_lower[1],
hspace=0.1, wspace=wss[1],
width_ratios=[0.8,
1]) # height_ratios=[1.5, 1.5, 5],
'''
several = False
extra_input = False#>
axes = []
axos = []
axds = []
axd2, axi, axo2, grid_lower, grid_s1, grid_s2 = grids_for_psds(save_names, extra_input, grid_cell,
several, widht_ratios = widht_ratios, wss = wss, wr = wr_l)
#axo2 = None
#axd2 = None
test_clim = False
zorder = [100,1]
mats = []
ax_psds = []
add_nonlin_title = None
title_squares = ['All spikes, ', 'First spike, ']
var = ['fr','fr_burst_corr_individual']
for aa, save_name in enumerate(save_names):
add_save = '_cell' + cell + save_name_type[aa] #
# grid_lower = gridspec.GridSpecFromSubplotSpec(1, len(save_names), grid_cell[1], hspace=0.1,
# wspace=0.15)
title_square = title_squares[aa]
load_name = load_folder_name('calc_RAM') + '/' + save_name + '_' + cell
# embed()
# axes = []
stack = load_data_susept(load_name + '.pkl', load_name, add=add_save, load_version='csv', cells = cells_plot2)
if len(stack) > 0:
files = stack['file_name'].unique()
amps = stack['amp'].unique()
file_name = files[0]
stack_file = stack[stack['file_name'] == file_name]
amps_defined = [np.min(stack_file['amp'].unique())]
# embed()
xpos_xlabel = -0.24
for aaa, amp in enumerate(amps_defined):
if amp in np.array(stack_file['amp']):
alpha = find_alpha_val(aa, save_names)
#add_save = '_cell' + str(cell) + '_amp_' + str(amp)
xlim = [0,1.1]#
if not several:
#embed()
#lim = find_lim_here(cell, 'individual')
fr = frame[frame.cell == cell][var[aa]].iloc[0]
fr_bc = frame[frame.cell == cell][var[-1]].iloc[0]
#embed()
diagonals_prj_l, axi, eod_fr, fr, stack_final1, axds, axos, ax_square, axo2, axd2,mat, add_nonlin_title = plt_psds_in_one_squares_next(
aa, add_save, amp, amps_defined, axds, axes, axis, axos, c, cells_plot, colors_b,
eod_fr, file_name, grid_lower, ims, load_name, save_names, stack_file, wss, xlim = [],
test_clim=test_clim, zorder=zorder[aa], alpha=alpha, extra_input=extra_input, fr=fr,
title_square=title_square,fr_diag = fr_bc, xpos_xlabel=xpos_xlabel, add_nonlin_title=add_nonlin_title,
color=colors[cell_type], axo2=axo2, peaks_extra = True, axd2=axd2, axi=axi, iterate_var=save_names, amp_give = False)
mats.append(mat)
print(np.max(np.max(mat)))
else:
axi, eod_fr, fr, stack_final1, stack_spikes, axds, axos, ax_square, axo2, axd2 = plt_psds_in_one_squares(
aa, add, amp,
amps_defined, axds, axes,
axis, axos, c, cells_plot,
colors_b, eod_fr,
file_name, files, fr,
grid_s1, grid_s2, ims,
load_name, save_names,
stack_file, wss, xlim, axo2=axo2, axd2=axd2, iterate_var=save_names)
if aa == 0:
if extra_input:
tags.append(axi)
else:
tags.append(axo2)
tags.append(ax_square)
if aa == 1:
tags.append(axd2)
ax_psds.append(axo2)
ax_psds.append(axd2)
################################
# do the scatter of these cells
add = ['', '_burst_corr', ]
add = ['', '_burst_corr_individual']
# embed()
if len(stack) > 0:
load_name = load_folder_name('calc_RAM') + '/' + save_names[aa] + '_' + cell
if ax3 != []:
try:
frame_g = base_to_stim(load_name, frame, cell_type_type, cell_type, stack=stack)
except:
print('stim problem')
embed()
try:
ax3.scatter(frame_g['cv'], frame_g['cv_stim'], zorder=2, alpha=1,
label=cell_type, s=15,
color=colors[str(cell_type)], facecolor='white')
except:
print('scatter problem')
embed()
######################################################
#if aa == 0:
# color_here = 'grey'
#else:
color_here = ['grey', colors[str(cell_type)]][aa]#[colors[str(cell_type)]
add = ['', '_burst_corr', ]
add = ['', '_burst_corr_individual']
#colors_hist = ['grey', colors[str(cell_type)]]
# if len(hists_both) > 1:
# colors_hist = ['grey', colors[str(cell_type)]]
# else:
# colors_hist = [colors[str(cell_type)]]
# for gg in range(len(hists_both)):
# if len(hists_both) > 1:
# hists_here = hists_both[gg]
# embed()
# spikes_base, hists, frs_calc, cont_spikes = load_spikes(spikes, eod_fr, spikes_base, hists, frs_calc)
xlim_e = [0, 200]
#if 'spikes' in stack_final1.keys():
if aa == 0:
axss = plt.subplot(grid_upper[1, -2::])
# axii = plt.subplot(grid_upper[:, 0])
# try:
# embed()
# ax_spikes = plt.subplot(grid_upper[1, 1::])
eod_fr, length, stack_final, stack_final1, trial_nr = stack_preprocessing(amp, stack_file)
stack_spikes = load_data_susept(load_name + '.pkl', load_name, add=add_save, load_version='csv',
load_type='spikes',
trial_nr=trial_nr, stimulus_length=length, amp=amp,
file_name=file_name, redo = True)
# das mache ich damit der Stimulus für Mascha hier einmal mit abgespeichert ist
#stack_stim = load_data_susept(load_name + '.pkl', load_name, add=add + '_sampling_' + str(sampling),
# load_version='csv', load_type='stimulus',
# trial_nr=trial_nr, stimulus_length=length, redo=True, amp=amp,
# file_name=file_name)
plt_spikes(amps_defined, aa, c, cell, cell_type, cells_plot, color_here, eod_fr, fr, axss,
stack_final1, stack_spikes, xlim, axi=axi,xlim_e = [0,150], alpha = alpha, spikes_max = 3)
# print('spikes not there yet')
#else:
# eod_mt, sampling, spikes_loaded = nix_load(cell, stack_final1)
##############################
# isi
if len(isi) > 0:
if aa == 0:
grid_p = gridspec.GridSpecFromSubplotSpec(1, 2, grid_upper[:, 0], width_ratios=[1.4, 2],
wspace=0.3,
hspace=0.55)
#grid_p = gridspec.GridSpecFromSubplotSpec(2, 1, grid_upper[:, 0], height_ratios=[1.4, 2],
# hspace=0.55)
# hspace=0.25)
ax_isi = plt.subplot(grid_p[0])
ax_p = plt.subplot(grid_p[1])
tags.insert(0, ax_isi)
lim_here = find_lim_here(cell, burst_corr=burst_corr)
if np.min(np.concatenate(isi)) < lim_here:
_, spikes_ex, frs_calc2 = correct_burstiness(isi, spikes_base,
[eod_fr] * len(spikes_base),
[eod_fr] * len(spikes_base), lim=lim_here,
burst_corr=burst_corr)
else:
# da machen wir die Burst corr spikes anders
lim_here = find_lim_here(cell, burst_corr=burst_corr)
if np.min(np.concatenate(isi)) < lim_here:
isi, spikes_ex, frs_calc2 = correct_burstiness(isi, spikes_base,
[eod_fr] * len(spikes_base),
[eod_fr] * len(spikes_base), lim=lim_here,
burst_corr=burst_corr)
#embed()
#if len(isi[0])<1:
# print('len thing')
# embed()
right = False
ax_isi = base_cells_susept(ax_isi, ax_p, c, cell, cell_type, cells_plot, colors, eod_fr, frame,
isi, right, spikes_ex,stack,xlim,add_texts = [-3.1,0],texts_left = [250.3,0],peaks = True, pos = -0.55, titles = ['Bursty P-unit,','Bursty P-unit,'],fr_name = '$f_{BaseCorrected}$')
#plt_susept_isi_base(c, cell_type, cells_plot,'grey', ax_isi, isi, xlim=[])# color_here
#ax_p = plt_susept_psd_base(cell_type, 'grey', eod_fr, ax_p, spikes_base, xlim,
# right) #colors[str(cell_type)]
#remove_xticks(ax_p)
#else:
# embed()
##################################
# stimulus
xlim_e = [0, 100]
if aa == 0:
axe = plt.subplot(grid_upper[0, -2::])
plt_stimulus(eod_fr, axe, stack_final1, xlim_e, files[0])
tags.insert(1, axe)
#embed()
set_same_ylimscale(ax_psds)
labels_for_psds(axd2, axi, axo2, extra_input, right = right, xpos_xlabel = xpos_xlabel)
tags_cell.append(tags)
if not test_clim:
set_clim_same_here(ims, mats=mats, lim_type='up', mean_type = True, percnr = 94)
#set_clim_same_here(ims, clims='all', same = 'same', lim_type='up')
#set_clim_same_here(ims, clims='all', same = 'same', lim_type='up')
# join_y(axes)
# axds[0].get_shared_y_axes().join(*axds)
# embed()
# todo: das muss noch der gleiche ylim sein
try:
set_same_ylim(axos)
set_same_ylim(axds)
except:
print('axo thing')
#fig = plt.gcf()
#fig.tag(tags_cell, xoffs=-4, yoffs=1.9) # -1.5diese Offsets sind nicht intuitiv
if not test_clim:
try:
if len(cells_plot2) ==1:
tags_susept_pictures(tags_cell)
else:
tags_susept_pictures(tags_cell,yoffs=np.array([1.1, 1.1, 2.9, 2.9, 2.9, 2.9]))
except:
print('tag thing')
embed()
def burst_cells(amp_desired=[0.5, 1, 5], cell_class=' Ampullary', cells_plot2=[], show=False, annotate=False):
plot_style()
default_figsize(column=2, width=12, length=7.7) #ts=10, fs=10, ls=10,
save_names = ['noise_data8_nfft1sec_original__LocalEOD_CutatBeginning_0.05_s_NeurDelay_0.005_s_burst_corr']
# 'noise_data8_nfft1sec_original__LocalEOD_CutatBeginning_0.05_s_NeurDelay_0.005_s',#__burstIndividual_
# ]
save_names = ['noise_data8_nfft1sec_original__LocalEOD_CutatBeginning_0.05_s_NeurDelay_0.005_s__burstIndividual_']
save_names = ['noise_data8_nfft1sec_original__LocalEOD_CutatBeginning_0.05_s_NeurDelay_0.005_s_burst_corr']
save_names = ['noise_data8_nfft1sec_original__LocalEOD_CutatBeginning_0.05_s_NeurDelay_0.005_s_burst_corr',
'noise_data8_nfft1sec_original__LocalEOD_CutatBeginning_0.05_s_NeurDelay_0.005_s_burst_corr',
'noise_data10_nfft1sec_original__StimPreSaved4__mean5__CutatBeginning_0.05_s_NeurDelay_0.005_s_spikes_']
save_names = [
'noise_data10_nfft1sec_original__StimPreSaved4__mean5__CutatBeginning_0.05_s_NeurDelay_0.005_s_spikes_',
'noise_data10_nfft1sec_original__StimPreSaved4__mean5__CutatBeginning_0.05_s_NeurDelay_0.005_s__burstIndividual__spikes_']
save_names = [version_final(),version_final()+'__burstIndividual_']
# amps_desired, cell_type_type, cells_plot, frame, cell_types = load_isis(save_names, amps_desired = amp_desired, cell_class = cell_class)
cell_type_type = 'cell_type_reclassified'
#frame = load_cv_base_frame(cells_plot2, cell_type_type=cell_type_type)
#
frame, frame_spikes = load_cv_vals_susept(cells_plot2, EOD_type='synch',
names_keep=['spikes','gwn', 'fs', 'EODf', 'cv', 'fr', 'width_75', 'vs',
'cv_burst_corr_individual',
'fr_burst_corr_individual',
'width_75_burst_corr_individual',
'vs_burst_corr_individual', 'cell_type_reclassified',
'cell'], path_sp = '/calc_base_data-base_frame_overview.pkl',frame_general = False)
#print(cell)
#embed()
# if len(cells_plot2)>0:
cells_plot = cells_plot2
# '2012-05-15-ac-invivo-1','2010-06-21-ac-invivo-1','2010-06-18-ah-invivo-1'
# elif len(cells_plot)>6:
# cells_plot = cells_plot[0:6]
# cells_plot = cells_plot[0:6]
# embed()
################################################
# fig = plt.figure(figsize=(11.5, 6))
# das entscheided ob wir ein burst pic haben werden
#default_settings(ts=10, fs=10, ls=10, width=12, length=3.25 * len(cells_plot), column=2)
default_settings_cells_susept(cells_plot, l=3.65)
if len(cells_plot) > 1:
grid1 = big_grid_susept_pics(cells_plot, top=0.96, bottom=0.065)
else:
grid1 = big_grid_susept_pics(cells_plot, top=0.9, bottom=0.12)
plt_cellbody_singlecell_bursts2(grid1, frame, save_names, cells_plot, cell_type_type,
plus=1, burst_corr='_burst_corr_individual', cells_plot2 = cells_plot2)
# embed()
# plt.show()
fig = plt.gcf()
save_visualization(pdf=True)
# fig.savefig()
# save_all(0, cell+save_name+cell_sorted, show, '')
# show_func(show = show)
if __name__ == '__main__':
cells_plot1 = p_units_to_show(type_here = 'contrasts')
cells_plot1 = p_units_to_show(type_here='contrasts')
cells_plot2 = p_units_to_show(type_here = 'bursts')
burst_cells(cells_plot2 = [cells_plot2[0]], show = True, cell_class =' P-unit')#

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

View File

@ -1,324 +0,0 @@
from utils_suseptibility import *#p_units_to_show,burst_cells
#from plt_RAM import plt_punit
from burst_cells_suscept import burst_cells
# plt_cellbody_singlecell
def plt_cellbody_singlecell_bursts2(grid1, frame, save_names, cells_plot, cell_type_type, plus=1, ax3=[],
burst_corr='_burst_corr_individual'):
#plt.rcParams["font.family"] = "Times New Roman"
colors = colors_overview()
stack = []
axis = []
ims = []
tags_cell = []
#titles = ['Low CV P-unit', 'High CV P-unit', 'Ampullary cell']
for c, cell in enumerate(cells_plot):
print(cell)
frame_cell = frame[(frame['cell'] == cell)]
frame_cell = unify_cell_names(frame_cell, cell_type=cell_type_type)
try:
cell_type = frame_cell[cell_type_type].iloc[0]
except:
print('cell type prob')
embed()
spikes = frame_cell.spikes.iloc[0]
wss = [0.15, 0.66]
# embed()
# eod, sampling_rate, ds, time_eod = find_eod(frame_cell)
tags = []
spikes_base = []
isi = []
frs_calc = []
fr = frame_cell.fr.iloc[0]
cv = frame_cell.cv.iloc[0]
vs = frame_cell.vs.iloc[0]
eod_fr = frame_cell.EODf.iloc[0]
print('EODF' + str(eod_fr))
spikes_base, isi, frs_calc, cont_spikes = load_spikes(spikes, eod_fr)
save_name_type = ['_allspikes_', '_burstIndividual_']
colors_b = ['grey', colors[cell_type]]
ims = []
wr_l = [1, 0.1, 1, 1]
wr_l = wr_l_cells_susept()
wr_u = [1, 0.1, 1, 1]
grid_cell, grid_upper = grids_upper_susept_pics(c, grid1, hs=0.75, row = 2, hr = [1, 0.8], wr_u = wr_u)
wss = ws_for_susept_pic()
# todo: das wenn die zwei ungleich ist ist noch ein Problem
widht_ratios = [2 + wss[0], 2 + wss[1]]
grid_lower = gridspec.GridSpecFromSubplotSpec(1, len(save_names), grid_cell[1], hspace=0.1, wspace=0.15,
width_ratios=widht_ratios)
'''grid_s1 = gridspec.GridSpecFromSubplotSpec(2, 2, grid_lower[0],
hspace=0.1, wspace=wss[0],
width_ratios=[0.8,
1]) # height_ratios=[1.5, 1.5, 5],
# plot the same also to the next plot
grid_s2 = gridspec.GridSpecFromSubplotSpec(2, 2, grid_lower[1],
hspace=0.1, wspace=wss[1],
width_ratios=[0.8,
1]) # height_ratios=[1.5, 1.5, 5],
'''
several = False
extra_input = False#>
axes = []
axos = []
axds = []
axd2, axi, axo2, grid_lower, grid_s1, grid_s2 = grids_for_psds(save_names, extra_input, grid_cell,
several, widht_ratios = widht_ratios, wss = wss, wr = wr_l)
#axo2 = None
#axd2 = None
test_clim = False
zorder = [100,1]
mats = []
ax_psds = []
add_nonlin_title = None
title_squares = ['All spikes, ', 'First spike, ']
var = ['fr','fr_burst_corr_individual']
for aa, save_name in enumerate(save_names):
add_save = '_cell' + cell + save_name_type[aa] #
# grid_lower = gridspec.GridSpecFromSubplotSpec(1, len(save_names), grid_cell[1], hspace=0.1,
# wspace=0.15)
title_square = title_squares[aa]
load_name = load_folder_name('calc_RAM') + '/' + save_name + '_' + cell
# embed()
# axes = []
stack = load_data_susept(load_name + '.pkl', load_name, add=add_save, load_version='csv', cells = cells_plot2)
if len(stack) > 0:
files = stack['file_name'].unique()
amps = stack['amp'].unique()
file_name = files[0]
stack_file = stack[stack['file_name'] == file_name]
amps_defined = [np.min(stack_file['amp'].unique())]
# embed()
xpos_xlabel = -0.24
for aaa, amp in enumerate(amps_defined):
if amp in np.array(stack_file['amp']):
alpha = find_alpha_val(aa, save_names)
#add_save = '_cell' + str(cell) + '_amp_' + str(amp)
xlim = [0,1.1]#
if not several:
#embed()
#lim = find_lim_here(cell, 'individual')
fr = frame[frame.cell == cell][var[aa]].iloc[0]
fr_bc = frame[frame.cell == cell][var[-1]].iloc[0]
#embed()
diagonals_prj_l, axi, eod_fr, fr, stack_final1, axds, axos, ax_square, axo2, axd2,mat, add_nonlin_title = plt_psds_in_one_squares_next(
aa, add_save, amp, amps_defined, axds, axes, axis, axos, c, cells_plot, colors_b,
eod_fr, file_name, grid_lower, ims, load_name, save_names, stack_file, wss, xlim = [],
test_clim=test_clim, zorder=zorder[aa], alpha=alpha, extra_input=extra_input, fr=fr,
title_square=title_square,fr_diag = fr_bc, xpos_xlabel=xpos_xlabel, add_nonlin_title=add_nonlin_title,
color=colors[cell_type], axo2=axo2, peaks_extra = True, axd2=axd2, axi=axi, iterate_var=save_names, amp_give = False)
mats.append(mat)
print(np.max(np.max(mat)))
else:
axi, eod_fr, fr, stack_final1, stack_spikes, axds, axos, ax_square, axo2, axd2 = plt_psds_in_one_squares(
aa, add, amp,
amps_defined, axds, axes,
axis, axos, c, cells_plot,
colors_b, eod_fr,
file_name, files, fr,
grid_s1, grid_s2, ims,
load_name, save_names,
stack_file, wss, xlim, axo2=axo2, axd2=axd2, iterate_var=save_names)
if aa == 0:
if extra_input:
tags.append(axi)
else:
tags.append(axo2)
tags.append(ax_square)
if aa == 1:
tags.append(axd2)
ax_psds.append(axo2)
ax_psds.append(axd2)
################################
# do the scatter of these cells
add = ['', '_burst_corr', ]
add = ['', '_burst_corr_individual']
# embed()
if len(stack) > 0:
load_name = load_folder_name('calc_RAM') + '/' + save_names[aa] + '_' + cell
if ax3 != []:
try:
frame_g = base_to_stim(load_name, frame, cell_type_type, cell_type, stack=stack)
except:
print('stim problem')
embed()
try:
ax3.scatter(frame_g['cv'], frame_g['cv_stim'], zorder=2, alpha=1,
label=cell_type, s=15,
color=colors[str(cell_type)], facecolor='white')
except:
print('scatter problem')
embed()
######################################################
#if aa == 0:
# color_here = 'grey'
#else:
color_here = ['grey', colors[str(cell_type)]][aa]#[colors[str(cell_type)]
add = ['', '_burst_corr', ]
add = ['', '_burst_corr_individual']
#colors_hist = ['grey', colors[str(cell_type)]]
# if len(hists_both) > 1:
# colors_hist = ['grey', colors[str(cell_type)]]
# else:
# colors_hist = [colors[str(cell_type)]]
# for gg in range(len(hists_both)):
# if len(hists_both) > 1:
# hists_here = hists_both[gg]
# embed()
# spikes_base, hists, frs_calc, cont_spikes = load_spikes(spikes, eod_fr, spikes_base, hists, frs_calc)
xlim_e = [0, 200]
#if 'spikes' in stack_final1.keys():
if aa == 0:
axss = plt.subplot(grid_upper[1, -2::])
# axii = plt.subplot(grid_upper[:, 0])
# try:
# embed()
# ax_spikes = plt.subplot(grid_upper[1, 1::])
eod_fr, length, stack_final, stack_final1, trial_nr = stack_preprocessing(amp, stack_file)
stack_spikes = load_data_susept(load_name + '.pkl', load_name, add=add_save, load_version='csv',
load_type='spikes',
trial_nr=trial_nr, stimulus_length=length, amp=amp,
file_name=file_name, redo = True)
# das mache ich damit der Stimulus für Mascha hier einmal mit abgespeichert ist
#stack_stim = load_data_susept(load_name + '.pkl', load_name, add=add + '_sampling_' + str(sampling),
# load_version='csv', load_type='stimulus',
# trial_nr=trial_nr, stimulus_length=length, redo=True, amp=amp,
# file_name=file_name)
plt_spikes(amps_defined, aa, c, cell, cell_type, cells_plot, color_here, eod_fr, fr, axss,
stack_final1, stack_spikes, xlim, axi=axi,xlim_e = [0,150], alpha = alpha, spikes_max = 3)
# print('spikes not there yet')
#else:
# eod_mt, sampling, spikes_loaded = nix_load(cell, stack_final1)
##############################
# isi
if len(isi) > 0:
if aa == 0:
grid_p = gridspec.GridSpecFromSubplotSpec(1, 2, grid_upper[:, 0], width_ratios=[1.4, 2],
wspace=0.3,
hspace=0.55)
#grid_p = gridspec.GridSpecFromSubplotSpec(2, 1, grid_upper[:, 0], height_ratios=[1.4, 2],
# hspace=0.55)
# hspace=0.25)
ax_isi = plt.subplot(grid_p[0])
ax_p = plt.subplot(grid_p[1])
tags.insert(0, ax_isi)
lim_here = find_lim_here(cell, burst_corr=burst_corr)
if np.min(np.concatenate(isi)) < lim_here:
_, spikes_ex, frs_calc2 = correct_burstiness(isi, spikes_base,
[eod_fr] * len(spikes_base),
[eod_fr] * len(spikes_base), lim=lim_here,
burst_corr=burst_corr)
else:
# da machen wir die Burst corr spikes anders
lim_here = find_lim_here(cell, burst_corr=burst_corr)
if np.min(np.concatenate(isi)) < lim_here:
isi, spikes_ex, frs_calc2 = correct_burstiness(isi, spikes_base,
[eod_fr] * len(spikes_base),
[eod_fr] * len(spikes_base), lim=lim_here,
burst_corr=burst_corr)
#embed()
#if len(isi[0])<1:
# print('len thing')
# embed()
right = False
ax_isi = base_cells_susept(ax_isi, ax_p, c, cell, cell_type, cells_plot, colors, eod_fr, frame,
isi, right, spikes_ex,stack,xlim,add_texts = [-3.1,0],texts_left = [250.3,0],peaks = True, pos = -0.55, titles = ['Bursty P-unit,','Bursty P-unit,'],fr_name = '$f_{BaseCorrected}$')
#plt_susept_isi_base(c, cell_type, cells_plot,'grey', ax_isi, isi, xlim=[])# color_here
#ax_p = plt_susept_psd_base(cell_type, 'grey', eod_fr, ax_p, spikes_base, xlim,
# right) #colors[str(cell_type)]
#remove_xticks(ax_p)
#else:
# embed()
##################################
# stimulus
xlim_e = [0, 100]
if aa == 0:
axe = plt.subplot(grid_upper[0, -2::])
plt_stimulus(eod_fr, axe, stack_final1, xlim_e, files[0])
tags.insert(1, axe)
set_same_ylimscale(ax_psds)
labels_for_psds(axd2, axi, axo2, extra_input, right = right, xpos_xlabel = xpos_xlabel)
tags_cell.append(tags)
if not test_clim:
set_clim_same_here(ims, mats=mats, lim_type='up', mean_type = True, percnr = 94)
#set_clim_same_here(ims, clims='all', same = 'same', lim_type='up')
#set_clim_same_here(ims, clims='all', same = 'same', lim_type='up')
# join_y(axes)
# axds[0].get_shared_y_axes().join(*axds)
# embed()
# todo: das muss noch der gleiche ylim sein
try:
set_same_ylim(axos)
set_same_ylim(axds)
except:
print('axo thing')
#fig = plt.gcf()
#fig.tag(tags_cell, xoffs=-4, yoffs=1.9) # -1.5diese Offsets sind nicht intuitiv
if not test_clim:
try:
if len(cells_plot2) ==1:
tags_susept_pictures(tags_cell)
else:
tags_susept_pictures(tags_cell,yoffs=np.array([1.1, 1.1, 2.9, 2.9, 2.9, 2.9]))
except:
print('tag thing')
embed()
if __name__ == '__main__':
cells_plot2 = p_units_to_show(type_here = 'bursts')
burst_cells( cells_plot2 = [cells_plot2[1]], show = True, cell_class =' P-unit')

Binary file not shown.

View File

@ -1,75 +0,0 @@
from utils_suseptibility import cells_eigen
from utils_all import p_units_to_show
#from utils_all import load_folder_name
#from plt_RAM import plt_punit
from IPython import embed
if __name__ == '__main__':
#'2010-06-21-ac-invivo-1'
# Bei dem ampullary cells machen wir auch die Bursts weg
['2010-11-26-al-invivo-1', '2010-11-26-am-invivo-1',
'2010-11-08-ab-invivo-1', '2010-11-08-ag-invivo-1', '2010-11-08-ah-invivo-1', '2010-11-08-ai-invivo-1',
'2010-11-11-ak-invivo-1', '2010-11-11-ac-invovo-1',
'2013-04-11-ab-invivo-1',
]
cells = ['2010-11-26-al-invivo-1', '2010-11-26-am-invivo-1'
]
# 10-08-11-ar
# 5 + 10+20
# 0.5, 1, 5, 10, 20
# 2.5 5 10
# 5 10 20 (2012-06-21-av, 2010-08-27-ag)
# 0.5, 1, 5 (2021-08-03-ab)
# 0.1, 0.5, 1, 5 (2021-08-03-ac)
# 1 5 10 20, (2020-10-21-ac)
# 0.1,1,10 (2021-12-17-ad)
# 0.1, 0.5, 1, 5, 10 ,20 (2020-10-27-af)
# 1, 2, 5, 10, 20 (2021-06-18-ae)
unklar = ['2010-07-29-ae-invivo-1']
# für mehrere
# ampullary
## 2.5, 5, 10 (2011-10-25-ab, 2012-07-11-ag, 2012-12-13-ao)
# amp_desired = [2.5, 10, 20]# '2010-08-31-ad-invivo-1',
# cells_plot2 = ['2011-10-25-ac-invivo-1', '2012-05-15-ac-invivo-1','2012-06-08-ae-invivo-1']#['2010-06-21-av-invivo-1', '2010-08-27-ag-invivo-1','2020-10-27-ae-invivo-1']
amp_desired = [1, 5, 10, 20]
amp_desired = [0.1, 1, 10]
amp_desired = [0.5, 1, 5]
amp_desired = [0.5, 1, 5],
# 0.1, 0.5, 1, 5 (2021-08-03-ac,2021-08-03-ae)
amp_desired = [0.1, 0.5, 1, 5]
cells_plot2 = []
# 0.5, 1, 5 (2021-08-03-ab)
amp_desired = [0.5, 1, 5]
cells_plot2 = ['2021-08-03-ab-invivo-1','2021-08-03-ac-invivo-1','2021-08-03-ae-invivo-1']
# 1 5 10 20, (2020-10-21-ac)
amp_desired = [1,5,10,20]
cells_plot2 = []
# 0.1,1,10 (2021-12-17-ad)
# 0.1, 0.5, 1, 5, 10 ,20 (2020-10-20-ab, 2020-10-27-af)
#amp_desired = [1,5,10,20]
#cells_plot2 = []
# das hat uns glaube ich ganz gut gefallen
# 5 10 20 (2010-06-21-av, 2010-08-27-ag, 2010-08-31-ad)
amp_desired = [5,20]# '2010-08-31-ad-invivo-1', 10,
cells_plot2 = p_units_to_show(type_here = 'eigen_small')
# I like: '2020-10-21-ac' '2010-06-21-av-invivo-1', '2010-08-27-ag-invivo-1' '2021-08-03-ag-invivo-1, '20-10-21-aa-invivo-1
#2021-12-17-ad
#embed()
#'2017-10-25-am-invivo-1', '2010-11-26-an-invivo-1'
#save_names = ['noise_data10_nfft1sec_original__StimPreSaved4__mean5__CutatBeginning_0.05_s_NeurDelay_0.005_s_spikes_']
#load_name = load_folder_name('calc_RAM') + '/' + save_names[0] + '_' +'2017-10-25-am-invivo-1'# '2010-11-26-an-invivo-1'#'2017-10-25-am-invivo-1'
#stack = pd.read_pickle(load_name + '.pkl')
#embed()#[0, 250]#'High CV P-unit', at Fr \n at 1/2 EODf'
cells_eigen(titles = ['Low-CV P-unit,','Low-CV P-unit,'], cells_plot2 = cells_plot2, amp_desired = amp_desired, show = True,cell_class = ' P-unit')

Binary file not shown.

View File

@ -1,918 +0,0 @@
#sys.path.insert(0, '..')
#from plt_RAM import plt_RAM_overview_nice
#from utils_susept import
from IPython import embed
from matplotlib import gridspec as gridspec, pyplot as plt
import numpy as np
#embed()
from utils_all_down import default_settings, resave_small_files,update_cell_names
from utils_suseptibility import default_figsize, NLI_scorename, kernel_scatter, plt_burst_modulation_hists, \
plt_model_overview2, version_final
from utils_all import colors_overview, cv_base_name, load_overview_susept, make_log_ticks, p_units_to_show, \
save_visualization, \
setting_overview_score, update_ssh_file, load_folder_name
#import lstat
try:
from plotstyle import plot_style, spines_params
except:
a = 5
from heterogeneity import plt_fr_cv_base, get_grids_for_cv_fr, get_frame_for_base_plot
def data_overview2():
# calcdf_RAM_overview()
save_name = 'calc_RAM_overview-noise_data8_nfft1sec_original__LocalEOD_CutatBeginning_0.05_s_NeurDelay_0.005_s_burst_corr'
save_name = 'calc_RAM_overview-noise_data8_nfft1sec_original__LocalEOD_CutatBeginning_0.05_s_NeurDelay_0.005_s'
save_name = 'calc_RAM_overview-noise_data9_nfft1sec_original__StimPreSaved4__CutatBeginning_0.05_s_NeurDelay_0.005_s'
save_name = 'calc_RAM_overview-noise_data9_nfft1sec_original__StimPreSaved4__mean5__CutatBeginning_0.05_s_NeurDelay_0.005_s'
col = 4
row = 2 # sharex=True,
plot_style()
default_figsize(column=2, length=7.35)
#fig, ax = plt.subplots(4, 2) # , figsize=(14, 7.5) constrained_layout=True,
three = True
if three:
top = True
grid00 = gridspec.GridSpec(2, 1, wspace=0.37, bottom=0.15,
hspace=0.25, left=0.085, right=0.95, top=0.94, height_ratios = [1,2.7])
else:
grid00 = gridspec.GridSpec(4, 2, wspace=0.75, bottom=0.04,
hspace=0.6, left=0.15, right=0.99, top=0.95)
top = False
#grid0 = gridspec.GridSpec(3, 3, wspace=0.35, bottom=0.2,
# hspace=1, left=0.085, right=0.95, top=0.94)
grid0 = gridspec.GridSpecFromSubplotSpec(1, 5, grid00[0],width_ratios = [1,0.4, 1,0.55,1], hspace=0.35,wspace=0)
grid1 = gridspec.GridSpecFromSubplotSpec(2, 5, grid00[1],width_ratios = [1,0.4, 1,0.55,1], hspace=1.1, wspace=0)
###################################
###############################
# Das ist der Finale Score
scoreall = 'perc99/med'
###################################
#scores = [scoreall+'_diagonal_proj']
#score = scores[0]
##########################
# Auswahl: wir nehmen den mean um nicht Stimulus abhängigen Noise rauszumitteln
#save_names = []
save_names = ['calc_RAM_overview-_simplified_'+version_final()]#'calc_RAM_overview-_simplified_noise_data9_nfft1sec_original__StimPreSaved4__mean5__CutatBeginning_0.05_s_NeurDelay_0.005_s__burstIndividual_','calc_RAM_overview-noise_data9_nfft1sec_original__StimPreSaved4__mean5__CutatBeginning_0.05_s_NeurDelay_0.005_s__burstIndividual_',
save_names = [version_final_overview()]#_abs_
#save_names = ['calc_RAM_overview-_simplified_noise_data12_nfft0.5sec_original__StimPreSaved4__abs_']
counter = 0
colors = colors_overview()
ax_j = []
axls = []
axss = []
cell_types = [' Ampullary', ' P-unit', ]
counter = 0
tags = []
log = False
counterplus = 2
max_val = 1.5
score_burst_corr = 'max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr'#scores[0]
score_n_burst_corr= 'max(diag5Hz)/med \n diagonal_proj \n fr_base_w_burstcorr' # , 'max(diag5Hz)/med \n diagonal_proj \n fr_base_w_burstcorr']
score_n_burst_corr = 'Fr$_{BurstCorr}$/Median' # , 'max(diag5Hz)/med \n diagonal_proj \n fr_base_w_burstcorr']
score_n_burst_corr = NLI_burstcorr_name()
score = 'max(diag5Hz)/med_diagonal_proj_fr'
score_n = 'max(diag5Hz)\n/med_diagonal_proj_fr'
score_n = 'Fr/Median' # , 'max(diag5Hz)/med \n diagonal_proj \n fr_base_w_burstcorr']
score_n = NLI_scorename()
#score = 'max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr' # scores[0]
redo = False#True#True
frame_load_sp = load_overview_susept(save_names[0], redo=redo, redo_class=redo)
#embed()
test_amps = False
if test_amps:
cells_amp = ['2011-09-21-ab', '2010-06-21-am', '2012-05-15-ac', '2012-04-26-ae', '2012-05-07-ac', '2010-06-21-ac']
cells_amp = update_cell_names(cells_amp)
frame_amps = frame_load_sp[frame_load_sp.cell.isin(cells_amp)]
fish_plot = False
if fish_plot:
axls, axss, counter, frame_load_sp, max_val, score_burst_corr = fish_plt_false(ax_j, axls, axss, cell_types,
colors, counter, grid0, log,
max_val, save_names,
score_burst_corr)
alpha = 0.3
####################################################################
# base plots
# cells = p_units_to_show()
# cell_type_type, frame_load, frame_spikes = get_frame_for_base_plot(cells)
burst_choice = ['', '_burst_corr_individual']
xmax_burst = [[1.5,'no'],[0.8,'no']]
for gg in range(len(burst_choice)):
cells = p_units_to_show()
species = ' Apteronotus leptorhynchus'
cell_type_type, frame_load, frame_spikes = get_frame_for_base_plot(cells, save_names = save_names, species = species)
ax0, ax_cv, ax_fr = get_grids_for_cv_fr(gg, grid0[counter])#counter
if gg == 0:
#ax_cv.text(1.5, 2, r'\bf{A} \textit{Apteronotus leptorhynchus}', ha = 'center', va = 'center', transform=ax_cv.transAxes)
text_punits(ax_cv, colors)
ax_cv.text(0.35, 0.45, r'Ampullary cells', ha='left', va='center',
transform=ax_cv.transAxes, color = colors[' Ampullary'])#' Ampullary',
species_letter(ax_cv)
print(species)
x_axis, y_axis = plt_fr_cv_base(ax0, ax_cv, ax_fr, burst_choice,
frame_load, gg, alpha = alpha, xmax = xmax_burst[gg], species = species)
ax0.set_xticks_delta(0.5)
tags.append(ax_cv)
counter += 2
#frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='min', species=species)
####################################################################
# base plots
# cells = p_units_to_show()
# cell_type_type, frame_load, frame_spikes = get_frame_for_base_plot(cells)
burst_choice = ['']#, '_burst_corr_individual']
#counter += 1
nrs = [1,3]
for gg in range(len(burst_choice)):
cells = p_units_to_show()
species = ' Eigenmannia virescens'
cell_type_type, frame_load, frame_spikes = get_frame_for_base_plot(cells,save_names = save_names, species = species)
ax0, ax_cv, ax_fr = get_grids_for_cv_fr(gg, grid0[counter])#counter
#ax_cv.set_title('Eigenmannia virescens')
#ax_cv.text(0.5, 2, B, ha='center', va='center', transform=ax_cv.transAxes)
species_letter(ax_cv, letter='B', species=r'\textit{Eigenmannia virescens}')
print(species)
x_axis, y_axis = plt_fr_cv_base(ax0, ax_cv, ax_fr, burst_choice,
frame_load, gg, alpha = alpha, xmax = ['no','no'], species = species)
ax0.set_xticks_delta(0.5)
tags.append(ax_cv)
counter += 2
#embed()
###########################
###########################
###########################
# counterreset!
counter = 0
#grid0 = grid1
# base ready
####################################################################
####################################################################
####################################################################
####################################################################
#grid_lower = gridspec.GridSpecFromSubplotSpec(2, 2, grid0[2],hspace = 0.55, wspace = 0.5)
#
cv_name = "cv_base"
species = ' Apteronotus leptorhynchus'
cell_type_here = ' P-unit'
#for c, cell_type_here in enumerate(cell_types):
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='min', species=species)
#embed()
#setting_overview_score(frame_load_sp, cell_type_here, min_amp='min', species=species)
x_axis = ['cv_base',score]#,'burst_fraction_burst_corr_individual_stim']#, 'cv_base']#,'cv_base',]
x_axis_names = [cv_base_name(), score_n] # ,'Burst Fraction$_{Stim}$' 'CV$_{Base}$']#,'Burst Fraction$_{Base}$',]
y_axis = ['burst_fraction_burst_corr_individual_base', score_burst_corr] # , 'coherence_', ]
y_axis_name = ['Burst Fraction$_{Base}$', score_n_burst_corr]
#
var_item_names = ['Response Modulation [Hz]']#,'Response Modulation [Hz]']#,'Burst Fraction$_{Base}$']#'Response Modulation',]#,score_n_burst_corr,'Response Modulation [Hz]']#'Burst Fraction$_{Stim}$',['Modulation']#,
#'Response Modulation [Hz]',
var_types = ['response_modulation']#,'response_modulation']#,'burst_fraction_burst_corr_individual_base']#'response_modulation']#,score_burst_corr,'response_modulation']#,'burst_fraction_burst_corr_individual_stim','cv_base''response_modulation'] # [ 'response_modulation']#,'cv_base''response_modulation']#,'burst_fraction_burst_corr_individual_base', ]
logs = [False,False]#,False]
xmins = [0,0]#,'no']
#'response_modulation',
#var_item_names = ['burst_diff']#['Modulation [Hz]']#,
#var_types = ['burst_diff'] # [ 'response_modulation']#,'cv_base''response_modulation']#,'burst_fraction_burst_corr_individual_base', ]
#['burst_fraction_burst_corr_individual_stim']
#score_name = ['Burst Fraction$_{Stim}$']# 'CV$_{Base}$']#,'Burst Fraction', ]
frame_file['burst_diff'] = np.abs(frame_file['burst_fraction_burst_corr_individual_stim']-frame_file['burst_fraction_burst_corr_individual_base'])
burst_fraction = [1,1,1]#, 0.5, 1, 1]#05burst_fraction_burst_corr_individual_base
#score_n = ['Perc99/Med','Perc99/Med']
#score = ['max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr','max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr']
n = False
xlim_here0 = [0,1.5]
ax_j, axls, axs, axss, counter = plt_var_axis([], axls, axss,y_axis_name, burst_fraction, cell_type_here, counter, cv_name,
frame_file, grid1, max_val, score_burst_corr, y_axis, var_item_names,
var_types, x_axis, x_axis_names, counterplus = counterplus, n = n, xlim = xlim_here0, log = logs, top = top, xmins = xmins, extra_cells = False)
text_punits(ax_j[0], colors, xpos = 0.65, ypos = 0.9)
#plt.show()
#hier beide anhängen
tags.append(ax_j[-1])
#tags.extend(ax_j)
xlim_here = axss[-1].get_xlim()
ylim_here = axss[-1].get_ylim()
axss[-1].set_xlim(xlim_here0)
ax_j[-1].set_xlim(xlim_here0)
start = np.max([xlim_here[0],ylim_here[0]])
end = np.min([xlim_here[1], ylim_here[1]])
#axss[-1].plot([start, end], [start, end], color='grey', linewidth=0.5)
#plt.show()
####################################################################
#grid_lower = gridspec.GridSpecFromSubplotSpec(2, 2, grid0[2],hspace = 0.55, wspace = 0.5)
#
cv_name = "cv_base"
species = ' Apteronotus leptorhynchus'
cell_type_here = ' P-unit'
#for c, cell_type_here in enumerate(cell_types):
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='min', species=species)
x_axis = ['burst_fraction_burst_corr_individual_base','cv_base',score]#,'burst_fraction_burst_corr_individual_stim']#, 'cv_base']#,'cv_base',]
x_axis_names = ['Burst Fraction$_{Base}$', 'CV$_{Base}$',score_n] # ,'Burst Fraction$_{Stim}$' 'CV$_{Base}$']#,'Burst Fraction$_{Base}$',]
y_axis = [score_burst_corr, 'burst_fraction_burst_corr_individual_base', score_burst_corr] # , 'coherence_', ]
y_axis_name = [score_n_burst_corr, 'Burst Fraction$_{Base}$', score_n_burst_corr]
#
var_item_names = ['Response Modulation [Hz]']#,'Response Modulation [Hz]']#,'Burst Fraction$_{Base}$']#'Response Modulation',]#,score_n_burst_corr,'Response Modulation [Hz]']#'Burst Fraction$_{Stim}$',['Modulation']#,
#'Response Modulation [Hz]',
var_types = ['response_modulation']#,'response_modulation']#,'burst_fraction_burst_corr_individual_base']#'response_modulation']#,score_burst_corr,'response_modulation']#,'burst_fraction_burst_corr_individual_stim','cv_base''response_modulation'] # [ 'response_modulation']#,'cv_base''response_modulation']#,'burst_fraction_burst_corr_individual_base', ]
logs = [False,False]#,False]
xmins = [0,0]#,'no']
#'response_modulation',
#var_item_names = ['burst_diff']#['Modulation [Hz]']#,
#var_types = ['burst_diff'] # [ 'response_modulation']#,'cv_base''response_modulation']#,'burst_fraction_burst_corr_individual_base', ]
#['burst_fraction_burst_corr_individual_stim']
#score_name = ['Burst Fraction$_{Stim}$']# 'CV$_{Base}$']#,'Burst Fraction', ]
frame_file['burst_diff'] = np.abs(frame_file['burst_fraction_burst_corr_individual_stim']-frame_file['burst_fraction_burst_corr_individual_base'])
burst_fraction = [1,1,1]#, 0.5, 1, 1]#05burst_fraction_burst_corr_individual_base
#score_n = ['Perc99/Med','Perc99/Med']
#score = ['max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr','max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr']
xmax = 6
ax_j, axls, axs, axss, counter = plt_var_axis([], axls, axss,y_axis_name, burst_fraction, cell_type_here, counter, cv_name,
frame_file, grid1, max_val, score_burst_corr, y_axis, var_item_names,
var_types, x_axis, x_axis_names, counterplus = counterplus, n = n, log = logs, top = top, xmins = xmins, ymaxs = [xmax], extra_cells = True)
#text_punits(axs, colors)
#hier beide anhängen
reset_xlims(axls, axss, xmax)
tags.append(ax_j[-1])
#tags.extend(ax_j)
xlim_here = axss[-1].get_xlim()
ylim_here = axss[-1].get_ylim()
start = np.max([xlim_here[0],ylim_here[0]])
end = np.min([xlim_here[1], ylim_here[1]])
#axss[-1].plot([start, end], [start, end], color='grey', linewidth=0.5)
#plt.show()
########################################################################
#####################################################################
# Eigemania Zellen
ylim_eigen = [0, 6]
cell_types = [' P-unit',' Ampullary'] # ,' P-unit',' Ampullary', ]
x_axis = ["cv_base"] # , "cv_base_w_burstcorr","cv_base", ]
cv_name_title = [cv_base_name()] # ,'CV$_{BurstCorr}$','CV']
species_all = [' Eigenmannia virescens'] # ,' Apteronotus leptorhynchus',' Eigenmannia virescens']
#counter += counterplus
ax_j, axls, axss, cell_types, _, max_val, _ = species_with_both_cells(grid1[counter], cell_types, ax_j,
axls, axss, colors,
cv_name_title,
save_names, score,
species_all, x_axis,ylim = ylim_eigen,
max_val=max_val,n = n, alpha = alpha, log = False, score_n = score_n)
tags.append(ax_j[-1])
axss[-1].set_title('')
ax_j[-1].set_title('')
counter += 1
####################################################################
# grid_lower = gridspec.GridSpecFromSubplotSpec(2, 2, grid0[2],hspace = 0.55, wspace = 0.5)
#
cv_name = "cv_base"
species = ' Apteronotus leptorhynchus'
cell_type_here = ' P-unit'
# for c, cell_type_here in enumerate(cell_types):
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='min', species=species)
x_axis = [
score] # 'burst_fraction_burst_corr_individual_base','cv_base']#,score]#,'burst_fraction_burst_corr_individual_stim']#, 'cv_base']#,'cv_base',]
x_axis_names = [
score_n] # ,'Burst Fraction$_{Base}$', 'CV$_{Base}$']#,score_n] # ,'Burst Fraction$_{Stim}$' 'CV$_{Base}$']#,'Burst Fraction$_{Base}$',]
y_axis = [
score_burst_corr] # , 'burst_fraction_burst_corr_individual_base']#, score_burst_corr] # , 'coherence_', ]
y_axis_name = [score_n_burst_corr] # , 'Burst Fraction$_{Base}$']#, score_n_burst_corr]
#
var_item_names = [
'Burst Fraction$_{Base}$'] # 'Response Modulation',]#,score_n_burst_corr,'Response Modulation [Hz]']#'Burst Fraction$_{Stim}$',['Modulation']#,
# 'Response Modulation [Hz]',
var_types = [
'burst_fraction_burst_corr_individual_base'] # 'response_modulation']#,score_burst_corr,'response_modulation']#,'burst_fraction_burst_corr_individual_stim','cv_base''response_modulation'] # [ 'response_modulation']#,'cv_base''response_modulation']#,'burst_fraction_burst_corr_individual_base', ]
logs = [False]
xmins = ['no']
ymins = ['no']
# 'response_modulation',
# var_item_names = ['burst_diff']#['Modulation [Hz]']#,
# var_types = ['burst_diff'] # [ 'response_modulation']#,'cv_base''response_modulation']#,'burst_fraction_burst_corr_individual_base', ]
# ['burst_fraction_burst_corr_individual_stim']
# score_name = ['Burst Fraction$_{Stim}$']# 'CV$_{Base}$']#,'Burst Fraction', ]
frame_file['burst_diff'] = np.abs(frame_file['burst_fraction_burst_corr_individual_stim'] - frame_file[
'burst_fraction_burst_corr_individual_base'])
burst_fraction = [1, 1, 1] # , 0.5, 1, 1]#05burst_fraction_burst_corr_individual_base
# score_n = ['Perc99/Med','Perc99/Med']
# score = ['max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr','max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr']
xmax = 7
ax_j, axls, axs, axss, counter = plt_var_axis(ax_j, axls, axss, y_axis_name, burst_fraction, cell_type_here,
counter, cv_name,
frame_file, grid1, max_val, score_burst_corr, y_axis, var_item_names,
var_types, x_axis, x_axis_names, counterplus = counterplus,n = n, log=logs, top=top, xmins=xmins, ymaxs = [xmax], extra_cells= False)
reset_xlims(axls, axss, xmax)
axss[-1].set_xticks_delta(2)
axss[-1].set_yticks_delta(2)
axss[-1].set_xlim(0.5, xmax)
ax_j[-1].get_shared_x_axes().join(*[axss[-1], ax_j[-1]])
#text_punits(axs, colors)
# embed()
tags.append(ax_j[-1])
xlim_here = axss[-1].get_xlim()
ylim_here = axss[-1].get_ylim()
start = np.max([xlim_here[0], ylim_here[0]])
end = np.min([xlim_here[1], ylim_here[1]])
axss[-1].plot([start, end], [start, end], color='grey', linewidth=0.5)
# embed()
####################################################################
cv_name = "cv_base"
species = ' Apteronotus leptorhynchus'
cell_type_here = ' P-unit'
# 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)
var_types = ['response_modulation']#,'response_modulation']
x_axis = ['burst_fraction_burst_corr_individual_base']#,score]
var_item_names = ['Response Modulation [Hz]']#,'Response Modulation [Hz]']#'Modulatoin'
x_axis_names = ['Burst Fraction$_{Base}$']#,score_n]
burst_fraction = [1, 1, 1, 1] # burst_fraction_burst_corr_individual_base
y_axis = ['burst_fraction_burst_corr_individual_stim']#,score_burst_corr]
y_axis_name = ['Burst Fraction$_{Stim}$']#,score_n_burst_corr]
#embed()
test = False
if test:
burst_fraction, var_item_names, var_types, x_axis, x_axis_names, y_axis, y_axis_name = test_eodfr(
burst_fraction, var_item_names, var_types, x_axis, x_axis_names, y_axis, y_axis_name)
#embed()
for v, var_type in enumerate(var_types):
# ax = plt.subplot(grid0[1+v])#grid_lower[0, v]
axk, axl, axs, axls, axss, ax_j = get_grid_4(ax_j, axls, axss, grid1[counter])
cmap, _, _ = plt_burst_modulation_hists(axk, axl, var_item_names[v], axs, cell_type_here,
x_axis[v], frame_file, max_val, y_axis[v],
burst_fraction=burst_fraction[v], n = n,top = top, var_item=var_type)
axs.set_ylabel(y_axis_name[v])
axs.set_xlabel(x_axis_names[v])
#text_punits(axs, colors)
plot_extra_cells(axs, frame_file, y_axis, v, x_axis, type_here = 'contrasts')
#if v == 1:
if test == False:
axs.plot([0, 1.01], [0, 1.01], color='grey', linewidth=0.5)
tags.append(axk)
counter += counterplus
####################################################################
#grid_lower = gridspec.GridSpecFromSubplotSpec(2, 2, grid0[2],hspace = 0.55, wspace = 0.5)
#
mutual_information = False
if mutual_information:
cv_name = "cv_base"
species = ' Apteronotus leptorhynchus'
cell_type_here = ' P-unit'
#for c, cell_type_here in enumerate(cell_types):
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='min', species=species)
x_axis = ['burst_fraction_burst_corr_individual_base','cv_base',score]#,'burst_fraction_burst_corr_individual_stim']#, 'cv_base']#,'cv_base',]
x_axis_names = ['Burst Fraction$_{Base}$', 'CV$_{Base}$',score_n] # ,'Burst Fraction$_{Stim}$' 'CV$_{Base}$']#,'Burst Fraction$_{Base}$',]
y_axis = ['contrast_integral', 'burst_fraction_burst_corr_individual_base', score_burst_corr] # , 'coherence_', ]
y_axis_name = ['(MI$_{R}$-MI$_{C}$)/MI$_{C}$', 'Burst Fraction$_{Base}$', score_n_burst_corr]
#
var_item_names = ['Response Modulation [Hz]']#,'Response Modulation [Hz]']#,'Burst Fraction$_{Base}$']#'Response Modulation',]#,score_n_burst_corr,'Response Modulation [Hz]']#'Burst Fraction$_{Stim}$',['Modulation']#,
#'Response Modulation [Hz]',
var_types = ['response_modulation']#,'response_modulation']#,'burst_fraction_burst_corr_individual_base']#'response_modulation']#,score_burst_corr,'response_modulation']#,'burst_fraction_burst_corr_individual_stim','cv_base''response_modulation'] # [ 'response_modulation']#,'cv_base''response_modulation']#,'burst_fraction_burst_corr_individual_base', ]
logs = [False,False]#,False]
xmins = [0,0]#,'no']
#'response_modulation',
#var_item_names = ['burst_diff']#['Modulation [Hz]']#,
#var_types = ['burst_diff'] # [ 'response_modulation']#,'cv_base''response_modulation']#,'burst_fraction_burst_corr_individual_base', ]
#['burst_fraction_burst_corr_individual_stim']
#score_name = ['Burst Fraction$_{Stim}$']# 'CV$_{Base}$']#,'Burst Fraction', ]
frame_file['burst_diff'] = np.abs(frame_file['burst_fraction_burst_corr_individual_stim']-frame_file['burst_fraction_burst_corr_individual_base'])
burst_fraction = [1,1,1]#, 0.5, 1, 1]#05burst_fraction_burst_corr_individual_base
#score_n = ['Perc99/Med','Perc99/Med']
#score = ['max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr','max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr']
ax_j, axls, axs, axss, counter = plt_var_axis([], axls, axss,y_axis_name, burst_fraction, cell_type_here, counter, cv_name,
frame_file, grid0, max_val, score_burst_corr, y_axis, var_item_names,
var_types, x_axis, x_axis_names,counterplus = coutnerplus, n = n, extra_cells = True, log = logs, top = top, xmins = xmins)
#hier beide anhängen
tags.append(ax_j[-1])
#tags.extend(ax_j)
xlim_here = axss[-1].get_xlim()
ylim_here = axss[-1].get_ylim()
start = np.max([xlim_here[0],ylim_here[0]])
end = np.min([xlim_here[1], ylim_here[1]])
#axss[-1].plot([start, end], [start, end], color='grey', linewidth=0.5)
#####################################################################
# Eigemania Zellen
cell_types = [' P-unit',' Ampullary'] # ,' P-unit',' Ampullary', ]
x_axis = ["response_modulation"] # , "cv_base_w_burstcorr","cv_base", ]
cv_name_title = ['Response Modulation [Hz]'] # ,'CV$_{BurstCorr}$','CV']
species_all = [' Eigenmannia virescens'] # ,' Apteronotus leptorhynchus',' Eigenmannia virescens']
#counter += 1
ax_j, axls, axss, cell_types, frame_load_sp, max_val, score_burst_corr = species_with_both_cells(grid1[counter], cell_types, ax_j,
axls, axss, colors,
cv_name_title,
save_names, score,
species_all, x_axis, alpha = alpha,
max_val=max_val, n = n, ylim = ylim_eigen, log = False, score_n = score_n)
tags.append(ax_j[-1])
axss[-1].set_title('')
ax_j[-1].set_title('')
counter+= 1#counterplus
#####################################################
#grid_lower_lower = gridspec.GridSpecFromSubplotSpec(1, 2, grid0[1], wspace = 0.5, hspace=0.55)#, height_ratios = [1,3]
cell_types = [' P-unit']#,' P-unit',' Ampullary', ]
restrict = False
if restrict:
ax_j, axls, axss, counter = modulation_restrict(ax_j, axls, axs, axss, cell_types, counter, cv_name,
frame_load_sp, grid0, log, max_val, score_burst_corr, score_n,
species, tags, top)
################################
# coherence
coherence_plot = False
if coherence_plot:
coherence_plot_modulation(ax_j, axls, axss, counter, frame_load_sp, grid0, max_val, tags, top)
##############################################
# jetzt kommen die extra P-unit Eigen statistiken
#species = ' Eigenmannia virescens'
#cv_name = 'cv_base'
#ax = plt.subplot(grid[4, 0])
#for c, cell_type_here in enumerate(cell_types):
# frame_file = setting_overview_score(cell_type_here, frame_load_sp, species=species)
# plt_eigen(cv_name, ax, c, cell_type_here, cells_extra, colors, frame_file, max_val, score,
# species, x_axis, y_axis)
########################
# modell
model_plot = False
if model_plot:
model_overview_plot(grid0, scoreall)
#ax_j[0].get_shared_y_axes().join(*[ax_j[0],ax_j[2],ax_j[3]])
#ax_j[0].get_shared_y_axes().join(*[ax_j[1], ax_j[3], ax_j[5], axls[0], axls[1], axls[2]])
#ax_j[0].get_shared_x_axes().join(*ax_j)
#ax_j[0].get_shared_x_axes().join(*[ax_j[0],ax_j[1]])
#ax_j[2].get_shared_x_axes().join(*[ax_j[2], ax_j[3]])
#ax_j[4].get_shared_x_axes().join(*[ax_j[4], ax_j[5]])
#plt.show()
fig = plt.gcf()
fig.tag([[tags[0], tags[1], tags[3], tags[4], tags[6], tags[7]],[tags[2], tags[5], tags[8]]], xoffs=-4.2, yoffs=1.12)
show = False#True
save_visualization(pdf = True, show = show)
def reset_xlims(axls, axss, xmax):
axss[-1].set_ylim(0.5, xmax)
axls[-1].get_shared_y_axes().join(*[axss[-1], axls[-1]])
def species_letter(ax_cv, letter = 'A', species = r'\textit{Apteronotus leptorhynchus}'):
ax_cv.text(-0.26, 1.8, letter, ha='left',
transform=ax_cv.transAxes, fontsize=13.5)
ax_cv.text(-0.1, 1.8, species, ha='left',
transform=ax_cv.transAxes) # va='center',
def text_punits(ax_cv, colors, xpos = 0.35, ypos = 0.85):
ax_cv.text(xpos, ypos, r'P-units', ha='left', va='center',
transform=ax_cv.transAxes, color=colors[' P-unit'])
def fish_plt_false(ax_j, axls, axss, cell_types, colors, counter, grid0, log, max_val, save_names, score_burst_corr):
#####################################################################
x_axis = ["cv_base"] # , "cv_base_w_burstcorr","cv_base", ]
cv_name_title = ['CV'] # ,'CV$_{BurstCorr}$','CV']
species_all = [' Apteronotus leptorhynchus'] # ,' Apteronotus leptorhynchus',' Eigenmannia virescens']
ax_j, axls, axss, cell_types, frame_load_sp, max_val, score_burst_corr = species_with_both_cells(grid0[counter],
cell_types, ax_j,
axls, axss, colors,
cv_name_title,
save_names,
score_burst_corr,
species_all,
x_axis, log=log,
max_val=max_val)
counter += 1
#####################################################################
x_axis = ["cv_base"] # , "cv_base_w_burstcorr","cv_base", ]
cv_name_title = ['CV'] # ,'CV$_{BurstCorr}$','CV']
# embed()
species_all = [' Apteronotus albifrons'] # ,' Apteronotus leptorhynchus',' Eigenmannia virescens']
ax_j, axls, axss, cell_types, frame_load_sp, max_val, score_burst_corr = species_with_both_cells(grid0[-2],
cell_types, ax_j,
axls, axss, colors,
cv_name_title,
save_names,
score_burst_corr,
species_all,
x_axis,
max_val=max_val)
return axls, axss, counter, frame_load_sp, max_val, score_burst_corr
def version_final_overview():
return 'calc_RAM_overview-_simplified_noise_data12_nfft0.5sec_original__StimPreSaved4__direct_'
def NLI_burstcorr_name():
return 'NLI$(f_{BaseCorrected})$'#f_{BaseCorr}
def test_eodfr(burst_fraction, var_item_names, var_types, x_axis, x_axis_names, y_axis, y_axis_name):
########################################
# test
var_types = ['response_modulation']
x_axis = ['burst_fraction_burst_corr_individual_base']
var_item_names = ['Response Modulation [Hz]'] # 'Modulatoin'
x_axis_names = ['Burst Fraction$_{Base}$']
burst_fraction = [1, 1, 1, 1] # burst_fraction_burst_corr_individual_base
y_axis = ['eod_fr']
y_axis_name = ['EOD Fr']
return burst_fraction, var_item_names, var_types, x_axis, x_axis_names, y_axis, y_axis_name
def model_overview_plot(grid0, scoreall):
model = resave_small_files("models_big_fit_d_right.csv", load_folder='calc_model_core')
cells = model.cell.unique()
axm = plt.subplot(grid0[-3])
plt_model_overview2(axm, cells, scores=[scoreall + '_'])
plt.subplots_adjust(left=0.07, right=0.95, top=0.98, bottom=0.05, wspace=0.45, hspace=0.55)
def coherence_plot_modulation(ax_j, axls, axss, counter, frame_load_sp, grid0, max_val, tags, top):
cv_name = "cv_base"
species = ' Apteronotus leptorhynchus'
cell_type_here = ' P-unit'
# for c, cell_type_here in enumerate(cell_types):
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='min', species=species)
var_types = ['burst_fraction_burst_corr_individual_base'] # ,'response_modulation']
x_axis = ['cv_base'] # ,'burst_fraction_burst_corr_individual_base']
var_item_names = ['Burst Fraction'] # , 'Modulatoin' ]
x_axis_names = ['Burst Fraction$_{Base}$'] # ,'Burst Fraction$_{Base}$']
burst_fraction = [1] # , 1, 1, 1]#burst_fraction_burst_corr_individual_base
y_axis = ['mutual_informaiton_'] # , 'coherence_''burst_fraction_burst_corr_individual_stim']
y_axis_name = ['Mutual Information'] # , 'coherence''Burst Fraction$_{Stim}$']
# embed()
for v, var_type in enumerate(var_types):
# ax = plt.subplot(grid0[1+v])#grid_lower[0, v]
axk, axl, axs, axls, axss, ax_j = get_grid_4(ax_j, axls, axss, grid0[counter])
cmap, _, y_axis = plt_burst_modulation_hists(axk, axl, var_item_names[v], axs, cell_type_here,
x_axis[v], frame_file, max_val, y_axis[v],
burst_fraction=burst_fraction[v], xmin=0, ymin=0, top=top,
var_item=var_type)
axs.set_ylabel(y_axis_name[v])
axs.set_xlabel(x_axis_names[v])
# if v == 1:
# axs.plot([0, 1], [0, 1], color='grey', linewidth=0.5)
tags.append(axk)
counter += 1
# ax_j
def modulation_restrict(ax_j, axls, axs, axss, cell_types, counter, cv_name, frame_load_sp, grid0, log, max_val,
score_burst_corr, score_n, species, tags, top):
burst_corr_reset = 'response_modulation'
burst_fraction = [50] # , 1000, 1000] # ,1,1]
burst_fraction = [0.01] # , 1, 1] # ,1,1]
burst_corr_reset = 'burst_fraction_burst_corr_individual_stim'
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)
##############################################
# modulatoin comparison for both cell_types
################################
# Modulation, cell type comparison
# todo: hier die diff werte über die zellen
# ax_here = []
# axd = plt.subplot(grid_lower_lower[0, c])
# embed()
# kernel_histogram(axk, colors[str(cell_type_here)], np.array(x_axis), norm=True, step=0.03, alpha=0.5)
# embed()
# axk.show_spines('lb')
# axs = plt.subplot(grid0[6+c])
var_types = ['response_modulation']
x_axis = ['cv_base']
var_item_names = ['Response Modulation [Hz]', ] # 'Modulatoin'
x_axis_names = ['CV$_{Base}$']
y_axis = [score_burst_corr]
y_axis_name = [score_n]
for v, var_type in enumerate(var_types):
# ax = plt.subplot(grid0[1+v])#grid_lower[0, v]
axk, axl, axs, axls, axss, ax_j = get_grid_4(ax_j, axls, axss, grid0[counter])
cmap, _, y_axis = plt_burst_modulation_hists(axk, axl, var_item_names[v], axs, cell_type_here,
x_axis[v], frame_file, max_val, y_axis[v],
burst_fraction=burst_fraction[c], top=top,
burst_fraction_reset=burst_corr_reset, var_item=var_type)
axs.set_ylabel(y_axis_name[v])
axs.set_xlabel(x_axis_names[v])
# remove_yticks(axl)
if log:
axl.set_yscale('log')
axs.set_yscale('log')
axl.minorticks_off()
axl.set_yticks_blank()
tags.append(axk)
counter += 1
if c in [0, 2]:
######################################################
# hier kommen die kontrast Punkte dazu
# für die Zellen spielt Burst correctin ja keine Rolle
# if cv_n == 0:
if cell_type_here == ' P-unit':
cells_plot2 = p_units_to_show(type_here='contrasts')[0:2]
else:
cells_plot2 = [p_units_to_show(type_here='contrasts')[-1]]
# for cell_plt in cells_plot2:
cells_extra = frame_file[frame_file['cell'].isin(cells_plot2)].index
# ax = plt.subplot(grid[1, cv_n])
# todo: hier nur noch die kleinste und größte Amplitude nehmen
# embed()
axs.scatter(frame_file[cv_name].loc[cells_extra], frame_file[score_burst_corr].loc[cells_extra],
s=5, color='white', edgecolor='black', alpha=0.5, clip_on=False) # colors[str(cell_type_here)]
# cmap, _, y_axis = plt_modulation_overview(axs, c, cell_type_here,
# cv_name, frame_file, max_val, score,
# species)
# axs.set_ylabel(score)
# embed()#frame_file[(frame_file.cv_base < 0.65) & (frame_file.response_modulation > 200)].response_modulation
# axs.set_xlabel(cv_name)
# axs.get_shared_x_axes().join(*[axs, axd])
# elif species == ' Apteronotus albifrons':
# plt_albi(ax[4, 1], cell_type_here, colors, max_val, species, x_axis, y_axis)
# ax[1,cv_n].set_xlim(0, max_val)
# set_same_ylim(np.concatenate(ax[1::, :]))
# set_same_ylim(np.concatenate(ax[1::, :]),ylim_type ='xlim')
# set_same_ylim(ax[0, :], ylim_type='xlim')
# set_ylim_same()
# ax[1, 1].get_shared_y_axes().join(*ax[1, 1::])
# embed()
# counter += 1
# embed()
return ax_j, axls, axss, counter
def plt_var_axis(ax_j, axls, axss,score_name, burst_fraction, cell_type_here, counter, cv_name, frame_file, grid0, max_val, score,
scores_here, var_item_names, var_types, x_axis, x_axis_names, ymaxs = ['no'], n = True,counterplus = 1, extra_cells_false = False, extra_cells = True, ymins = ['no'], xmins = [], xlim = None, log = [False], top = False):
for v, var_type in enumerate(var_types):
# ax = plt.subplot(grid0[1+v])#grid_lower[0, v]
axk, axl, axs, axls, axss, ax_j = get_grid_4(ax_j, axls, axss, grid0[counter])
counter += counterplus
try:
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],
ymax = ymaxs[v], burst_fraction=burst_fraction[v], n = n, xlim = xlim, xmin = xmins[v],ymin =ymins[v], var_item=var_type, top = top)
except:
print('burst thing')
embed()
axk.show_spines('')
axl.show_spines('')
axs.set_ylabel(score_name[v])
axs.set_xlabel(x_axis_names[v])
if v in [0, 1]:
if log[v]:
axl.set_yscale('log')
axs.set_yscale('log')
axes = [axl, axs]
make_log_ticks(axes)
axl.set_yticks_blank()
# remove_yticks(axl)
axl.minorticks_off()
if extra_cells:
plot_extra_cells(axs, frame_file, scores_here, v, x_axis)
return ax_j, axls, axs, axss, counter
def plot_extra_cells(axs, frame_file, scores_here, v, x_axis, type_here = 'bursts'):
############################
# extra Zellen Scatter
# todo: diese Zellen müssen noch runter konvertiert werden
# todo: extra funktion für Zellen über 9 Snippets schreiben und die nochmal extra machen
cells_plot2 = p_units_to_show(type_here=type_here)
# for cell_plt in cells_plot2:
cells_extra = frame_file[frame_file['cell'].isin(cells_plot2)].index
# ax = plt.subplot(grid[1, cv_n])
#embed()
test_amps = False
if test_amps:
cells_here = frame_file.cell.unique()
cells_amp = ['2011-09-21-ab', '2010-06-21-am', '2012-05-15-ac', '2012-04-26-ae', '2012-05-07-ac',
'2010-06-21-ac']
cells_amp = update_cell_names(cells_amp)
# frame_amps = frame_file[frame_file.cell.isin(cells_amp)]
for cell_amp in cells_amp:
if cell_amp in cells_here:
print(cell_amp)
# cells_plot = update_cell_names(cells_search)
try:
axs.scatter(frame_file[x_axis[v]].loc[cells_extra], frame_file[scores_here[v]].loc[cells_extra],
s=5, color='white', edgecolor='black', alpha=0.5,
clip_on=False) # colors[str(cell_type_here)]
except:
print('small things')
embed()
def species_with_both_cells(grid0, cell_types, ax_j, axls, axss, colors, cv_name_title, save_names, score, species_all, x_axis, log = True, n = True,ylim = None, alpha = 1, max_val = 1.5, score_n ='Perc(99)/Median'):
for cv_n, cv_name in enumerate(x_axis):
if cv_n == 0:
redo = False
else:
redo = False
redo = False
frame_load_sp = load_overview_susept(save_names[0], redo=redo, redo_class=redo)
if len(frame_load_sp.cell.unique()) <470:
# double check if the file is the newest
#hostname, password, root, username = credencials0()
dated_up = update_ssh_file(load_folder_name('calc_RAM') + '/' + save_names[0] + '.csv')
if dated_up == 'yes':
frame_load_sp = load_overview_susept(save_names[0], redo=True, redo_class=redo)
#res = pysftp.put(filepath, destination)
#ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(cmd_to_execute)
#ssh
#embed()
# frame_file = setting_overview_score(cell_type_here, frame_load_sp, min_amp=True, species=species)
# print(np.isnan(species))
for c, cell_type_here in enumerate(cell_types):
#if c == 1:
# embed()
species = species_all[cv_n]
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='min', species=species)
##################################
# modulation and species comparison
# x_axis, y_axis = get_axis(cv_name, frame_file, score)
# if cv_n == 0:
###############################
#######################
# Kernel Histogram
# plot the histograms of the values above the according vals
# grid = gridspec.GridSpecFromSubplotSpec(1, 1, grid0[0],hspace=0, wspace = 0.15)#grid[0, cv_n]
#
if c == 0:
axk, axl, axs, axls, axss, ax_j = get_grid_4(ax_j, axls, axss, grid0)
if c in [0, 2]:
axk.set_title(species)
# embed()
if len(frame_file) > 0:
if log:
ymin = 'no'
else:
ymin = 0
xmin = 0
if ylim:
axs.set_ylim(ylim)
axs, x_axis = kernel_scatter(axl, cell_types, axk, axs, ax_j, c, cell_type_here, colors, cv_n, cv_name,
frame_file, grid0, max_val,
score, log = log,alpha = alpha, n = n,xmin = xmin, ymin = ymin)
if log:
axl.set_yscale('log')
make_log_ticks([axs])
axl.set_yticks_blank()
axl.minorticks_off()
axs.set_xlabel(cv_name_title[cv_n])
if cv_n == 0:
axs.set_ylabel(score_n)
axl.show_spines('')
axk.show_spines('')
if cv_n == 0:
axm = [axs]
return ax_j, axls, axss, cell_types, frame_load_sp, max_val, score
def get_grid_4(ax_j, axls, axss, grid0):
grid_k = gridspec.GridSpecFromSubplotSpec(2, 2, grid0,
hspace=0.1, wspace=0.1, height_ratios=[0.35, 3], width_ratios=[3, 0.5])
axk = plt.subplot(grid_k[0, 0])
ax_j.append(axk)
axs = plt.subplot(grid_k[1, 0])
axss.append(axs)
axl = plt.subplot(grid_k[1, 1])
axls.append(axl)
return axk, axl, axs, axls, axss, ax_j
if __name__ == '__main__':
data_overview2()

Binary file not shown.

View File

@ -1,408 +0,0 @@
#from utils_suseptibility import default_settings
#from plt_RAM import model_and_data_isi, model_cells
#from utils_suseptibility import model_and_data, remove_yticks
#from utils_suseptibility import *
#from utils_susept import nonlin_title, plt_data_susept, plt_single_square_modl, set_clim_same_here, set_xlabel_arrow, \
# set_ylabel_arrow, \
# xpos_y_modelanddata
#from utils_all import default_settings, find_cell_add, get_flowchart_params, load_folder_name, load_model_susept, \
# overlap_cells, \
# plot_lowpass2, plt_time_arrays, remove_xticks, remove_yticks, resave_small_files, save_visualization, set_same_ylim
from utils_suseptibility import *#model_and_data
#from plt_RAM import model_and_data, model_and_data_sheme, model_and_data_vertical2
def table_printen(table):
print(table.keys())
for l in range(len(table)):
list_here = np.array(table.iloc[l])
l1 = "& ".join(list_here)
print(l1)
def model_and_data2(width=0.005, nffts=['whole'], powers=[1], cells=["2013-01-08-aa-invivo-1"], show=False,
contrasts=[0], noises_added=[''], D_extraction_method=['additiv_cv_adapt_factor_scaled'],
internal_noise=['RAM'], external_noise=['RAM'], level_extraction=[''], receiver_contrast=[1],
dendrids=[''], ref_types=[''], adapt_types=[''], c_noises=[0.1], c_signal=[0.9], cut_offs1=[300],
label=r'$\frac{1}{mV^2S}$'): # ['eRAM']
# plot_style()#['_RAMscaled']'_RAMscaled'
duration_noise = '_short',
formula = 'code' ##'formula'
# ,int(2 ** 16) int(2 ** 16), int(2 ** 15),
stimulus_length = 1 # 20#550 # 30 # 15#45#0.5#1.5 15 45 100
trials_nrs = [1] # [100, 500, 1000, 3000, 10000, 100000, 1000000] # 500
stimulus_type = '_StimulusOrig_' # ,#
# ,3]#, 3, 1, 1.5, 0.5, ] # ,1,1.5, 0.5] #[1,1.5, 0.5] # 1.5,0.5]3, 1,
variant = 'sinz'
mimick = 'no'
cell_recording_save_name = ''
trans = 1 # 5
rep = 1000000 # 500000#0
repeats = [20, rep] # 250000
aa = 0
good_data, remaining = overlap_cells()
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,
hspace=0.18, left=0.09, right=0.93, top=0.94)
a = 0
maxs = []
mins = []
mats = []
ims = []
perc05 = []
perc95 = []
iternames = [D_extraction_method, external_noise,
internal_noise, powers, nffts, dendrids, cut_offs1, trials_nrs, c_signal,
c_noises,
ref_types, adapt_types, noises_added, level_extraction, receiver_contrast, contrasts, ]
nr = '2'
# embed()
# cell_contrasts = ["2013-01-08-aa-invivo-1"]
# cells_triangl_contrast = np.concatenate([cells_all,cell_contrasts])
# cells_triangl_contrast = 1
# cell_contrasts = 1
rows = len(cells_all) # len(good_data)+len(cell_contrasts)
perc = 'perc'
lp = 2
label_model = r'Nonlinearity $\frac{1}{S}$'
for all in it.product(*iternames):
var_type, stim_type_afe, stim_type_noise, power, nfft, dendrid, cut_off1, trial_nrs, c_sig, c_noise, ref_type, adapt_type, noise_added, extract, a_fr, a_fe = all
# print(trials_stim,stim_type_noise, power, nfft, a_fe,a_fr, dendrid, var_type, cut_off1,trial_nrs)
fig = plt.figure()
hs = 0.45
#################################
# data cells
# embed()
grid_data = gridspec.GridSpecFromSubplotSpec(1, 1, grid[0, 1],
hspace=hs)
#ypos_x_modelanddata()
nr = 1
ax_data, stack_spikes_all, eod_frs = plt_data_susept(fig, grid_data, cells_all, cell_type='p-unit', width=width,
cbar_label=True, nr = nr, amp_given = 1,xlabel = False, lp=lp, title=True)
for ax_external in ax_data:
# ax.set_ylabel(F2_xlabel())
# remove_xticks(ax)
ax_external.set_xticks_delta(100)
set_ylabel_arrow(ax_external, xpos=xpos_y_modelanddata(), ypos=0.87)
#embed()
set_xlabel_arrow(ax_external, ypos=ypos_x_modelanddata())
# ax.text(-0.42, 0.87, F2_xlabel(), ha='center', va='center',
# transform=ax.transAxes, rotation = 90)
# ax.text(1.66, 0.5, nonlin_title(), rotation=90, ha='center', va='center',
# transform=ax.transAxes)
ax_external.arrow_spines('lb')
#embed()
#plt.show()
##################################
# model part
trial_nr = 500000
cell = '2013-01-08-aa-invivo-1'
cell = '2012-07-03-ak-invivo-1'
print('cell'+str(cell))
cells_given = [cell]
save_name_rev = load_folder_name(
'calc_model') + '/' + '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_' + str(
trial_nr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV_revQuadrant_'
# for trial in trials:#.009
trial_nr = 1000000#1000000
save_names = [
'calc_RAM_model-2__nfft_whole_power_1_afe_0.009_RAM_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_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_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',
]
nrs_s = [2, 3, 6, 7, 10, 11]
#embed()
tr_name = trial_nr/1000000
if tr_name == 1:
tr_name = 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\,\%$ ']#%
ax_model = []
for s, sav_name in enumerate(save_names):
try:
ax_external = plt.subplot(grid[nrs_s[s]])
except:
print('vers something')
embed()
ax_model.append(ax_external)
save_name = load_folder_name('calc_model') + '/' + sav_name
cell_add, cells_save = find_cell_add(cells_given)
perc = 'perc'
path = save_name + '.pkl' # '../'+
# stack = get_stack_one_quadrant(cell, cell_add, cells_save, path, save_name)
# full_matrix = create_full_matrix2(np.array(stack), np.array(stack_rev))
# stack_final = get_axis_on_full_matrix(full_matrix, stack)
# im = plt_RAM_perc(ax, perc, np.abs(stack))
# embed()
stack = load_model_susept(path, cells_save, save_name.split(r'/')[-1] + cell_add)
if len(stack)> 0:
add_nonlin_title, cbar, fig, stack_plot, im = plt_single_square_modl(ax_external, cell, stack, perc, titles[s],
width, titles_plot=True,
resize=True, nr = nr)
# if s in [1,3,5]:
ims.append(im)
mats.append(stack_plot)
maxs.append(np.max(np.array(stack_plot)))
mins.append(np.min(np.array(stack_plot)))
col = 2
row = 3
ax_external.set_xticks_delta(100)
ax_external.set_yticks_delta(100)
# cbar[0].set_label(nonlin_title(add_nonlin_title)) # , labelpad=100
cbar.set_label(nonlin_title(' ['+add_nonlin_title), labelpad=lp) # rotation=270,
if (s in np.arange(col - 1, 100, col)) | (s == 0):
remove_yticks(ax_external)
else:
set_ylabel_arrow(ax_external, xpos=xpos_y_modelanddata(), ypos=0.87)
if s >= row * col - col:
set_xlabel_arrow(ax_external, ypos=ypos_x_modelanddata())
# ax.set_xlabel(F1_xlabel(), labelpad=20)
else:
remove_xticks(ax_external)
if len(cells) > 1:
a += 1
set_clim_same_here(ims, mats=mats, lim_type='up', nr_clim='perc', clims='', percnr=95)
#################################################
# Flowcharts
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]
ylim = [-0.5, 0.5]
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]]):
grid_lowpass = gridspec.GridSpecFromSubplotSpec(4, 1,
subplot_spec=grid_here, hspace=0.3,
height_ratios=[1, 1,1, 0.1])
models = resave_small_files("models_big_fit_d_right.csv", load_folder='calc_model_core')
model_params = models[models['cell'] == '2012-07-03-ak-invivo-1'].iloc[0]
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]
# embed()eod_fr = stack.eod_fr.iloc[0]
print(var_types[g] + ' a_fe ' + str(a_fes[g]))
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,
subplot_spec=grid_here,height_ratios=[1, 1,1, 0.1], hspace=0.2)
# if (np.unique(frame.RAM_afe) != 0):grid_left[g]
ax_external = plt_time_arrays('red', grid_lowpass2, 1, (frame.RAM_afe)*100, time=time, nr=0)
# if (np.unique(frame.RAM_noise) != 0):
remove_xticks(ax_external)
ax_intrinsic = plt_time_arrays('purple', grid_lowpass2, 1, (frame.RAM_noise)*100, time=time, nr=1)
ax_intrinsic.text(-0.6, 0.5, '$\%$', rotation=90, va='center', transform=ax_intrinsic.transAxes)
ax_intrinsic.show_spines('l')
ax_external.show_spines('l')
# ax_ams.append(axt_p2)
#color_timeseries = 'black'
#axt_p2.set_xlabel('Time [ms]')
#axt_p2.text(-0.6, 0.5, '$\%$', rotation=90, va='center', transform=axt_p2.transAxes)
#ax_ams.append(axt_p2)
vers = 'all'
elif (len(np.unique(frame.RAM_afe)) > 1):
color_timeseries = 'red'
nr_plot = 0
print(str(g) + ' afevar ' + str(np.var(frame.RAM_afe)) + ' afenoise ' + str(np.var(frame.RAM_noise)))
try:
ax_external, ff, pp, ff_am, pp_am = plot_lowpass2([grid_lowpass[nr_plot]], time,
(frame.RAM_afe + frame.RAM_noise)*100,
deltat, eod_fr,
color1=color_timeseries, lw=1, extract=False)
except:
print('add up thing')
embed()
ax_external.show_spines('l')
ax_intrinsic = plt.subplot(grid_lowpass[1])
ax_intrinsic.show_spines('l')
ax_intrinsic.axhline(0, color='black', lw=0.5)
ax_intrinsic.axhline(0, color='purple', lw=0.5)
remove_xticks(ax_external)
remove_xticks(ax_intrinsic)
join_x([ax_intrinsic, ax_external])
join_y([ax_intrinsic, ax_external])
vers = 'first'
elif (len(np.unique(frame.RAM_noise)) > 1):
color_timeseries = 'purple'
nr_plot = 1
print(str(g) + ' afevar ' + str(np.var(frame.RAM_afe)) + ' afenoise ' + str(np.var(frame.RAM_noise)))
try:
ax_intrinsic, ff, pp, ff_am, pp_am = plot_lowpass2([grid_lowpass[nr_plot]], time, (frame.RAM_afe + frame.RAM_noise)*100,
deltat, eod_fr,
color1=color_timeseries, lw=1, extract=False)
except:
print('add up thing')
embed()
ax_external = plt.subplot(grid_lowpass[0])
ax_external.show_spines('l')
ax_intrinsic.show_spines('l')
ax_external.axhline(0, color='black', lw=0.5)
ax_external.axhline(0, color='red', lw=0.5)
join_x([ax_intrinsic,ax_external])
join_y([ax_intrinsic, ax_external])
vers = 'second'
ax_external.text(-0.6, 0.5, '$\%$', va='center', rotation=90, transform=ax_external.transAxes)
ax_intrinsic.text(-0.6, 0.5, '$\%$', va='center', rotation=90, transform=ax_intrinsic.transAxes)
remove_xticks(ax_intrinsic)
# if (len(np.unique(frame.RAM_afe)) > 1) & (len(np.unique(frame.RAM_noise)) > 1):
ax_external.set_xlabel('')
# remove_yticks(ax)
ax_ams.append(ax_external)
remove_xticks(ax_external)
# embed()
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:
ax_n.set_xlabel('Time [ms]', labelpad = -0.5)
else:
remove_xticks(ax_n)
ax_n.set_ylim(ylim)
if vers == 'first':
ax_external.text(1, 1, 'RAM', ha='right', color='red', transform=ax_external.transAxes)
ax_n.text(start_pos_modeldata(), 1.1, noise_component_name(), ha='right', color='gray',
transform=ax_n.transAxes)
elif vers == 'second':
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)
ax_n.text(start_pos_modeldata(), 0.8, noise_component_name(), ha='right', color='gray',
transform=ax_n.transAxes)
else:
ax_n.text(start_pos_modeldata(), 0.8, noise_component_name(), ha='right', color='gray',
transform=ax_n.transAxes)
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)
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])
#ax_data.extend([,])
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([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],
save_visualization(pdf=True)
def start_pos_modeldata():
return 1.03
def signal_component_name():
return 'Signal component'#'signal noise'
def noise_component_name():
return 'Noise component'#'intrinsic noise'
def ypos_x_modelanddata():
return -0.45
if __name__ == '__main__':
model = resave_small_files("models_big_fit_d_right.csv", load_folder='calc_model_core')
cells = model.cell.unique()
# embed()
params = {'cells': cells}
show = True
# if show == False:
# low CV: cells = ['2012-07-03-ak-invivo-1']
plot_style()
default_settings(lw=0.5, column=2, length=3.35) #8.5
redo = False
D_extraction_method = ['additiv_cv_adapt_factor_scaled']
# D_extraction_method = ['additiv_visual_d_4_scaled']
##########################
# hier printen wir die table Werte zum kopieren in den Text
table = pd.read_csv('print_table_suscept-model_params_suscept_table.csv')
table_printen(table)
table = pd.read_csv('print_table_all-model_params_suscept_table.csv')
print('model big')
table_printen(table)
#embed()
##########################
#embed()
model_and_data2(width=0.005, show=show, D_extraction_method=D_extraction_method,
label=r'$\frac{1}{mV^2S}$') #r'$\frac{1}{mV^2S}$'

Binary file not shown.

View File

@ -1,108 +0,0 @@
from utils_suseptibility import *
def model_full():
plot_style()
default_figsize(column=2, length=2.3)
grid = gridspec.GridSpec(1, 2, wspace=0.6, bottom = 0.1,hspace=0.15, top=0.95, left=0.075, right=0.87)
axes = []
##################################
# model part
ls = '--'
lw = 0.5
ax = plt.subplot(grid[1])
axes.append(ax)
perc,im,stack_final = plt_model_big(ax, ls = ls, lw = 0.5)
# if len(cbar) > 0:
###############################
# data part
ax = plt.subplot(grid[0])
axes.append(ax)
cell = '2012-07-03-ak-invivo-1'
mat_rev,stack_final_rev = load_stack_data_susept(cell, save_name = version_final(), end = '_revQuadrant_')
mat, stack = load_stack_data_susept(cell, save_name=version_final(), end = '')
#embed()
#try:
full_matrix = create_full_matrix2(np.array(mat),np.array(mat_rev))
#except:
# print('full matrix something')
# embed()
stack_final = get_axis_on_full_matrix(full_matrix, mat)
abs_matrix = np.abs(stack_final)
#embed()
#if np.
abs_matrix, add_nonlin_title, resize_val = rescale_colorbar_and_values(abs_matrix)
ax.axhline(0, color = 'white', linestyle = ls, linewidth = lw)
ax.axvline(0, color='white', linestyle = ls, linewidth = lw)
im = plt_RAM_perc(ax, perc, abs_matrix)
cbar, left, bottom, width, height = colorbar_outside(ax, im, add=5, width=0.01)
set_clim_same_here([im], mats=[abs_matrix], lim_type='up', nr_clim='perc', clims='', percnr=95)
#clim = im.get_clim()
#if clim[1]> 1000:
#todo: change clim values with different Hz values
#embed()
cbar.set_label(nonlin_title(add_nonlin_title = ' ['+add_nonlin_title), rotation=90, labelpad=8)
set_ylabel_arrow(ax, xpos = -0.07, ypos = 0.97)
set_xlabel_arrow(ax, xpos=1, ypos=-0.07)
''' eod_fr, stack_spikes = plt_data_suscept_single(ax, cbar_label, cell, cells, f, fig, file_names_exclude, lp, title,
width)'''
cbar, left, bottom, width, height = colorbar_outside(ax, im, add=5, width=0.01)
#print('finished model_full')
fig = plt.gcf()
#axes = plt.gca()
fig.tag(axes[::-1], xoffs=-4.5, yoffs=0.4) # ax_ams[3],
save_visualization()
def load_stack_data_susept(cell, save_name, end = ''):
load_name = load_folder_name('calc_RAM') + '/' + save_name+end
add = '_cell' + cell +end# str(f) # + '_amp_' + str(amp)
#embed()
stack_cell = load_data_susept(load_name + '_' + cell + '.pkl', load_name + '_' + cell, add=add,
load_version='csv')
file_names_exclude = get_file_names_exclude()
stack_cell = stack_cell[~stack_cell['file_name'].isin(file_names_exclude)]
# if len(stack_cell):
file_names = stack_cell.file_name.unique()
#embed()
file_names = exclude_file_name_short(file_names)
cut_off_nr = get_cutoffs_nr(file_names)
try:
maxs = list(map(float, cut_off_nr))
except:
embed()
file_names = file_names[np.argmax(maxs)]
#embed()
stack_file = stack_cell[stack_cell['file_name'] == file_names]
amps = [np.min(stack_file.amp.unique())]
amps = restrict_punits(cell, amps)
amp = np.min(amps)#[0]
# for amp in amps:
stack_amps = stack_file[stack_file['amp'] == amp]
lengths = stack_amps.stimulus_length.unique()
trial_nr_double = stack_amps.trial_nr.unique()
trial_nr = np.max(trial_nr_double)
stack_final = stack_amps[
(stack_amps['stimulus_length'] == np.max(lengths)) & (stack_amps.trial_nr == trial_nr)]
mat, new_keys = get_mat_susept(stack_final)
return mat,stack_final
if __name__ == '__main__':
model_full()

View File

@ -1,4 +1,4 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.2) (preloaded format=pdflatex 2021.5.16) 22 FEB 2024 22:43
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.2) (preloaded format=pdflatex 2021.5.16) 23 FEB 2024 13:46
entering extended mode
**./susceptibility1.tex
(susceptibility1.tex
@ -1004,61 +1004,97 @@ Package natbib Warning: Citation `Neiman2011fish' on page 10 undefined on input
line 631.
Package natbib Warning: Citation `Maler2009a' on page 10 undefined on input lin
e 641.
Package natbib Warning: Citation `Hladnik2023' on page 10 undefined on input li
ne 645.
ne 641.
Package natbib Warning: Citation `Stamper2012Envelope' on page 10 undefined on
input line 652.
Package natbib Warning: Citation `Beiran2018' on page 10 undefined on input lin
e 641.
Package natbib Warning: Citation `Middleton2006' on page 10 undefined on input
line 652.
Package natbib Warning: Citation `Hladnik2023' on page 10 undefined on input li
ne 641.
Package natbib Warning: Citation `Middleton2007' on page 10 undefined on input
line 652.
LaTeX Warning: Reference `ROC_with_nonlin' on page 10 undefined on input line 6
45.
Package natbib Warning: Citation `Savard2011' on page 10 undefined on input lin
e 652.
Package natbib Warning: Citation `Schlungbaum2023' on page 10 undefined on inpu
t line 645.
LaTeX Warning: Reference `data_overview' on page 10 undefined on input line 652
.
LaTeX Warning: Reference `ROC_with_nonlin' on page 10 undefined on input line 6
45.
Package natbib Warning: Citation `Grewe2017' on page 10 undefined on input line
645.
Package natbib Warning: Citation `Hladnik2023' on page 10 undefined on input li
ne 645.
LaTeX Warning: Reference `ROC_with_nonlin' on page 10 undefined on input line 6
45.
[10]
Package natbib Warning: Citation `Stamper2012Envelope' on page 11 undefined on
input line 660.
Package natbib Warning: Citation `Middleton2006' on page 11 undefined on input
line 660.
Package natbib Warning: Citation `Middleton2007' on page 11 undefined on input
line 660.
Package natbib Warning: Citation `Middleton2007' on page 11 undefined on input
line 660.
Package natbib Warning: Citation `Savard2011' on page 11 undefined on input lin
e 660.
Package natbib Warning: Citation `Tan2005' on page 11 undefined on input line 6
56.
64.
Package natbib Warning: Citation `Stamper2010' on page 11 undefined on input li
ne 656.
ne 664.
LaTeX Warning: Reference `cocktail party' on page 11 undefined on input line 65
6.
LaTeX Warning: Reference `cocktail party' on page 11 undefined on input line 66
4.
Package natbib Warning: Citation `Henninger2018' on page 11 undefined on input
line 656.
line 664.
Package natbib Warning: Citation `Voronenko2017' on page 11 undefined on input
line 659.
line 667.
[11]
Package natbib Warning: Citation `Grewe2017' on page 12 undefined on input line
704.
712.
Package natbib Warning: Citation `Hladnik2023' on page 12 undefined on input li
ne 704.
ne 712.
LaTeX Warning: Reference `heterogeneity' on page 12 undefined on input line 704
LaTeX Warning: Reference `heterogeneity' on page 12 undefined on input line 712
.
@ -1068,97 +1104,99 @@ pdfTeX warning: pdflatex (file ./Settup.pdf): PDF inclusion: found PDF version
<Settup.pdf, id=507, 963.6pt x 414.22754pt>
File: Settup.pdf Graphic file (type pdf)
<use Settup.pdf>
Package pdftex.def Info: Settup.pdf used on input line 730.
Package pdftex.def Info: Settup.pdf used on input line 738.
(pdftex.def) Requested size: 468.0pt x 201.1782pt.
LaTeX Warning: `!h' float specifier changed to `!ht'.
[12]
Package natbib Warning: Citation `Stoewer2014' on page 12 undefined on input li
ne 767.
Package natbib Warning: Citation `Stoewer2014' on page 13 undefined on input li
ne 775.
[12] [13 <./Settup.pdf>]
[13 <./Settup.pdf>]
LaTeX Warning: Reference `data_overview' on page 14 undefined on input line 877
LaTeX Warning: Reference `data_overview' on page 14 undefined on input line 885
.
LaTeX Warning: Reference `burst_cells_suscept' on page 14 undefined on input li
ne 877.
ne 885.
LaTeX Warning: Reference `cells_eigen' on page 14 undefined on input line 877.
LaTeX Warning: Reference `cells_eigen' on page 14 undefined on input line 885.
Package natbib Warning: Citation `Chacron2001' on page 14 undefined on input li
ne 890.
ne 898.
Package natbib Warning: Citation `Sinz2020' on page 14 undefined on input line
890.
898.
[14]
Package natbib Warning: Citation `Fourcaud-Trocme2003' on page 15 undefined on
input line 940.
input line 948.
<flowchart.pdf, id=560, 489.3874pt x 339.66899pt>
<flowchart.pdf, id=558, 489.3874pt x 339.66899pt>
File: flowchart.pdf Graphic file (type pdf)
<use flowchart.pdf>
Package pdftex.def Info: flowchart.pdf used on input line 944.
Package pdftex.def Info: flowchart.pdf used on input line 952.
(pdftex.def) Requested size: 468.0pt x 324.82944pt.
Package natbib Warning: Citation `Ott2020' on page 15 undefined on input line 9
74.
82.
[15]
LaTeX Warning: Reference `beat' on page 15 undefined on input line 985.
LaTeX Warning: Reference `beat' on page 16 undefined on input line 993.
[15] [16 <./flowchart.pdf>]
[16 <./flowchart.pdf>]
Package natbib Warning: Citation `Novikov1965' on page 17 undefined on input li
ne 1005.
ne 1013.
Package natbib Warning: Citation `Furutsu1963' on page 17 undefined on input li
ne 1005.
ne 1013.
Package natbib Warning: Citation `Egerland2020' on page 17 undefined on input l
ine 1005.
ine 1013.
Package natbib Warning: Citation `Novikov1965' on page 17 undefined on input li
ne 1029.
ne 1037.
Package natbib Warning: Citation `Furutsu1963' on page 17 undefined on input li
ne 1029.
ne 1037.
Package natbib Warning: Citation `Egerland2020' on page 17 undefined on input l
ine 1029.
ine 1037.
Package natbib Warning: Citation `Ott2020' on page 17 undefined on input line 1
043.
051.
Package natbib Warning: Citation `Ott2020' on page 17 undefined on input line 1
043.
051.
[17]
<cells_suscept_high_CV.pdf, id=629, 489.3874pt x 267.39899pt>
File: cells_suscept_high_CV.pdf Graphic file (type pdf)
<use cells_suscept_high_CV.pdf>
Package pdftex.def Info: cells_suscept_high_CV.pdf used on input line 1090.
Package pdftex.def Info: cells_suscept_high_CV.pdf used on input line 1098.
(pdftex.def) Requested size: 489.38622pt x 267.39833pt.
Overfull \hbox (21.38622pt too wide) in paragraph at lines 1090--1093
Overfull \hbox (21.38622pt too wide) in paragraph at lines 1098--1101
[][]
[]
(susceptibility1.bbl) [18 <./cells_suscept_high_CV.pdf>]
(susceptibility1.bbl) [18 <./cells_suscept_high_CV.pdf>] [19]
Package natbib Warning: There were undefined citations.
@ -1170,14 +1208,23 @@ See the caption package documentation for explanation.
LaTeX Warning: There were undefined references.
Package rerunfilecheck Info: File `susceptibility1.out' has not changed.
(rerunfilecheck) Checksum: 86758D0DA4F18F509F918859B173A0F4;7460.
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
Package rerunfilecheck Warning: File `susceptibility1.out' has changed.
(rerunfilecheck) Rerun to get outlines right
(rerunfilecheck) or use package `bookmark'.
Package rerunfilecheck Info: Checksums for `susceptibility1.out':
(rerunfilecheck) Before: 86758D0DA4F18F509F918859B173A0F4;7460
(rerunfilecheck) After: 1F46864C96A9861AD5E13A6956E744D8;7514.
)
Here is how much of TeX's memory you used:
13372 strings out of 479334
196704 string characters out of 2857084
13374 strings out of 479334
196728 string characters out of 2857084
547701 words of memory out of 3000000
30535 multiletter control sequences out of 15000+200000
30536 multiletter control sequences out of 15000+200000
415007 words of font info for 70 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
83i,17n,88p,2575b,440s stack positions out of 5000i,500n,10000p,200000b,50000s
@ -1219,9 +1266,9 @@ c/cm-super/sfrm1000.pfb><C:/Users/alexi/AppData/Local/Programs/MiKTeX/fonts/typ
e1/urw/helvetic/uhvr8a.pfb><C:/Users/alexi/AppData/Local/Programs/MiKTeX/fonts/
type1/urw/helvetic/uhvro8a.pfb><C:/Users/alexi/AppData/Local/Programs/MiKTeX/fo
nts/type1/urw/symbol/usyr.pfb>
Output written on susceptibility1.pdf (18 pages, 1546206 bytes).
Output written on susceptibility1.pdf (19 pages, 1548534 bytes).
PDF statistics:
774 PDF objects out of 1000 (max. 8388607)
91 named destinations out of 1000 (max. 500000)
779 PDF objects out of 1000 (max. 8388607)
92 named destinations out of 1000 (max. 500000)
310 words of extra memory for PDF output out of 10000 (max. 10000000)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff