624 lines
31 KiB
Python
624 lines
31 KiB
Python
#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() |