improving code for plots
BIN
ampullary.pdf
@ -4,8 +4,6 @@ from threefish.RAM.plots import ampullary_punit
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
cells_plot2 = cells_to_show_susceptibility(plot_choice='amp')
|
||||
ampullary_punit(eod_metrice = False, base_extra = True, color_same = False, fr_name = '$f_{base}$', tags_individual = True, isi_delta = 5, titles=[''],
|
||||
cells_plot=cells_plot2, RAM=False, scale_val = False, add_texts = [0.25, 1.3])#Low-CV ampullary cell,
|
@ -208,12 +208,10 @@ def printing_values_data_overview(cell_types, frame_load_sp, scores, species, x_
|
||||
x = frame_file['fr_base']
|
||||
y = frame_file['ser_first']
|
||||
c = frame_file['cv_base']
|
||||
try:
|
||||
c_axis, x_axis, y_axis, exclude_here = exclude_nans_for_corr(frame_file, corr_var, cv_name=corr_var,
|
||||
|
||||
c_axis, x_axis, y_axis, exclude_here = exclude_nans_for_corr(frame_file, corr_var, cv_name=corr_var,
|
||||
score=score)
|
||||
except:
|
||||
print('frame file lost')
|
||||
embed()
|
||||
|
||||
corr, p_value = stats.pearsonr(x_axis, y_axis)
|
||||
pears_l = label_pearson(corr, p_value, y_axis, n=True)
|
||||
print(start_name(cell_type_here, species) + ' ' + corr_var + ' to ' + str(score) + pears_l)
|
||||
@ -328,15 +326,13 @@ def printing_values_data_overview(cell_types, frame_load_sp, scores, species, x_
|
||||
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='', species=species)
|
||||
|
||||
if len(frame_file) > 0:
|
||||
try:
|
||||
print(start_name(cell_type_here, species) + ' CV_min ' + str(
|
||||
|
||||
print(start_name(cell_type_here, species) + ' CV_min ' + str(
|
||||
np.round(np.nanmin(frame_file.cv_base), 2)) + ' CV max ' + str(
|
||||
np.round(np.nanmax(frame_file.cv_base), 2)) + ' FR max ' + str(
|
||||
np.round(np.nanmin(frame_file.fr_base))) + ' FR max ' + str(
|
||||
np.round(np.nanmax(frame_file.fr_base))))
|
||||
except:
|
||||
print('min here')
|
||||
embed()
|
||||
|
||||
############################################
|
||||
#######
|
||||
# N
|
||||
|
BIN
flowchart.pdf
BIN
flowchart.png
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
10
flowchart.py
@ -1,14 +1,4 @@
|
||||
#from utils0import default_settings
|
||||
#from plt_RAM import model_and_data_isi, model_cells
|
||||
#from threefish.utils0 import default_settings, resave_small_files
|
||||
#from plt_RAM import model_and_data, model_and_data_sheme, model_and_data_vertical2
|
||||
# from threefish.utils0 import default_settings, resave_small_files
|
||||
# from plt_RAM import model_and_data, model_and_data_sheme, model_and_data_vertical2
|
||||
|
||||
# from threefish.utils0 import default_settings, resave_small_files
|
||||
# from plt_RAM import model_and_data, model_and_data_sheme, model_and_data_vertical2
|
||||
# from threefish.utils0 import default_settings, resave_small_files
|
||||
# from plt_RAM import model_and_data, model_and_data_sheme, model_and_data_vertical2
|
||||
import matplotlib.gridspec as gridspec
|
||||
|
||||
from plotstyle import plot_style
|
||||
|
@ -42,7 +42,6 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
|
||||
|
||||
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
|
||||
rep = 1000000 # 500000#0
|
||||
good_data, remaining = overlap_cells()
|
||||
cells_all = [good_data[0]]
|
||||
|
||||
@ -62,17 +61,8 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
|
||||
c_noises,
|
||||
ref_types, adapt_types, noises_added, level_extraction, receiver_contrast, contrasts, ]
|
||||
|
||||
nr = '2'
|
||||
|
||||
# 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
|
||||
@ -101,111 +91,20 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
|
||||
##################################
|
||||
# model part
|
||||
|
||||
trial_nr = 100000
|
||||
cell = '2013-01-08-aa-invivo-1'
|
||||
cell = '2012-07-03-ak-invivo-1'
|
||||
|
||||
cells_given = [cell]
|
||||
save_name_rev = find_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.025_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.025_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_' + str(
|
||||
trial_nr) + '_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_' + str(
|
||||
trial_nr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
|
||||
|
||||
]
|
||||
|
||||
|
||||
##########
|
||||
# Erklärung
|
||||
# Ich habe hier 0.009 und nicht 0.25 weil das Modell einen Fehler hat
|
||||
# den Stimulus in den Daten habe ich überprüft der tatsächliche stimulus ist 2.3 Prozent
|
||||
# sollte aber 2.5 Prozent sein
|
||||
# Im Fall von 2.5 Prozent wäre das ein Fehler von 0.36 sonst von 0.39
|
||||
# Hier werde ich nun mit dem Fehler von 0.36 verfahren
|
||||
# das bedeutet aber das sich den Stimulus zwar mit 0.009 ins Modell reintue später für die
|
||||
# Susceptiblitätsberechnung sollte ich ihn aber um den Faktor 0.36 teilen
|
||||
|
||||
# oben habe ich einen bias factor weil die Zelle zu sensitiv gefittet ist, also passe ich das an dass die den
|
||||
# gleichen CV und feurrate hat, wie die Zelle in der Stimulation, deswegen ist dieser Bias faktor nur oben!
|
||||
#
|
||||
#bias_factors = [1, 1, 1, 1] # 0.3
|
||||
bias_factors = [0.36, 0.36, 1, 1] # 0.36
|
||||
bias_factors = [1, 1, 1, 1] # 0.36
|
||||
|
||||
#new
|
||||
save_names = [
|
||||
'calc_RAM_model-3__nfft_whole_power_1_afe_0.025_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_11_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV_old_fit_',
|
||||
'calc_RAM_model-2__nfft_whole_power_1_afe_0.009_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_' + str(
|
||||
trial_nr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
|
||||
|
||||
|
||||
# Ich habe hier 0.009 und nicht 0.25 weil das Modell sensitiver ist
|
||||
# ich habe das mit dem CV verifiziert dass das so stimmen sollte
|
||||
|
||||
'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_old_fit_',
|
||||
'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',
|
||||
|
||||
]#'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',
|
||||
|
||||
save_names = [
|
||||
'calc_RAM_model-3__nfft_whole_power_1_afe_0.025_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_11_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV_old_fit_',
|
||||
'calc_RAM_model-3__nfft_whole_power_1_afe_0.025_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_'+str(trial_nr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV_old_fit_',
|
||||
|
||||
'calc_RAM_model-3__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_old_fit_',
|
||||
'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_100000_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV_old_fit_',
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
save_names = [
|
||||
'calc_RAM_model-2__nfft_whole_power_1_afe_0.023_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.023_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_' + str(
|
||||
trial_nr) + '_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_' + str(
|
||||
trial_nr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
|
||||
|
||||
] #calc_RAM_model-2__nfft_whole_power_1_afe_2.6_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_11_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV
|
||||
save_names = [
|
||||
'calc_RAM_model-3__nfft_whole_power_1_afe_0.025_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-3__nfft_whole_power_1_afe_0.025_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_'+str(trial_nr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
|
||||
|
||||
'calc_RAM_model-3__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-3__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',
|
||||
|
||||
]
|
||||
|
||||
save_names = [
|
||||
'calc_RAM_model-2__nfft_whole_power_1_afe_0.023_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.023_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_' + str(
|
||||
trial_nr) + '_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_' + str(
|
||||
trial_nr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
|
||||
|
||||
] #calc_RAM_model-2__nfft_whole_power_1_afe_2.6_RAM_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_11_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV
|
||||
bias_factors = [0.36, 0.36, 1, 1]#0.36
|
||||
bias_factors = [1, 1, 1, 1]
|
||||
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_' + str(
|
||||
trial_nr) + '_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_' + str(
|
||||
trial_nr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
|
||||
trial_nr = 100000
|
||||
cell = '2012-07-03-ak-invivo-1'
|
||||
|
||||
]
|
||||
cells_given = [cell]
|
||||
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_' + str(
|
||||
@ -214,30 +113,14 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
|
||||
'calc_RAM_model-2__nfft_whole_power_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_11_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV',
|
||||
'calc_RAM_model-2__nfft_whole_power_1_RAM_additiv_cv_adapt_factor_scaled_cNoise_0.1_cSig_0.9_cutoff1_300_cutoff2_300no_sinz_length1_TrialsStim_' + str(
|
||||
trial_nr) + '_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_' + str(
|
||||
#trial_nr) + '_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 = [3, 4, 8, 9] #, 10, 11
|
||||
#embed()
|
||||
tr_name = trial_nr / 1000000
|
||||
if tr_name == 1:
|
||||
tr_name = 1 #'$c=1\,\%$','$c=0\,\%$'
|
||||
c = 2.5
|
||||
cs = ['$c=%.1f$' % c + '$\,\%$', '$c=0\,\%$']
|
||||
titles = ['Model\n$N=11$', 'Model\n' + '$N=10^6$',
|
||||
'Model\,(' + label_noise_name().lower() + ')' + '\n' + '$N=11$',
|
||||
'Model\,(' + label_noise_name().lower() + ')' + '\n' + '$N=10^6$'
|
||||
] #%#%s$' % (tr_name) + '\,million'
|
||||
#'Model\,('+noise_name().lower()+')' + '\n' + '$N=11$\n $c=1\,\%$',$N=%s $' % (tr_name) +'\,million'
|
||||
# 'Model\,('+noise_name().lower()+')' + '\n' + '$N=%s$' % (tr_name) + '\,million\n $c=1\,\%$ '
|
||||
ax_model = []
|
||||
|
||||
for s, sav_name in enumerate(save_names):
|
||||
@ -265,11 +148,8 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
|
||||
width, eod_metrice=eod_metrice,
|
||||
titles_plot=True,
|
||||
resize=True,
|
||||
bias_factor=bias_factors[s],
|
||||
fr_print=fr_print, nr=nr)
|
||||
|
||||
# if s in [1,3,5]:
|
||||
#embed()
|
||||
ims.append(im)
|
||||
mats.append(stack_plot)
|
||||
maxs.append(np.max(np.array(stack_plot)))
|
||||
@ -278,7 +158,6 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
|
||||
row = 2
|
||||
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)
|
||||
@ -288,7 +167,6 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
|
||||
|
||||
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)
|
||||
|
||||
@ -298,32 +176,20 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
|
||||
set_clim_same(ims, mats=mats, lim_type='up', nr_clim='perc', clims='', percnr=perc_model_full())#
|
||||
|
||||
#################################################
|
||||
# Flowcharts
|
||||
# plot Flowcharts
|
||||
|
||||
ax_ams, ax_external = plt_model_flowcharts(a_fr, ax_external, c, cs, grid, model, stimulus_length)
|
||||
ax_ams, ax_external = plt_model_flowcharts( a_fr, ax_external, c, cs, grid, model, stimulus_length)
|
||||
|
||||
set_same_ylim(ax_ams, up='up')
|
||||
|
||||
axes = np.concatenate([ax_data, ax_model])
|
||||
|
||||
axes = [ax_ams[0], axes[1], axes[2], ax_ams[1], axes[3], axes[4], ] #ax_ams[2], axes[5], axes[6],
|
||||
#axd1 = plt.subplot(grid[1, 1])
|
||||
#axd2 = plt.subplot(grid[2, 1])
|
||||
#ax_data.extend([,])
|
||||
#axd1.show_spines('')
|
||||
#axd2.show_spines('')
|
||||
#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]]]
|
||||
axes = [ax_ams[0], axes[1], axes[2], ax_ams[1], axes[3], axes[4], ]
|
||||
|
||||
fig.tag([ax_data], xoffs=-3, yoffs=1.6) # ax_ams[3],
|
||||
fig.tag([axes[0:3]], xoffs=-3, yoffs=1.6) # ax_ams[3],
|
||||
#fig.tag([[axes[4]]], xoffs=-3, yoffs=1.6, minor_index=0) # ax_ams[3],
|
||||
fig.tag([axes[3:6]], xoffs=-3, yoffs=1.6) #, major_index = 1, minor_index = 2 ax_ams[3],
|
||||
#fig.tag([[axes[7]]], xoffs=-3, yoffs=1.6, major_index=2,minor_index=0) # ax_ams[3],
|
||||
#fig.tag([axes[8::]], xoffs=-3, yoffs=1.6, major_index=2, minor_index=2) # ax_ams[3],
|
||||
#fig.tag([axes[7::]], xoffs=-3, yoffs=1.6) # ax_ams[3],
|
||||
fig.tag([ax_data], xoffs=-3, yoffs=1.6)
|
||||
fig.tag([axes[0:3]], xoffs=-3, yoffs=1.6)
|
||||
fig.tag([axes[3:6]], xoffs=-3, yoffs=1.6)
|
||||
|
||||
#fig.tag([ax_ams[0],ax_data[0],axes[2], axes[3]], xoffs=-3, yoffs=1.6)#ax_ams[3],
|
||||
|
||||
save_visualization(pdf=True)
|
||||
|
||||
|
BIN
model_full.pdf
BIN
model_full.png
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 177 KiB |
@ -88,7 +88,7 @@ def model_full():
|
||||
stimulus_length=length, plus_q=plus_q, stack_saved = stack_saved,
|
||||
diagonal=diagonal, runs=1, nfft = nfft, xlim_psd = xlim_psd,
|
||||
cells=[cell], dev_spikes ='original', markers = markers, DF1_frmult = DF1_frmult, DF2_frmult = DF2_frmult,
|
||||
log = log, ms = ms, models_name = models_name, adjust_factor_outside = adjust_factor_outside, array_len = array_len, f_same = f_same, transfer = transfer, clip_on = False, trials_nr_all= [1, 1, 1, 1, 1]) #arrays_len a_f1s=[0.02]"2012-12-13-an-invivo-1"'2013-01-08-aa-invivo-1'
|
||||
log = log, ms = ms, models_name = models_name, adjust_factor_outside = adjust_factor_outside, array_len = array_len, clip_on = False, trials_nr_all= [1, 1, 1, 1, 1]) #arrays_len a_f1s=[0.02]"2012-12-13-an-invivo-1"'2013-01-08-aa-invivo-1'
|
||||
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ def do_trasfer_in_model_full(a_size, cell, do_transfer, grid, models_name, stack
|
||||
a_fes = [a_size, a_size, 0] # alpha\alpha0.1,
|
||||
trials_nr = 100 # 100
|
||||
|
||||
frame = get_transfer_for_model_full([a_size], 0, cell, deltat, eod_fr,
|
||||
frame = get_transfer_for_model_full(cell, deltat, eod_fr,
|
||||
model_params,
|
||||
stimulus_length,
|
||||
trials_nr,
|
||||
@ -208,7 +208,7 @@ def plt_data_matrix(axes, grid, ls, lw, perc):
|
||||
# stack_final_rev['snippets'].unique()[0], stack_here=stack_final_rev) #
|
||||
mat, add_nonlin_title, resize_val = rescale_colorbar_and_values(mat)
|
||||
mat_rev, add_nonlin_title, resize_val = rescale_colorbar_and_values(mat_rev, resize_val=resize_val)
|
||||
# try:
|
||||
|
||||
full_matrix = create_full_matrix2(np.array(mat), np.array(mat_rev))
|
||||
# except:
|
||||
# print('full matrix something')
|
||||
@ -376,7 +376,7 @@ def plt_data_full_model(c1, chose_score, detections, devs, dfs, end, grid, mult_
|
||||
for gg in range(len(DF1_desired)):
|
||||
|
||||
|
||||
# try:
|
||||
|
||||
grid0 = gridspec.GridSpecFromSubplotSpec(len(DF1_desired), 1, wspace=0.15, hspace=0.35,
|
||||
subplot_spec=grid)
|
||||
t3 = time.time()
|
||||
@ -390,7 +390,7 @@ def plt_data_full_model(c1, chose_score, detections, devs, dfs, end, grid, mult_
|
||||
grouped = mt_sorted.groupby(
|
||||
['c1', 'c2', 'm1, m2'],
|
||||
as_index=False)
|
||||
# try:
|
||||
|
||||
grouped_mean = chose_certain_group(DF1_desired[gg],
|
||||
DF2_desired[gg], grouped,
|
||||
several=True, emb=False,
|
||||
@ -423,19 +423,6 @@ def plt_data_full_model(c1, chose_score, detections, devs, dfs, end, grid, mult_
|
||||
arrays, arrays_original, spikes_pure = save_arrays_susept(
|
||||
data_dir, cell, c, chirps, devs, extract, group_mean, mean_type, plot_group=0,
|
||||
rocextra=False, sorted_on=sorted_on)
|
||||
####################################################
|
||||
|
||||
####################################################
|
||||
# hier checken wir ob für diesen einen Punkt das funkioniert mit der standardabweichung
|
||||
|
||||
#try:
|
||||
# check_var_substract_method(spikes_pure)
|
||||
#except:
|
||||
# print('var checking not possible')
|
||||
# fig = plt.figure()
|
||||
# grid = gridspec.GridSpec(2, 1, wspace=0.7, left=0.05, top=0.95, bottom=0.15,
|
||||
# right=0.98)
|
||||
|
||||
##########################################################################
|
||||
# part with the power spectra
|
||||
|
||||
|
BIN
motivation.pdf
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
BIN
plot_chi2.pdf
119
plot_chi2.py
@ -1,20 +1,14 @@
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
import mpmath as mp
|
||||
import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
from IPython import embed
|
||||
from matplotlib import rc
|
||||
|
||||
from threefish.core import find_code_vs_not
|
||||
from threefish.load import save_visualization
|
||||
from threefish.plot.colorbar import colorbar_outside
|
||||
from threefish.plot.limits import set_clim_same
|
||||
from threefish.plot.tags import tag2
|
||||
from threefish.RAM.plot_labels import nonlin_title, set_xlabel_arrow, set_ylabel_arrow
|
||||
from threefish.RAM.calc_analytics import calc_nonlin_analytic_values
|
||||
from threefish.RAM.plot_subplots import plt_RAM_perc
|
||||
from threefish.RAM.reformat_matrix import convert_csv_str_to_float, find_model_names_susept
|
||||
from threefish.RAM.reformat_matrix import convert_csv_str_to_float
|
||||
from threefish.defaults import default_figsize, default_settings
|
||||
from threefish.plot.plotstyle import plot_style
|
||||
from threefish.RAM.values import perc_model_full
|
||||
@ -22,120 +16,14 @@ from threefish.RAM.values import perc_model_full
|
||||
rc('text', usetex=True)
|
||||
|
||||
|
||||
def FiringRate(mu, D, tau_ref, vR, vT):
|
||||
x_start = (mu - vT)/mp.sqrt(2.0*D)
|
||||
x_end = (mu - vR)/mp.sqrt(2.0*D)
|
||||
dx = 0.0001
|
||||
r = 0.0
|
||||
|
||||
for i in np.arange(x_start, x_end, dx):
|
||||
integrand = mp.exp(i**2) * mp.erfc(i)
|
||||
r += integrand*dx
|
||||
|
||||
return 1.0/(tau_ref + mp.sqrt(mp.pi)*r)
|
||||
|
||||
def Susceptibility_1(omega, r0, mu, D, tau_ref, vR, vT):
|
||||
delta = (vR**2 - vT**2 + 2.0*mu*(vT - vR))/(4.0*D)
|
||||
a = (r0 * omega*1.0j)/(mp.sqrt(D) * (omega*1.0j - 1.0))
|
||||
b = mp.pcfd(omega*1.0j - 1.0, (mu - vT)/mp.sqrt(D)) - mp.exp(delta) * mp.pcfd(omega*1.0j - 1.0, (mu - vR)/mp.sqrt(D))
|
||||
c = mp.pcfd(omega*1.0j, (mu - vT)/mp.sqrt(D)) - mp.exp(delta) * mp.exp(omega*1.0j*tau_ref) * mp.pcfd(omega*1.0j, (mu - vR)/mp.sqrt(D))
|
||||
return a * b/c
|
||||
|
||||
def Susceptibility_2(omega1, omega2, chi1_1, chi1_2, r0, mu, D, tau_ref, vR, vT):
|
||||
delta = (vR**2 - vT**2 + 2.0*mu*(vT - vR))/(4.0*D)
|
||||
a1 = r0*(1.0 - omega1*1.0j - omega2*1.0j)*(omega1*1.0j + omega2*1.0j)/(2.0*D*(omega1*1.0j - 1.0)*(omega2*1.0j - 1.0))
|
||||
a2 = (omega1*1.0j + omega2*1.0j)/(2.0*mp.sqrt(D))
|
||||
a3 = chi1_1/(omega2*1.0j - 1.0) + chi1_2/(omega1*1.0j - 1.0)
|
||||
b1 = mp.pcfd(omega1*1.0j + omega2*1.0j - 2.0, (mu - vT)/mp.sqrt(D)) - mp.exp(delta) * mp.pcfd(omega1*1.0j + omega2*1.0j - 2.0, (mu - vR)/mp.sqrt(D))
|
||||
b2 = mp.pcfd(omega1*1.0j + omega2*1.0j - 1.0, (mu - vT)/mp.sqrt(D))
|
||||
b3 = mp.exp(delta) * mp.pcfd(omega1*1.0j + omega2*1.0j - 1.0, (mu - vR)/mp.sqrt(D))
|
||||
c = mp.pcfd(omega1*1.0j + omega2*1.0j, (mu - vT)/mp.sqrt(D)) - mp.exp(delta) * mp.exp(1.0j*(omega1 + omega2)*tau_ref) * mp.pcfd(omega1*1.0j + omega2*1.0j, (mu - vR)/mp.sqrt(D))
|
||||
|
||||
return a1 * b1/c + a2*a3*b2/c - a2*a3*b3/c
|
||||
|
||||
|
||||
def calc_nonlin_analytic_values():
|
||||
|
||||
save_name = '-transfer'
|
||||
load_function, name1, save_name = find_model_names_susept(save_name)
|
||||
save_name2 = '-matrix'
|
||||
load_function, name2, save_name = find_model_names_susept(save_name2)
|
||||
versions_comp, subfolder, mod_name_slash, mod_name, subfolder_path = find_code_vs_not()
|
||||
redo = False
|
||||
if versions_comp == 'develop':
|
||||
if (not os.path.exists(name1)) | (redo == True):
|
||||
frame, frame2 = develop_analytic_nonlin(name1, name2)
|
||||
else:
|
||||
frame = pd.read_csv(name1, index_col=0)
|
||||
frame2 = pd.read_csv(name2, index_col=0)
|
||||
else:
|
||||
frame = pd.read_csv(name1, index_col=0)
|
||||
frame2 = pd.read_csv(name2, index_col=0)
|
||||
return frame, frame2
|
||||
|
||||
|
||||
def develop_analytic_nonlin(name1, name2):
|
||||
# LIF model in dimensionless units: dv/dt = -v + mu + sqrt(2D)*xi
|
||||
## v: membrane voltage
|
||||
## mu: mean input voltage
|
||||
## D: noise intensity
|
||||
## xi: white Gaussian noise
|
||||
## tau_mem = 1 (membrane time constant, skipped here)
|
||||
mu = 1.1
|
||||
D = 0.001
|
||||
# threshold voltage
|
||||
vT = 1.0
|
||||
# reset voltage
|
||||
vR = 0.0
|
||||
# refractory period
|
||||
tau_ref = 0.0
|
||||
# stationary firing rate
|
||||
r0 = FiringRate(mu, D, tau_ref, vR, vT)
|
||||
x_min = 0.01
|
||||
x_max = 1.0
|
||||
dx = 0.01
|
||||
y_min = 0.01
|
||||
y_max = 1.0
|
||||
dy = 0.01
|
||||
f1_range = np.arange(x_min, x_max + 0.5 * dx, dx)
|
||||
f2_range = np.arange(y_min, y_max + 0.5 * dy, dy)
|
||||
chi1_data = np.zeros(f2_range.size, dtype=complex)
|
||||
chi2_data = np.zeros((f2_range.size, f1_range.size), dtype=complex)
|
||||
for f2 in range(f2_range.size):
|
||||
omega2 = 2.0 * np.pi * f2_range[f2]
|
||||
chi1_2 = Susceptibility_1(omega2, r0, mu, D, tau_ref, vR, vT)
|
||||
print('Step: ' + str(f2 + 1) + ' von ' + str(int((y_max - y_min) / dy) + 1))
|
||||
chi1_data[f2] = chi1_2
|
||||
|
||||
for f1 in range(f1_range.size):
|
||||
omega1 = 2.0 * np.pi * f1_range[f1]
|
||||
chi1_1 = Susceptibility_1(omega1, r0, mu, D, tau_ref, vR, vT)
|
||||
chi2 = Susceptibility_2(omega1, omega2, chi1_1, chi1_2, r0, mu, D, tau_ref, vR, vT)
|
||||
chi2_data[f2][f1] = chi2
|
||||
chi1_data[f1] = chi1_1
|
||||
# embed()
|
||||
# chi2_data.index = chi2_data.index.map(lambda x: "{:.2f}".format(float(x)))
|
||||
# chi2_data.columns = chi2_data.columns.map(lambda x: "{:.2f}".format(float(x)))
|
||||
frame = pd.DataFrame(chi1_data, index=f1_range, columns=['transfer'])
|
||||
frame.index = frame.index.map(lambda x: "{:.2f}".format(float(x)))
|
||||
frame.to_csv(name1)
|
||||
frame2 = pd.DataFrame(chi2_data, index=f2_range, columns=f1_range)
|
||||
frame2.index = frame2.index.map(lambda x: "{:.2f}".format(float(x)))
|
||||
frame2.columns = frame2.columns.map(lambda x: "{:.2f}".format(float(x)))
|
||||
frame2.to_csv(name2)
|
||||
# name1 =
|
||||
# print('transfer embed')
|
||||
return frame, frame2
|
||||
|
||||
|
||||
def plot_chi2():
|
||||
global ax, frame2
|
||||
frame, frame2 = calc_nonlin_analytic_values()
|
||||
default_settings() # ts=13, ls=13, fs=13, lw = 0.7
|
||||
plot_style()
|
||||
default_figsize(column=2, length=2.5)
|
||||
fig1, ax = plt.subplots(1, 2)
|
||||
plt.subplots_adjust(bottom=0.2, wspace=0.35, left=0.1, right=0.92)
|
||||
|
||||
###################################################
|
||||
# plot transfer function
|
||||
frame = frame.astype(complex)
|
||||
@ -145,6 +33,7 @@ def plot_chi2():
|
||||
ax[0].set_xlim(0, frame.index[-1])
|
||||
ylim = ax[0].get_ylim()
|
||||
ax[0].set_ylim(0, ylim[-1])
|
||||
|
||||
###################################################
|
||||
# plot matrix
|
||||
frame2.columns = frame2.index
|
||||
|
BIN
trialnr.pdf
BIN
trialnr.png
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |