This commit is contained in:
saschuta 2024-06-20 21:19:27 +02:00
parent 9bf1328537
commit 8c852fa11d
29 changed files with 514 additions and 283 deletions

5
README.md Normal file
View File

@ -0,0 +1,5 @@
Tabele with all cell information considering RAM analysis is saved in data/ as data_overview_mod.csv
``` .py
frame = pd.read_csv('data_overview_mod.csv')
```
see data_overview_mod.py for loading and filtering.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -1,9 +1,9 @@
from threefish.RAM.plots import plot_suscept_matrix_data
from threefish.RAM.reformat_cellchoice import cells_to_show_susceptibility
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,
plot_suscept_matrix_data(titles=[''],
cells_plot=cells_plot2, RAM_as_punit=False, scale_val = False, add_texts = [0.25, 1.3])#Low-CV ampullary cell,

Binary file not shown.

View File

@ -1,8 +1,7 @@
from threefish.RAM.plots import plot_suscept_matrix_data
from threefish.RAM.reformat_cellchoice import cells_to_show_susceptibility
from threefish.RAM.plot_labels import label_fr_name_rm
from threefish.RAM.plots import ampullary_punit
if __name__ == '__main__':
cells_plot2 = cells_to_show_susceptibility(plot_choice='contrasts')
ampullary_punit(eod_metrice = False, color_same = False, base_extra = True, fr_name = label_fr_name_rm(), cells_plot=[cells_plot2[0]], isi_delta = 5, titles=[''], tags_individual = True, xlim_p = [0, 1.15])#Low-CV P-unit,
plot_suscept_matrix_data(cells_plot=[cells_plot2[0]], titles=[''], xlim_p = [0, 1.15])#Low-CV P-unit,

Binary file not shown.

View File

@ -1,9 +1,7 @@
from threefish.RAM.plots import plot_suscept_matrix_data
from threefish.RAM.reformat_cellchoice import cells_to_show_susceptibility
from threefish.RAM.plot_labels import label_fr_name_rm
from threefish.RAM.plots import ampullary_punit
if __name__ == '__main__':
cells_plot2 = cells_to_show_susceptibility(plot_choice='contrasts')
ampullary_punit(base_extra = True, eod_metrice = False, color_same = False, fr_name = label_fr_name_rm(), tags_individual = True, isi_delta = 5, cells_plot=[cells_plot2[1]], titles=['', 'Ampullary cell,'], )#High-CV P-unit,
plot_suscept_matrix_data(cells_plot=[cells_plot2[1]], titles=['', 'Ampullary cell,'], )#High-CV P-unit,

Binary file not shown.

View File

