169 lines
5.2 KiB
Python
169 lines
5.2 KiB
Python
import os
|
|
|
|
import numpy as np
|
|
import pandas as pd
|
|
from matplotlib import pyplot as plt
|
|
|
|
from plotstyle import plot_style
|
|
from threefish.core import find_folder_name
|
|
from threefish.defaults import default_figsize
|
|
from threefish.load import save_visualization
|
|
from threefish.RAM.calc_model import trial_nrs_ram_model
|
|
from threefish.RAM.plot_labels import title_find_cell_add
|
|
from threefish.RAM.reformat_matrix import get_stack, load_model_susept
|
|
|
|
|
|
##from update_project import *
|
|
|
|
|
|
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 trialnr():
|
|
|
|
plot_style()
|
|
default_figsize(column=2, length=3.1) #.254.75 0.75
|
|
|
|
|
|
##################################
|
|
# model part
|
|
|
|
cells = ['2013-01-08-aa-invivo-1']
|
|
trial_nrs_here = trial_nrs_ram_model()
|
|
|
|
|
|
|
|
fig, ax = plt.subplots(1, 1)
|
|
ax = [ax]
|
|
|
|
perc05, perc90, perc95 = get_lines_trialnr(cells, trial_nrs_here)
|
|
|
|
#######################
|
|
# plot 99the percentile
|
|
ax[0].plot(trial_nrs_here, perc95, color = 'black', clip_on = False, label = '99.99th percentile')
|
|
ax[0].scatter(trial_nrs_here, perc95, color = 'black', clip_on = False)
|
|
ax[0].set_xscale('log')#colors[s]
|
|
ax[0].set_yscale('log')
|
|
ax[0].set_xlabel('Trials [$N$]')
|
|
ax[0].set_ylabel(r'$|\chi_{2}|$\,[Hz]')
|
|
ax[0].set_xlim(8, 10000000)
|
|
|
|
############################################
|
|
# plot percentiles
|
|
ax[0].plot(trial_nrs_here, perc90, color='grey', clip_on=False, label='90th percentile')
|
|
ax[0].plot(trial_nrs_here, perc05, color='lightgrey', clip_on=False, label = '10th percentile')
|
|
ax[0].scatter(trial_nrs_here, perc05, color='lightgrey', clip_on=False)
|
|
ax[0].scatter(trial_nrs_here, perc90, color='grey', clip_on=False)
|
|
ax[0].legend()
|
|
|
|
|
|
plt.subplots_adjust(left = 0.1, right = 0.9, bottom = 0.2, top = 0.95)
|
|
|
|
save_visualization(pdf=True)
|
|
|
|
|
|
def get_lines_trialnr(cells_given, trial_nrs_here):
|
|
stacks = []
|
|
perc95 = []
|
|
perc90 = []
|
|
vars = []
|
|
cv_stims = []
|
|
fr_stims = []
|
|
perc05 = []
|
|
median = []
|
|
stacks_wo_norm = []
|
|
perc95_wo_norm = []
|
|
perc05_wo_norm = []
|
|
median_wo_norm = []
|
|
counter = []
|
|
for tr in trial_nrs_here:
|
|
save_names = [
|
|
'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(
|
|
tr) + '_a_fr_1__trans1s__TrialsNr_1_fft_o_forward_fft_i_forward_Hz_mV']
|
|
save_name = find_folder_name('calc_model') + '/' + save_names[0]
|
|
cell_add, cells_save = title_find_cell_add(cells_given)
|
|
path = save_name + '.pkl' # '../'+
|
|
|
|
suscept_matrix = load_model_susept(path, cells_save, save_name.split(r'/')[-1] + cell_add)
|
|
|
|
if len(suscept_matrix) > 0:
|
|
model_show, stack_plot, stack_plot_wo_norm = get_stack(cells_given[0], suscept_matrix)
|
|
|
|
stacks.append(stack_plot)
|
|
if 'counter_validate' in suscept_matrix.keys():
|
|
counter.append(suscept_matrix['counter_validate'].iloc[0])
|
|
else:
|
|
counter.append(float('nan'))
|
|
cv_stims.append(suscept_matrix['cv_stim_mean'].iloc[0])
|
|
fr_stims.append(suscept_matrix['fr_stim_mean'].iloc[0])
|
|
vars.append(suscept_matrix['var_RAM'].iloc[0])
|
|
perc95.append(np.percentile(stack_plot, 99.9)) # 99.99
|
|
perc90.append(np.percentile(stack_plot, 90))
|
|
perc05.append(np.percentile(stack_plot, 10))
|
|
median.append(np.percentile(stack_plot, 50))
|
|
stacks_wo_norm.append(stack_plot_wo_norm)
|
|
perc95_wo_norm.append(np.percentile(stack_plot_wo_norm, 99.99))
|
|
perc05_wo_norm.append(np.percentile(stack_plot_wo_norm, 10))
|
|
median_wo_norm.append(np.percentile(stack_plot_wo_norm, 50))
|
|
|
|
else:
|
|
vars.append(float('nan'))
|
|
cv_stims.append(float('nan'))
|
|
fr_stims.append(float('nan'))
|
|
stacks.append([])
|
|
perc95.append(float('nan'))
|
|
perc90.append(float('nan'))
|
|
perc05.append(float('nan'))
|
|
median.append(float('nan'))
|
|
stacks_wo_norm.append([])
|
|
perc95_wo_norm.append(float('nan'))
|
|
perc05_wo_norm.append(float('nan'))
|
|
median_wo_norm.append(float('nan'))
|
|
counter.append(float('nan'))
|
|
return perc05, perc90, perc95
|
|
|
|
|
|
def start_pos_modeldata():
|
|
return 1.03
|
|
|
|
|
|
def signal_component_name():
|
|
return r'$\xi_{signal}$'#signal noise'
|
|
|
|
|
|
def noise_component_name():#$\xi_{noise}$noise_name =
|
|
return r'$\xi_{noise}$'#'Noise component'#'intrinsic noise'
|
|
|
|
|
|
def ypos_x_modelanddata():
|
|
return -0.45
|
|
|
|
|
|
def print_table_for_methods():
|
|
global path
|
|
path = 'print_table_suscept-model_params_suscept_table.csv'
|
|
if os.path.exists(path):
|
|
table = pd.read_csv(path)
|
|
table_printen(table)
|
|
path = 'print_table_all-model_params_suscept_table.csv'
|
|
if os.path.exists(path):
|
|
table = pd.read_csv()
|
|
table_printen(table)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
##########################
|
|
# hier kann man die tabellen Werte zum kopieren in den Text printen lassen
|
|
print_table_for_methods()
|
|
|
|
trialnr()
|
|
|
|
|