@ -1,19 +1,20 @@
from IPython import embed
from matplotlib import gridspec as gridspec, pyplot as plt
import numpy as np
from threefish.RAM.values import start_name, version_final
from threefish.RAM.plot_subplots import plt_specific_cells, scatter_with_marginals_colorcoded
from threefish.RAM.plot_grid import get_grid_4
from scipy import stats
from threefish.defaults import default_figsize
from threefish.RAM.plot_colors import colors_overview
from threefish.reformat import exclude_nans_for_corr
from threefish.RAM.reformat_population import load_overview_susept, update_cell_names_to_unify_invivo_nomenclature
from threefish.load import save_visualization
from threefish.RAM.calc_bursts import setting_overview_score
from threefish.RAM.plot_colors import colors_overview
from threefish.RAM.plot_grid import get_grid_4
from threefish.RAM.plot_labels import basename_small, label_NLI_scorename2_small, label_pearson, label_stimname_small, \
make_log_ticks
from scipy import stats
from threefish.RAM.plot_subplots import plt_specific_cells, scatter_with_marginals_colorcoded
from threefish.RAM.reformat_population import load_overview_susept, update_cell_names_to_unify_invivo_nomenclature
from threefish.RAM.values import start_name
from threefish.reformat import exclude_nans_for_corr
try:
from plotstyle import plot_style, spines_params
except:
@ -29,7 +30,6 @@ def data_overview3():
var_it2 = ''
right = 0.85
ws = 0.75
#print(right)
grid0 = gridspec.GridSpec(3, 2, wspace=ws, bottom=0.06,
hspace=0.45, left=0.1, right=right, top=0.95)
@ -37,68 +37,40 @@ def data_overview3():
# Auswahl: wir nehmen den mean um nicht Stimulus abhängigen Noise rauszumitteln
save_names = ['calc_RAM_overview-_simplified_noise_data12_nfft0.5sec_original__StimPreSaved4__direct_']
#####################################################
#grid_lower_lower = gridspec.GridSpecFromSubplotSpec(1, 2, grid0[1], wspace = 0.5, hspace=0.55)#, height_ratios = [1,3]
cell_types = [' P-unit',' Ampullary', ]#, ' P-unit',]#' P-unit',
cell_types_name = ['P-units','Ampullary cells',]
species = ' Apteronotus leptorhynchus'
burst_corr_reset = 'response_modulation'
burst_fraction = [1000, 1000]# 50, # ,1,1]
burst_fraction = [1, 1] # ,1,1]
burst_corr_reset = 'burst_fraction_burst_corr_individual_stim'
redo = False
#embed()
counter = 0
tags = []
frame_load_sp = load_overview_susept(save_names[0], redo=redo, redo_class=redo)
scores = ['max(diag5Hz)/med_diagonal_proj_fr','max(diag5Hz)/med_diagonal_proj_fr',
'max(diag5Hz)/med_diagonal_proj_fr_base_w_burstcorr'] # + '_diagonal_proj'
scores = ['max(diag5Hz)/med_diagonal_proj_fr','max(diag5Hz)/med_diagonal_proj_fr',
] # + '_diagonal_proj'
printing = False # print values for paper
max_xs = [[[],[],[]],[[],[],[]]]
for c, cell_type_here in enumerate(cell_types):
for c, cell_type_here in enumerate(cell_types):# iteriert über die columns
frame_file = setting_overview_score(frame_load_sp, cell_type_here, min_amp='range', species=species)
#embed()
test = False
# ok das schließe ich aus weil da irgendwas in der Detektion ist, das betrifft jetzt genau 3 Zellen, also nicht so schlimm
#63 2018-08-14-af-invivo-1
#241 2018-09-05-aj-invivo-1
#252 2022-01-08-ah-invivo-1
frame_file = frame_file[frame_file.cv_stim <5]
##############################################
# modulatoin comparison for both cell_types
################################
# Modulation, cell type comparison
colorbar_value = [var_it,var_it,var_it2]#,var_it2]#['Response Modulation [Hz]',]
colorbar_name = ['response_modulation','response_modulation','']#,'']#'response_modulation'
x_axis = ['cv_base','cv_stim','response_modulation']#,'fr_base']#
var_item_names = [var_it,var_it,var_it2]#,var_it2]#['Response Modulation [Hz]',]
var_types = ['response_modulation','response_modulation','']#,'']#'response_modulation'
max_x = max_xs[c]
x_axis = ['cv_base', 'cv_stim', 'response_modulation'] # ,'fr_base']#
x_axis_names = ['CV$' + basename_small() +'$','CV$' + label_stimname_small() + '$', 'Response modulation [Hz]']#$'+basename()+'$,'Fr$'+basename()+'$',]
#score = scores[0]
score_n = ['Perc99/Med', 'Perc99/Med', 'Perc99/Med']
score = scores[c]
scores_here = [score,score,score]#,score]
score_name = ['max(diag5Hz)/med_diagonal_proj_fr','max(diag5Hz)/med_diagonal_proj_fr']#,'max(diag5Hz)/med_diagonal_proj_fr']#'Perc99/Med'
score_name = ['Fr/Med', 'Fr/Med']#'Fr/Med'] # 'Perc99/Med'
score_name = [label_NLI_scorename2_small(), label_NLI_scorename2_small(), label_NLI_scorename2_small()]#NLI_scorename()] # 'Fr/Med''Perc99/Med'
y_axis_values = [score,score,score]#,score]
y_axis_name = [label_NLI_scorename2_small(), label_NLI_scorename2_small(), label_NLI_scorename2_small()]#NLI_scorename()] # 'Fr/Med''Perc99/Med'
ax_j = []
axls = []
axss = []
#embed()
#frame_max = frame_file[frame_file[score]>5]
cv_name = "cv_base"
max_val = 1.5
log = ''#'logall'#''#'logy','logall'True#False
max_x = max_xs[c]
log = ''#'logall'#''#'logy','logall'True#False
marker = ['o']
for v, var_type in enumerate(var_types):
# ax = plt.subplot(grid0[1+v])#grid_lower[0, v]
for v, colorbar_name in enumerate(colorbar_name):# iteriert über die rows
axx, axy, axs, axls, axss, ax_j = get_grid_4(ax_j, axls, axss, grid0[v,counter])
@ -107,20 +79,20 @@ def data_overview3():
ymin = 'no'
else:
ymin = 0
xmin = 0
#frame.filter(like = 'fr')#wo_burstcorr
xmin = 0
xlimk = None
labelpad = 0.5#-1
cmap, _, y_axis = scatter_with_marginals_colorcoded(var_item_names[v], axs, cell_type_here, x_axis[v],
frame_file, scores_here[v], axy, axx, ymin=ymin,
cmap, _, y_axis = scatter_with_marginals_colorcoded(colorbar_value[v], axs, cell_type_here, x_axis[v],
frame_file, y_axis_values[v], axy, axx, ymin=ymin,
xmin=xmin, burst_fraction_reset=burst_corr_reset,
var_item=var_type, labelpad=labelpad, max_x=max_x[v],
xlim=xlimk, x_pos=1, burst_fraction=burst_fraction[c],
var_item=colorbar_name, labelpad=labelpad, max_x=max_x[v],
xlim=None, x_pos=1, burst_fraction=burst_fraction[c],
ha='right')
if printing:
print(cell_type_here + ' median '+scores_here[v]+''+str(np.nanmedian(frame_file[scores_here[v]])))
print(cell_type_here + ' median '+y_axis_values[v]+''+str(np.nanmedian(frame_file[y_axis_values[v]])))
print(cell_type_here + ' max ' + x_axis[v] + '' + str(np.nanmax(frame_file[x_axis[v]])))
if v == 0:
@ -129,7 +101,7 @@ def data_overview3():
axx.show_spines('')
axy.show_spines('')
axs.set_ylabel(score_name[v])
axs.set_ylabel(y_axis_name[v])
axs.set_xlabel(x_axis_names[v], labelpad = labelpad)
extra_lim = False
if extra_lim:
@ -157,19 +129,15 @@ def data_overview3():
axy.set_yticks_blank()
plt_specific_cells(axs, cell_type_here, x_axis[v], frame_file, scores_here[v], marker = ['o',"s"])
plt_specific_cells(axs, cell_type_here, x_axis[v], frame_file, y_axis_values[v], marker = ['o',"s"])
tags.append(axx)
#plt.show()
counter += 1
#plt.show()
if printing:
printing_values_data_overview(cell_types, frame_load_sp, scores, species, x_axis, y_axis)
show = False#True
fig = plt.gcf()
#embed()
tags_final = np.concatenate([tags[0::3],tags[1::3],tags[2::3]])#,tags[2::3]
fig.tag(tags_final, xoffs=-4.2, yoffs=1.12)
save_visualization(pdf = True, show = show)

Binary file not shown.

View File

@ -2,18 +2,18 @@
import matplotlib.gridspec as gridspec
from plotstyle import plot_style
from threefish.defaults import default_figsize
from threefish.load import save_visualization
from threefish.RAM.plots import flowchart_core
from threefish.defaults import default_figsize
def flowchart():
plot_style()
default_figsize(column=2, length=4.7) #5.3 5.8
default_figsize(column=2, length=4.7)
grid_orig = gridspec.GridSpec(1, 1, wspace=0.15, bottom=0.07,
hspace=0.1, left=0.05, right=0.96,
top=0.9) # , height_ratios = [0.4,3]
flowchart_core(grid_orig[0]) # grid_sheme grid_lower[3]
top=0.9)
flowchart_core(grid_orig[0])
save_visualization()

Binary file not shown.

View File

@ -1,9 +1,7 @@
##from update_project import **#model_and_data
import os
import numpy as np
import pandas as pd
from IPython import embed
from matplotlib import gridspec, pyplot as plt
from threefish.plot_subplots import plt_model_flowcharts
@ -71,7 +69,7 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
hs = 0.45
#################################
# data cells
# data cells panel A
grid_data = gridspec.GridSpecFromSubplotSpec(1, 1, grid[0, 0],
hspace=hs)
@ -133,16 +131,11 @@ def model_and_data2(eod_metrice=False, width=0.005, nffts=['whole'], powers=[1],
perc = 'perc'
path = save_name + '.pkl' # '../'+
# model = get_stack_one_quadrant(cell, cell_add, cells_save, path, save_name)
# full_matrix = create_full_matrix2(np.array(model), np.array(stack_rev))
# stack_final = get_axis_on_full_matrix(full_matrix, model)
# im = plt_RAM_perc(ax, perc, np.abs(model))
model = load_model_susept(path, cells_save, save_name.split(r'/')[-1] + cell_add)
#embed()
if len(model) > 0:
# panels Bii, Biii, Cii, Ciii
add_nonlin_title, cbar, fig, stack_plot, im = plt_single_square_modl(ax_external, cell, model, perc,
titles[s],
width, eod_metrice=eod_metrice,
@ -176,7 +169,7 @@ 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())#
#################################################
# plot Flowcharts
# plot Flowcharts panels Bi, Ci
ax_ams, ax_external = plt_model_flowcharts( a_fr, ax_external, c, cs, grid, model, stimulus_length)

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 176 KiB

View File

@ -1,35 +1,33 @@
import sys
import time
import numpy as np
from IPython import embed
from matplotlib import gridspec, pyplot as plt
from plotstyle import plot_style
from threefish.core import find_code_vs_not, info
from threefish.defaults import default_figsize
from threefish.load import resave_small_files, save_visualization
from threefish.plot.colorbar import colorbar_outside, rescale_colorbar_and_values
from threefish.plot.limits import set_clim_same
from threefish.plot.tags import tag2
from threefish.RAM.calc_fft import create_full_matrix2
from threefish.reformat import chose_mat_max_value, get_axis_on_full_matrix, get_psds_ROC, \
load_b_public
from threefish.RAM.reformat import check_var_substract_method, chose_certain_group, extract_waves, \
get_transfer_from_model, load_cells_three, predefine_grouping_frame, restrict_cell_type, save_arrays_susept
from threefish.RAM.save import get_transfer_for_model_full
from threefish.RAM.reformat_matrix import convert_csv_str_to_float, load_stack_data_susept
from threefish.RAM.plot_labels import label_deltaf1, label_deltaf2, label_diff, label_sum, label_two_deltaf1, \
label_two_deltaf2, nonlin_title, remove_xticks, set_xlabel_arrow, set_ylabel_arrow, title_motivation, \
xlabel_transfer_hz
from threefish.RAM.plot_subplots import colors_suscept_paper_dots, letters_for_full_model, \
plt_model_big, \
plt_model_full_model2, \
plt_model_letters, \
plt_psds_ROC, plt_RAM_perc, recalc_fr_to_DF1
from threefish.load import resave_small_files, save_visualization
from threefish.RAM.reformat import chose_certain_group, extract_waves, \
get_transfer_from_model, load_cells_three, predefine_grouping_frame, restrict_cell_type, save_arrays_susept
from threefish.RAM.reformat_matrix import convert_csv_str_to_float, load_stack_data_susept
from threefish.RAM.save import get_transfer_for_model_full
from threefish.RAM.values import find_all_dir_cells, perc_model_full, vals_model_full, version_final
from threefish.core import find_code_vs_not, info
from plotstyle import plot_style
import time
from threefish.defaults import default_diagonal_points, default_figsize
from threefish.plot.colorbar import colorbar_outside, rescale_colorbar_and_values
from threefish.RAM.plot_labels import label_deltaf1, label_deltaf2, label_diff, label_sum, \
nonlin_title, remove_xticks, set_xlabel_arrow, set_ylabel_arrow, title_motivation, label_two_deltaf1, \
label_two_deltaf2, \
xlabel_transfer_hz
from threefish.plot.limits import set_clim_same
from threefish.reformat import chose_mat_max_value, get_axis_on_full_matrix, get_psds_ROC, \
load_b_public
from threefish.values import values_nfft_full_model, values_stimuluslength_model_full
@ -48,7 +46,7 @@ def model_full():
##################################
# model square
# model square, panel A
ls = '--'
axm = plt.subplot(grid[:,0])
axes.append(axm)
@ -62,7 +60,7 @@ def model_full():
#################
#################
# power spectra model
# power spectra model, panel B, C, D, E
@ -93,11 +91,10 @@ def model_full():
########################################
# letters for the matrix
# letters for the matrix in panel A
plt_model_letters(DF1_frmult, DF2_frmult, axm, color012, color01_2, fr_noise, markers)
########################################
# tags
fig = plt.gcf()
tag2(fig, [axes[0], axes2[0], axes2[1], axes2[2], axes2[3]], xoffs=np.array([-4.2, -2.5, -2.5, -2.5, -2.5]),
yoffs=np.array([4.55, 4.35, 4.35, 4.35, 4.35])) # ax_ams[3],4.5
@ -344,7 +341,7 @@ def plt_data_full_model(c1, chose_score, detections, devs, dfs, end, grid, mult_
divergnce, fr, pivot_chosen, max_val, max_x, max_y, mult, DF1, DF2, min_y, min_x, min_val, diff_cut = chose_mat_max_value(
DF1_desired[df], DF2_desired[df], '', mult_type, eodftype, indices, cell,
contrast_small,
contrast_big, contrast1, dfs, start, devname_orig, contrast, autodefine=autodefine,
contrast_big, contrast1, dfs, devname_orig, contrast, autodefine=autodefine,
cut_matrix='cut', chose_score=chose_score) # chose_score = 'auci02_012-auci_base_01'
df1.append(DF1[0])
df2.append(DF2[0])
@ -421,7 +418,7 @@ def plt_data_full_model(c1, chose_score, detections, devs, dfs, end, grid, mult_
##############################################################
# load plotting arrays
arrays, arrays_original, spikes_pure = save_arrays_susept(
data_dir, cell, c, chirps, devs, extract, group_mean, mean_type, plot_group=0,
data_dir, cell, c, chirps, extract, group_mean, mean_type, plot_group=0,
rocextra=False, sorted_on=sorted_on)
##########################################################################
# part with the power spectra
@ -574,7 +571,5 @@ def plt_data_full_model(c1, chose_score, detections, devs, dfs, end, grid, mult_
if __name__ == '__main__':
#embed()
sys.excepthook = info
model_full()

Binary file not shown.

View File

@ -1,28 +1,16 @@
##from update_project import **
import numpy as np
from IPython import embed
from matplotlib import gridspec, pyplot as plt
from threefish.RAM.values import find_all_dir_cells, ws_nonlin_systems
from threefish.reformat import chose_mat_max_value, load_b_public
from plotstyle import plot_style
from threefish.defaults import default_figsize
from threefish.calc_time import cr_spikes_mat
from threefish.core import find_code_vs_not
import time
from threefish.RAM.reformat import check_var_substract_method, chose_certain_group, extract_waves, load_cells_three, \
predefine_grouping_frame, restrict_cell_type, save_arrays_susept
from threefish.load import save_visualization
from threefish.RAM.plot_labels import title_motivation
from threefish.RAM.plot_subplots import circle_plot, colors_suscept_paper_dots, plot_arrays_ROC_psd_single3, \
plot_shemes4, \
plt_coherences
from threefish.load import save_visualization
#from matplotlib import gridspec as gridspec, gridspec, mlab as ml, pyplot as plt, ticker as ticker
from matplotlib import pyplot as plt
from matplotlib import gridspec
from scipy.ndimage import gaussian_filter
from plotstyle import plot_style
plot_shemes4
from threefish.RAM.reformat import chose_certain_group, extract_waves, load_cells_three, \
predefine_grouping_frame, save_arrays_susept
from threefish.RAM.values import find_all_dir_cells, ws_nonlin_systems
from threefish.reformat import load_b_public
def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, devs=['2'],
@ -34,20 +22,16 @@ def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, devs=['2'
show = True
datasets, data_dir = find_all_dir_cells()
DF2_desired = [-33]
DF1_desired = [133]
autodefine = '_dfchosen_closest_first_'
cells = ['2021-08-03-ac-invivo-1']
c2 = 10
eodftype = '_psdEOD_'
indices = ['_allindices_']
chirps = [
''] # '_ChirpsDelete3_',,'_ChirpsDelete3_'','','',''#'_ChirpsDelete3_'#''#'_ChirpsDelete3_'#'#'_ChirpsDelete2_'#''#'_ChirpsDelete_'#''#'_ChirpsDelete_'#''#'_ChirpsDelete_'#''#'_ChirpsCache_'
extract = '' # '_globalmax_'
if len(cells) < 1:
data_dir, cells = load_cells_three(end, data_dir=data_dir, datasets=datasets)
start = 'min' #
cells = ['2021-08-03-ac-invivo-1']
ax_s = []
@ -64,14 +48,14 @@ def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, devs=['2'
b = load_b_public(c, cell, data_dir)
mt_sorted = predefine_grouping_frame(b, eodftype=eodftype, cell_name=cell)
mt_sorted = mt_sorted[(mt_sorted['c2'] == c2) & (mt_sorted['c1'] == c1)]
frame_loaded = predefine_grouping_frame(b, eodftype=eodftype, cell_name=cell)
frame_loaded = frame_loaded[(frame_loaded['c2'] == c2) & (frame_loaded['c1'] == c1)]
for gg in range(len(DF1_desired)):
ax_w = []
###################
# all trials in one
group_mean = group_saved_matrix(DF1_desired, DF2_desired, gg, mt_sorted)
group_mean = group_saved_matrix(DF1_desired, DF2_desired, gg, frame_loaded)
detection = 'MeanTrialsIndexPhaseSort'
mean_type = '_' + detection # + '_' + minsetting + '_' + extend_trials + concat
@ -79,7 +63,7 @@ def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, devs=['2'
##############################################################
# load plotting arrays
arrays, arrays_original, spikes_pure = save_arrays_susept(
data_dir, cell, c, chirps, devs, extract, group_mean, mean_type, plot_group=0,
data_dir, cell, c, chirps, extract, group_mean, mean_type, plot_group=0,
rocextra=False, sorted_on=sorted_on, dev_desired = dev_desired)
####################################################
@ -92,14 +76,14 @@ def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, devs=['2'
right=0.935, height_ratios=[0.5, 5.3]) # height_ratios=[1, 2], height_ratios = [1,6]bottom=0.25, top=0.8,
##########################################################################
# plot shemes above
# plot shemes above (top)
grid00 = gridspec.GridSpecFromSubplotSpec(1, 4, wspace=0.15, hspace=0.05,
subplot_spec=grid[0, :])
plot_pictograms(ax_s, grid00)
##########################################################################
# plot stimulus
# plot stimulus (first row)
grid0 = gridspec.GridSpecFromSubplotSpec(5, 4, wspace=0.15, hspace=0.35,
subplot_spec=grid[1, :],
height_ratios=[1, 0.35, 1.2, 0, 3, ])
@ -110,7 +94,7 @@ def motivation_all_small(dev_desired = '1', ylim=[-1.25, 1.25], c1=10, devs=['2'
ylim)
##########################################
# spike response
# spike response (bottom)
array_chosen = 1
smoothed_base = arrays[0][0]

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -3,36 +3,29 @@ import sys
import numpy as np
import pandas as pd
from IPython import embed
from matplotlib import gridspec, pyplot as plt
from plotstyle import plot_style
from threefish.calc_time import extract_am
from threefish.core import find_code_vs_not, find_folder_name, find_project_data, info
from threefish.defaults import default_figsize, default_ticks_talks
from threefish.defaults import default_figsize
from threefish.load import load_savedir, resave_small_files, save_visualization
from threefish.plot.limits import join_x, join_y, set_same_ylim
from threefish.plot.limits import set_same_ylim
from threefish.RAM.calc_fft import log_calc_psd
from threefish.RAM.calc_model import chose_old_vs_new_model
from threefish.RAM.core import find_load_function
from threefish.RAM.plot_labels import label_deltaf1, label_deltaf2, label_diff, label_f_eod_name_core_rm, \
label_fbasename_small, label_sum, \
onebeat_cond, \
from threefish.RAM.plot_labels import label_deltaf1, label_deltaf2, label_diff, label_fbasename_small, label_sum, \
remove_yticks
from threefish.RAM.plot_subplots import colors_suscept_paper_dots, plt_spikes_ROC, recalc_fr_to_DF1
from threefish.RAM.values import val_cm_to_inch, vals_model_full
from threefish.twobeat.calc_model import calc_roc_amp_core_cocktail
from threefish.twobeat.colors import colors_susept, twobeat_cond
from threefish.twobeat.labels import f_stable_name, f_vary_name
from threefish.RAM.values import vals_model_full
from threefish.twobeat.calc_model import calc_threefish_model
from threefish.twobeat.colors import colors_susept
from threefish.twobeat.reformat import c_dist_recalc_func, c_dist_recalc_here, dist_recalc_phaselockingchapter, \
find_dfs, \
get_frame_cell_params
from threefish.twobeat.subplots import plt_psd_saturation, plt_single_trace, plt_stim_saturation, plt_vmem_saturation, \
power_spectrum_name
from threefish.values import values_nfft_full_model, values_stimuluslength_model_full
find_dfs
from threefish.twobeat.subplots import plt_psd_saturation, plt_single_trace, plt_stim_saturation, power_spectrum_name
def nonlin_regime0(yposs=[450, 450, 450], show=True):
def nonlin_regime0():
results_diff = pd.DataFrame()
@ -74,13 +67,13 @@ def nonlin_regime0(yposs=[450, 450, 450], show=True):
subplot_spec=grid0[0], height_ratios=[1.5,1],) # height_ratios=[2,1],
############################
# overview
# overview, panel E
grid_down = gridspec.GridSpecFromSubplotSpec(1, 1,
hspace=0.75,
wspace=0.1,
subplot_spec=grid00[1]) # 1.2hspace=0.4,wspace=0.2,len(chirps)
ax_u1, c_dist_recalc, c_nrs, color0, color01, color012, color01_2, color02, eodf, f_counter, frame_cell, frame_cell_orig, freq1, freq2, i, sampling = plt_amplitudes_for_contrasts(
c_nrs_orig, cell_here, freq1, freq2, grid_down, yposs)
c_nrs_orig, cell_here, freq1, freq2, grid_down, yposs = [[220, 220, 220, 220]])
##############################
@ -105,19 +98,18 @@ def nonlin_regime0(yposs=[450, 450, 450], show=True):
model_cells, reshuffled = chose_old_vs_new_model(model_fit=model_fit)
axe_all = []
xlimp = (0, 300)
n = 1
dev = 0.001
dev_name = ['05']
a_fr = 1
a = 0
for c_nn, c_nr in enumerate(c_nrs):
a_f2s = [c_nrs_orig[c_nn]]
#################################
# hier wurden die psds vorgespeichert weil die lange brauchen
a_f2s = [c_nrs_orig[c_nn]]
xlimp = (0, 300)
runs = 1
n = 1
dev = 0.001
dev_name = ['05']
a_fr = 1
a = 0
@ -150,38 +142,23 @@ def nonlin_regime0(yposs=[450, 450, 450], show=True):
nfft_here = stimulus_length_here * 20000
a_f2s = [c_nrs_orig[c_nn]]
_, arrays_spikes, arrays_stim, _, _, _, _, arrays, names, _, _ = calc_roc_amp_core_cocktail([freq1 + eodf],
[freq2 + eodf],
auci_wo, auci_w,
results_diff,
a_f2s,
trials_nr,
nfft_here, a_fr,
stimulus_length_here,
model_cells,
position_diff,
dev, cell_here,
a_f1s=[
c_nrs_orig[
c_nn]],
dev_name=dev_name,
min_amps='_minamps_',
n=n,
reshuffled=reshuffled,
mean_choice='',
printing_cell=False)
# v_mems, arrays_spikes, arrays_stim, frame_diff, position_diff, arrays_convovled, names, p_array, ff
_, spikes_arrays_all, stimulus_arrays_all, _, _, convovled_arrays, threefish_names, _, _ = calc_threefish_model(
results_diff, position_diff, model_cells, cell_here, trials_nr=trials_nr,
stimulus_length=stimulus_length_here, freq1=[freq1 + eodf], freq2=[freq2 + eodf], a_f2s=a_f2s, a_f1s=[
c_nrs_orig[
c_nn]], a_fr=a_fr, dev=dev, dev_name=dev_name, n=n, reshuffled=reshuffled, nfft=nfft_here,
psd_min_amps='_minamps_', mean_choice='', printing_cell=False)#means_different
##################################################################
# preprocessing der arrays
time = np.arange(0, len(arrays[a][0]) / sampling, 1 / sampling)
# plot panels A, B, C, D
time = np.arange(0, len(convovled_arrays[a][0]) / sampling, 1 / sampling)
time = time * 1000
arrays_time = [arrays[3]] # [v_mems[1],v_mems[3]]#[1,2]#[1::]
arrays_here = [arrays[3]] # [arrays[1],arrays[3]]#arrays[1::]#
arrays_st = [arrays_stim[3]] #1:: [arrays_stim[1],arrays_stim[3]]#
arrays_sp = [arrays_spikes[3]] # [arrays_spikes[1],arrays_spikes[3]]#arrays_spikes[1::]
colors_array_here = ['grey', 'grey', 'grey'] # colors_array[1::]
# die arrays die rausgegeben werden sind für das threefish problem und hier nehmen wir nur den 012, also wo alle fische dabei sind
stimuli_arrays = [stimulus_arrays_all[3]] #1:: [stimulus_arrays_all[1],stimulus_arrays_all[3]]#
spike_arrays = [spikes_arrays_all[3]] # [spikes_arrays_all[1],spikes_arrays_all[3]]#spikes_arrays_all[1::]
p_arrays_all.append(p_arrays_here)
for a in range(len(arrays_here)):
for a in range(len(stimuli_arrays)):
grid_pt = gridspec.GridSpecFromSubplotSpec(3, 1,
hspace=0.3,
@ -193,36 +170,43 @@ def nonlin_regime0(yposs=[450, 450, 450], show=True):
########################################
# plot stimulus
plt_stim_nonlin(arrays_st, axe_all, axes, c_nn, c_nrs, colors_array_here, grid_pt, i, time, xlim)
plt_stim_nonlin(stimuli_arrays, axe_all, axes, c_nn, c_nrs, ['grey'], grid_pt, i, time, xlim)
#############################
# plot spikes
plt_spikes_nonlin(a, arrays_sp, axps, axss, c_nn, grid_pt, xlim)
plt_spikes_nonlin(a, spike_arrays, axss, c_nn, grid_pt, xlim)
#############################
# preallocate psd ax
axp = plt.subplot(grid_pt[-1])
axps.append(axp)
f_counter += 1
####################
# plot psds
a = plt_psd_nonlin(a, arrays_here, axps, c_nrs, color0, color01, color012, color01_2, color02,
colors_array_here, ff_p, frame_cell_orig, freq1, freq2, log, p_arrays_all, xlimp)
# plot psds, panels A, B, C, D, bottom
plt_psd_nonlin(axps, c_nrs, color0, color01, color012, color01_2, color02,
['grey'], ff_p, frame_cell_orig, freq1, freq2, log, p_arrays_all, xlimp)
###################
# limits
axps[0].get_shared_y_axes().join(*axps)
axps[0].get_shared_x_axes().join(*axps)
set_same_ylim(axe_all)
set_same_ylim(axps)
fig = plt.gcf()
fig.tag([axes[0], axes[1], axes[2], axes[3], ax_u1], xoffs=-2.3, yoffs=1.4)
save_visualization(cell_here, show)
save_visualization(cell_here, show=True)
def plt_spikes_nonlin(a, arrays_sp, axps, axss, c_nn, grid_pt, xlim):
def plt_spikes_nonlin(a, arrays_sp, axss, c_nn, grid_pt, xlim):
axs = plt.subplot(grid_pt[1])
plt_spikes_ROC(axs, 'grey', np.array(arrays_sp[a], dtype=object) * 1000, xlim, lw=1)
if c_nn == 0:
axs.xscalebar(0.15, -0.1, 30, 'ms', va='right', ha='bottom')
axss.append(axs)
axp = plt.subplot(grid_pt[-1])
axps.append(axp)
def plt_stim_nonlin(arrays_st, axe_all, axes, c_nn, c_nrs, colors_array_here, grid_pt, i, time, xlim):
@ -244,11 +228,11 @@ def plt_stim_nonlin(arrays_st, axe_all, axes, c_nn, c_nrs, colors_array_here, gr
axe_all.append(axe)
def plt_psd_nonlin(a, arrays_here, axps, c_nrs, color0, color01, color012, color01_2, color02, colors_array_here, ff_p,
def plt_psd_nonlin(axps, c_nrs, color0, color01, color012, color01_2, color02, colors_array_here, ff_p,
frame_cell_orig, freq1, freq2, log, p_arrays_all, xlimp):
pps = []
for c_nn, c_nr in enumerate(c_nrs):
for a in range(len(arrays_here)):
for a in range(len(p_arrays_all[c_nn])):
axps_here = [[axps[0], axps[1], axps[2], axps[3]]] # [axps[3], axps[4], axps[5]
axp = axps_here[a][c_nn]
@ -263,6 +247,7 @@ def plt_psd_nonlin(a, arrays_here, axps, c_nrs, color0, color01, color012, color
label_sum(), label_diff(), label_fbasename_small(), label_fbasename_small()]
freqs = [np.abs(freq1), np.abs(freq2), np.abs(freq1) + np.abs(freq2), np.abs(np.abs(freq1) - np.abs(freq2)),
fr]
plt_psd_saturation(pp, ff_p, a, axp, colors_array_here, freqs=freqs,
colors_peaks=colors_peaks, xlim=xlimp,
markeredgecolor=markeredgecolors, labels=labels, log=log, add_log=5)
@ -289,7 +274,6 @@ def plt_psd_nonlin(a, arrays_here, axps, c_nrs, color0, color01, color012, color
else:
axp.set_ylabel(power_spectrum_name())
axp.set_xlabel('Frequency [Hz]')
return a
def load_psds_for_nonlin_regime(a_f2s, a_fr, auci_w, auci_wo, c_nn, c_nrs_orig, cell_here, dev,
@ -338,9 +322,28 @@ def develop_save_nonlin_psd_values(a_f2s, a_fr, auci_w, auci_wo, c_nn, c_nrs_ori
name_psd_f, nfft_here, position_diff, reshuffled,
results_diff, stimulus_length_here, trials_nr, xlimp):
# psd generierung
_, _, arrays_stim, results_diff, position_diff, auci_wo, auci_w, arrays, names, p_arrays_p, ff_p = calc_roc_amp_core_cocktail(
[freq1 + eodf], [freq2 + eodf], auci_wo, auci_w, results_diff, a_f2s, trials_nr, nfft_here, a_fr,
stimulus_length_here, model_cells, position_diff, dev, cell_here,a_f1s=[c_nrs_orig[c_nn]], dev_name=dev_name, min_amps='_minamps_', n=n, reshuffled=reshuffled, mean_choice='first')
_, _, arrays_stim, results_diff, position_diff, arrays, names, p_arrays_p, ff_p = calc_threefish_model(results_diff,
position_diff,
model_cells,
cell_here,
trials_nr=trials_nr,
stimulus_length=stimulus_length_here,
freq1=[
freq1 + eodf],
freq2=[
freq2 + eodf],
a_f2s=a_f2s,
a_f1s=[
c_nrs_orig[
c_nn]],
a_fr=a_fr,
dev=dev,
dev_name=dev_name,
n=n,
reshuffled=reshuffled,
nfft=nfft_here,
psd_min_amps='_minamps_',
mean_choice='first')
p_arrays_here = [p_arrays_p[3]]
# embed()
for p in range(len(p_arrays_here)):
@ -351,7 +354,7 @@ def develop_save_nonlin_psd_values(a_f2s, a_fr, auci_w, auci_wo, c_nn, c_nrs_ori
return auci_w, auci_wo, ff_p, p_arrays_here, position_diff, results_diff
def plt_amplitudes_for_contrasts(c_nrs_orig, cell_here, freq1, freq2, grid_down, yposs):
def plt_amplitudes_for_contrasts(c_nrs_orig, cell_here, freq1, freq2, grid_down, yposs = [[220, 220, 220, 220]]):
full_names = [
'calc_model_amp_freqs-_F1_0.22833333333333333Fr_F2_1Fr_af_coupled__C1Len_100_FirstC1_0.0001_LastC1_0.3_FRrelavtiv__start_0.0001_end_0.3_StimLen_100_nfft_20000_trialsnr_1_mult_minimum_1_power_1_minamps__dev_original_05_not_log__point_1_fft2_temporal']
for i, full_name in enumerate(full_names):
@ -450,4 +453,4 @@ def load_nonlin_regime_values(full_name):
if __name__ == '__main__':
sys.excepthook = info
nonlin_regime0(yposs = [[220, 220, 220, 220]],)#, [430,470], [200,200], [200,200, 200, 200], [200,200, 200, 200], [200,200, 200, 200]
nonlin_regime0()

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -1,23 +1,25 @@
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rc
from threefish.defaults import default_figsize, default_settings
from threefish.load import save_visualization
from threefish.plot.colorbar import colorbar_outside
from threefish.plot.limits import set_clim_same
from threefish.plot.plotstyle import plot_style
from threefish.plot.tags import tag2
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
from threefish.defaults import default_figsize, default_settings
from threefish.plot.plotstyle import plot_style
from threefish.RAM.values import perc_model_full
rc('text', usetex=True)
def plot_chi2():
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)
@ -25,19 +27,22 @@ def plot_chi2():
plt.subplots_adjust(bottom=0.2, wspace=0.35, left=0.1, right=0.92)
###################################################
# plot transfer function
frame = frame.astype(complex)
ax[0].plot(frame.index, np.abs(frame['transfer']), color='black')
transfer_values, suscept_values = calc_nonlin_analytic_values()
###################################################
# plot transfer function, panel A
transfer_values = transfer_values.astype(complex)
ax[0].plot(transfer_values.index, np.abs(transfer_values['transfer']), color='black')
ax[0].set_xlabel(r'$f_{1}$')
ax[0].set_ylabel(r'$|\chi_{1}|$')
ax[0].set_xlim(0, frame.index[-1])
ax[0].set_xlim(0, transfer_values.index[-1])
ylim = ax[0].get_ylim()
ax[0].set_ylim(0, ylim[-1])
###################################################
# plot matrix
frame2.columns = frame2.index
new_keys, stack_plot = convert_csv_str_to_float(frame2)
# plot matrix, panel B
suscept_values.columns = suscept_values.index
new_keys, stack_plot = convert_csv_str_to_float(suscept_values)
im = plt_RAM_perc(ax[1], 'perc', np.abs(stack_plot))
set_clim_same([im],
mats=[np.abs(stack_plot)],
@ -45,17 +50,13 @@ def plot_chi2():
nr_clim='perc',
clims='',
percnr=perc_model_full())
pos_rel = -0.12
cbar, left, bottom, width, height = colorbar_outside(ax[1],
im,
add=5,
width=0.01)
ax[1].set_xlabel(r'$f_{1}$')
ax[1].set_ylabel(r'$f_{2}$')
ax[1].set_xticks_delta(0.2)
ax[1].set_xticks_delta(0.2)
ax[1].set_xlim(frame2.columns[0] - 0.01, frame2.columns[-1])
ax[1].set_ylim(frame2.columns[0] - 0.01, frame2.columns[-1])
ax[1].set_xlim(suscept_values.columns[0] - 0.01, suscept_values.columns[-1])
ax[1].set_ylim(suscept_values.columns[0] - 0.01, suscept_values.columns[-1])
cbar, left, bottom, width, height = colorbar_outside(ax[1], im, add=5, width=0.01)
cbar.set_label(r'$|\chi_{2}|$', rotation=90, labelpad=8)
tag2(axes=ax, xoffs=[-0.5, -5.5], yoffs=1.7) # ax_ams[3],
@ -64,8 +65,6 @@ def plot_chi2():
if __name__ == '__main__':
plot_chi2()

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -2,15 +2,15 @@ import os
import numpy as np
import pandas as pd
from IPython import embed
from matplotlib import pyplot as plt
from plotstyle import plot_style
from threefish.RAM.plot_labels import title_find_cell_add
from threefish.defaults import default_figsize, default_settings
from threefish.load import save_visualization
from threefish.RAM.reformat_matrix import get_stack, load_model_susept
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 *
@ -33,36 +33,33 @@ def trialnr():
##################################
# model part
cell = '2013-01-08-aa-invivo-1'
cells_given = [cell]
cells = ['2013-01-08-aa-invivo-1']
trial_nrs_here = trial_nrs_ram_model()
fig, ax = plt.subplots(1, 1)
ax = [ax]
alphas = [1]#, 1, 1]
colors = ['black']#, 'black','red']
for s in range(len(colors)):
perc05, perc90, perc95 = get_lines_trialnr(cell, cells_given, s, trial_nrs_here)
#######################
# plot 99the percentiel
ax[0].plot(trial_nrs_here, perc95, color = colors[s], clip_on = False, label = '99.99th percentile', alpha = alphas[s])
ax[0].scatter(trial_nrs_here, perc95, color = colors[s], clip_on = False, alpha = alphas[s])
ax[0].set_xscale('log')#colors[s]
ax[0].set_yscale('log')
ax[0].set_xlabel('Trials [$N$]')
ax[0].set_ylabel('$|\chi_{2}|$\,[Hz]')
ax[0].set_xlim(8, 10000000)
############################################
# plot percentile
ax[0].plot(trial_nrs_here, perc90, color='grey', clip_on=False, label='90th percentile', alpha=alphas[s])
ax[0].plot(trial_nrs_here, perc05, color='lightgrey', clip_on=False, label = '10th percentile', alpha = alphas[s])
ax[0].scatter(trial_nrs_here, perc05, color='lightgrey', clip_on=False, alpha = alphas[s])
ax[0].scatter(trial_nrs_here, perc90, color='grey', clip_on=False, alpha = alphas[s])
ax[0].legend()
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('$|\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)
@ -70,7 +67,7 @@ def trialnr():
save_visualization(pdf=True)
def get_lines_trialnr(cell, cells_given, s, trial_nrs_here):
def get_lines_trialnr(cells_given, trial_nrs_here):
stacks = []
perc95 = []
perc90 = []
@ -88,29 +85,23 @@ def get_lines_trialnr(cell, cells_given, s, 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 = save_names[s]
save_name = find_folder_name('calc_model') + '/' + save_name
save_name = find_folder_name('calc_model') + '/' + save_names[0]
cell_add, cells_save = title_find_cell_add(cells_given)
path = save_name + '.pkl' # '../'+
stack = load_model_susept(path, cells_save, save_name.split(r'/')[-1] + cell_add)
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)
if len(stack) > 0:
model_show, stack_plot, stack_plot_wo_norm = get_stack(cell, stack)
stacks.append(stack_plot)
if 'counter_validate' in stack.keys():
counter.append(stack['counter_validate'].iloc[0])
if 'counter_validate' in suscept_matrix.keys():
counter.append(suscept_matrix['counter_validate'].iloc[0])
else:
counter.append(float('nan'))
cv_stims.append(stack['cv_stim_mean'].iloc[0])
fr_stims.append(stack['fr_stim_mean'].iloc[0])
vars.append(stack['var_RAM'].iloc[0])
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))
@ -129,7 +120,6 @@ def get_lines_trialnr(cell, cells_given, s, trial_nrs_here):
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'))
@ -168,11 +158,9 @@ def print_table_for_methods():
if __name__ == '__main__':
plot_style()
default_settings(lw=0.5, column=2, length=3.35) #8.5
##########################
# hier printen wir die table Werte zum kopieren in den Text
# hier kann man die tabellen Werte zum kopieren in den Text printen lassen
print_table_for_methods()
trialnr()