Discussion and changes to abstract

This commit is contained in:
nkoch1
2022-10-27 11:06:25 -04:00
parent 2b537f790a
commit 6c2ba406b8
8 changed files with 966 additions and 1050 deletions

View File

@@ -0,0 +1,661 @@
import pandas as pd
import numpy as np
import h5py
import os
from ast import literal_eval
#%% create JSON files for each alt type
# folder
top_dir = '../Sensitivity_Analysis'
# for each alt_type create pd df
shift_AUC = pd.DataFrame()
shift_rheo = pd.DataFrame()
shift_fI = pd.DataFrame(dtype=object)
shift_I_mag = pd.DataFrame(dtype=object)
slope_AUC = pd.DataFrame()
slope_rheo = pd.DataFrame()
slope_fI = pd.DataFrame(dtype=object)
slope_I_mag = pd.DataFrame(dtype=object)
g_AUC = pd.DataFrame()
g_rheo = pd.DataFrame()
g_fI = pd.DataFrame(dtype=object)
g_I_mag = pd.DataFrame(dtype=object)
print('SA pd gen')
dir_names = ['RS_pyramidal', 'RS_inhib', 'FS','RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for dir_name in dir_names:
folder = os.path.join(top_dir, dir_name)
print(folder)
# for each alt_type create pd df
shift_AUC = pd.DataFrame()
shift_rheo = pd.DataFrame()
shift_fI = pd.DataFrame(dtype=object)
shift_I_mag = pd.DataFrame(dtype=object)
slope_AUC = pd.DataFrame()
slope_rheo = pd.DataFrame()
slope_fI = pd.DataFrame(dtype=object)
slope_I_mag = pd.DataFrame(dtype=object)
g_AUC = pd.DataFrame()
g_rheo = pd.DataFrame()
g_fI = pd.DataFrame(dtype=object)
g_I_mag = pd.DataFrame(dtype=object)
for root, dirs, files in os.walk(folder):
for file in files:
if file.endswith('.hdf5'):
with h5py.File(os.path.join(folder, file), "r+") as f:
alt = f['data'].attrs['alteration']
test = f['data'].attrs['alteration_info'].replace(' ', ',')
alt_info = literal_eval(test)
var = alt_info[0]
alt_type = alt_info[1]
if alt_type == 'shift':
shift_AUC.loc[alt, var] = f['analysis']['AUC'][()]
shift_rheo.loc[alt, var] = f['analysis']['rheobase'][()]
shift_fI.loc[alt, var] = 0
shift_fI = shift_fI.astype(object)
shift_fI.at[alt, var] = f['analysis']['F_inf'][:].tolist()
shift_I_mag.loc[alt, var] = 0
shift_I_mag = shift_I_mag.astype(object)
shift_I_mag.at[alt, var] = ((np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'],
(f['data'].attrs['I_high'] - f['data'].attrs['I_low']) /
f['data'].attrs['stim_num'])) * 1000).tolist() # nA
elif alt_type == 'slope':
slope_AUC.loc[alt, var] = f['analysis']['AUC'][()]
slope_rheo.loc[alt, var] = f['analysis']['rheobase'][()]
slope_fI.loc[alt, var] = 0
slope_fI = slope_fI.astype(object)
slope_fI.at[alt, var] = f['analysis']['F_inf'][:].tolist()
slope_I_mag.loc[alt, var] = 0
slope_I_mag = slope_I_mag.astype(object)
slope_I_mag.at[alt, var] = ((np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'],
(f['data'].attrs['I_high'] - f['data'].attrs['I_low']) /
f['data'].attrs['stim_num'])) * 1000).tolist()
elif alt_type == 'g':
g_AUC.loc[alt, var] = f['analysis']['AUC'][()]
g_rheo.loc[alt, var] = f['analysis']['rheobase'][()]
g_fI.loc[alt, var] = 0
g_fI = g_fI.astype(object)
g_fI.at[alt, var] = f['analysis']['F_inf'][:].tolist()
g_I_mag.loc[alt, var] = 0
g_I_mag = g_I_mag.astype(object)
g_I_mag.at[alt, var] = ((np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'],
(f['data'].attrs['I_high'] - f['data'].attrs['I_low']) /
f['data'].attrs['stim_num'])) * 1000).tolist()
else:
print(file, 'Unknown alteration type')
# save df with folder+alt_type
save_folder = os.path.join(top_dir, 'SA_summary_df')
if not os.path.isdir(save_folder):
os.makedirs(save_folder)
shift_AUC.to_json(os.path.join(save_folder, '{}_shift_AUC.json'.format(dir_name)))
shift_rheo.to_json(os.path.join(save_folder, '{}_shift_rheo.json'.format(dir_name)))
shift_fI.to_json(os.path.join(save_folder, '{}_shift_fI.json'.format(dir_name)))
shift_I_mag.to_json(os.path.join(save_folder, '{}_shift_I_mag.json'.format(dir_name)))
slope_AUC.to_json(os.path.join(save_folder, '{}_slope_AUC.json'.format(dir_name)))
slope_rheo.to_json(os.path.join(save_folder, '{}_slope_rheo.json'.format(dir_name)))
slope_fI.to_json(os.path.join(save_folder, '{}_slope_fI.json'.format(dir_name)))
slope_I_mag.to_json(os.path.join(save_folder, '{}_slope_I_mag.json'.format(dir_name)))
g_AUC.to_json(os.path.join(save_folder, '{}_g_AUC.json'.format(dir_name)))
g_rheo.to_json(os.path.join(save_folder, '{}_g_rheo.json'.format(dir_name)))
g_fI.to_json(os.path.join(save_folder, '{}_g_fI.json'.format(dir_name)))
g_I_mag.to_json(os.path.join(save_folder, '{}_g_I_mag.json'.format(dir_name)))
# requires _shift_rheo.json
#%% correlation analysis ###########################################################################################
models = ['RS_pyramidal', 'RS_inhib', 'FS','RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN',
'STN_Kv', 'STN_Kv_only']
model_labels = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal +$K_V1.1$', 'RS_inhib +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate', 'Cb stellate +$K_V1.1$',
'Cb stellate $\Delta$$K_V1.1$', 'STN', 'STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$']
var_dict = {}
var_dict['RS_pyramidal'] = ['m', 'h', 'n']
var_dict['RS_inhib'] = ['m', 'h', 'n']
var_dict['FS'] = ['m', 'h', 'n']
var_dict['RS_pyramidal_Kv'] = ['m', 'h', 'n', 's', 'u']
var_dict['RS_inhib_Kv'] = ['m', 'h', 'n', 's', 'u']
var_dict['FS_Kv'] = ['m', 'h', 'n', 's', 'u']
var_dict['Cb_stellate'] = ['m', 'h', 'n', 'a', 'b']
var_dict['Cb_stellate_Kv'] = ['m', 'h', 'n', 'a', 'b', 's', 'u']
var_dict['Cb_stellate_Kv_only'] = ['m', 'h', 'n', 's', 'u']
var_dict['STN'] = ['m', 'h', 'n', 'n_A', 'h_A', 's', 'u']
var_dict['STN_Kv'] = ['m', 'h', 'n', 'n_A', 'h_A', 's', 'u']
var_dict['STN_Kv_only'] = ['m', 'h', 'n', 's', 'u']
folder = './Sensitivity_Analysis/corr_df'
if not os.path.isdir(folder):
os.makedirs(folder)
# % rheo
# % shift
shift_m = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_m[mod] = pd.read_json(json_file)['m'].sort_index()
shift_m.sort_index(inplace=True)
shift_m.replace(0., np.NaN, inplace=True)
shift_m = (shift_m - shift_m.loc[0, :])
shift_m.to_json(os.path.join(folder, 'shift_m_rheo.json'))
shift_h = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_h[mod] = pd.read_json(json_file)['h'].sort_index()
shift_h.sort_index(inplace=True)
shift_h.replace(0., np.NaN, inplace=True)
shift_h = (shift_h - shift_h.loc[0, :])
shift_h.to_json(os.path.join(folder, 'shift_h_rheo.json'))
shift_n = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_n[mod] = pd.read_json(json_file)['n'].sort_index()
shift_n.sort_index(inplace=True)
shift_n.replace(0., np.NaN, inplace=True)
shift_n = (shift_n - shift_n.loc[0, :])
shift_n.to_json(os.path.join(folder, 'shift_n_rheo.json'))
shift_s = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_s[mod] = pd.read_json(json_file)['s'].sort_index()
shift_s.sort_index(inplace=True)
shift_s.replace(0., np.NaN, inplace=True)
shift_s = (shift_s - shift_s.loc[0, :])
shift_s.to_json(os.path.join(folder, 'shift_s_rheo.json'))
shift_u = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_u[mod] = pd.read_json(json_file)['u'].sort_index()
shift_u.sort_index(inplace=True)
shift_u.replace(0., np.NaN, inplace=True)
shift_u = (shift_u - shift_u.loc[0, :])
shift_u.to_json(os.path.join(folder, 'shift_u_rheo.json'))
shift_a = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_a[mod] = pd.read_json(json_file)['n_A'].sort_index()
models = ['STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_a[mod] = pd.read_json(json_file)['a'].sort_index()
shift_a.sort_index(inplace=True)
shift_a.replace(0., np.NaN, inplace=True)
shift_a = (shift_a - shift_a.loc[0, :])
shift_a.to_json(os.path.join(folder, 'shift_a_rheo.json'))
shift_b = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_b[mod] = pd.read_json(json_file)['h_A'].sort_index()
models = ['STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_shift_rheo.json'.format(mod)) as json_file:
shift_b[mod] = pd.read_json(json_file)['b'].sort_index()
shift_b.sort_index(inplace=True)
shift_b.replace(0., np.NaN, inplace=True)
shift_b = (shift_b - shift_b.loc[0, :])
shift_b.to_json(os.path.join(folder, 'shift_b_rheo.json'))
# % slope
slope_m = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_m[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['m'].sort_index()
slope_m.index = slope_m.index.map(float)
slope_m.sort_index(inplace=True)
slope_m.replace(0., np.NaN, inplace=True)
slope_m = (slope_m - slope_m.loc[1.0, :])
slope_m.to_json(os.path.join(folder, 'slope_m_rheo.json'))
slope_h = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_h[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['h'].sort_index()
slope_h.index = slope_h.index.map(float)
slope_h.sort_index(inplace=True)
slope_h.replace(0., np.NaN, inplace=True)
slope_h = (slope_h - slope_h.loc[1.0, :])
slope_h.to_json(os.path.join(folder, 'slope_h_rheo.json'))
slope_n = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_n[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['n'].sort_index()
slope_n.index = slope_n.index.map(float)
slope_n.sort_index(inplace=True)
slope_n.replace(0., np.NaN, inplace=True)
slope_n = (slope_n - slope_n.loc[1.0, :])
slope_n.to_json(os.path.join(folder, 'slope_n_rheo.json'))
slope_s = pd.DataFrame()
models = [ 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_s[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['s'].sort_index()
slope_s.index = slope_s.index.map(float)
slope_s.sort_index(inplace=True)
slope_s.replace(0., np.NaN, inplace=True)
slope_s = (slope_s - slope_s.loc[1.0, :])
slope_s.to_json(os.path.join(folder, 'slope_s_rheo.json'))
slope_u = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_u[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['u'].sort_index()
slope_u.index = slope_u.index.map(float)
slope_u.sort_index(inplace=True)
slope_u.replace(0., np.NaN, inplace=True)
slope_u = (slope_u - slope_u.loc[1.0, :])
slope_u.to_json(os.path.join(folder, 'slope_u_rheo.json'))
slope_a = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_a[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['n_A'].sort_index()
models = ['STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_a[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['a'].sort_index()
slope_a.index = slope_a.index.map(float)
slope_a.sort_index(inplace=True)
slope_a.replace(0., np.NaN, inplace=True)
slope_a = (slope_a - slope_a.loc[1.0, :])
slope_a.to_json(os.path.join(folder, 'slope_a_rheo.json'))
slope_b = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_b[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['h_A'].sort_index()
models = ['STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_slope_rheo.json'.format(mod)) as json_file:
slope_b[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['b'].sort_index()
slope_b.index = slope_b.index.map(float)
slope_b.sort_index(inplace=True)
slope_b.replace(0., np.NaN, inplace=True)
slope_b = (slope_b - slope_b.loc[1.0, :]) #
slope_b.to_json(os.path.join(folder, 'slope_b_rheo.json'))
# % g
g_Na = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_g_rheo.json'.format(mod)) as json_file:
g_Na[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['Na'].sort_index()
g_Na.index = g_Na.index.map(float)
g_Na.sort_index(inplace=True)
g_Na.replace(0., np.NaN, inplace=True)
g_Na = (g_Na - g_Na.loc[1.0, :])
g_Na.to_json(os.path.join(folder, 'g_Na_rheo.json'))
g_Kd = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_g_rheo.json'.format(mod)) as json_file:
g_Kd[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['Kd'].sort_index()
g_Kd.index = g_Kd.index.map(float)
g_Kd.sort_index(inplace=True)
g_Kd.replace(0., np.NaN, inplace=True)
g_Kd = (g_Kd - g_Kd.loc[1.0, :])
g_Kd.to_json(os.path.join(folder, 'g_Kd_rheo.json'))
g_Kv = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_g_rheo.json'.format(mod)) as json_file:
g_Kv[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['Kv'].sort_index()
g_Kv.index = g_Kv.index.map(float)
g_Kv.sort_index(inplace=True)
g_Kv.replace(0., np.NaN, inplace=True)
g_Kv = (g_Kv - g_Kv.loc[1.0, :])
g_Kv.to_json(os.path.join(folder, 'g_Kv_rheo.json'))
g_A = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv', 'STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_g_rheo.json'.format(mod)) as json_file:
g_A[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['A'].sort_index()
g_A.index = g_A.index.map(float)
g_A.sort_index(inplace=True)
g_A.replace(0., np.NaN, inplace=True)
g_A = (g_A - g_A.loc[1.0, :])
g_A.to_json(os.path.join(folder, 'g_A_rheo.json'))
g_Leak = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_g_rheo.json'.format(mod)) as json_file:
g_Leak[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['Leak'].sort_index()
g_Leak.index = g_Leak.index.map(float)
g_Leak.sort_index(inplace=True)
g_Leak.replace(0., np.NaN, inplace=True)
g_Leak = (g_Leak - g_Leak.loc[1.0, :])
g_Leak.to_json(os.path.join(folder, 'g_Leak_rheo.json'))
# % AUC
# % shift
shift_m = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_m[mod] = pd.read_json(json_file)['m'].sort_index()
shift_m.sort_index(inplace=True)
shift_m.replace(0., np.NaN, inplace=True)
shift_m = (shift_m - shift_m.loc[0, :]) / shift_m.loc[0, :]
shift_m.to_json(os.path.join(folder, 'shift_m_AUC.json'))
shift_h = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_h[mod] = pd.read_json(json_file)['h'].sort_index()
shift_h.sort_index(inplace=True)
shift_h.replace(0., np.NaN, inplace=True)
shift_h = (shift_h - shift_h.loc[0, :]) / shift_h.loc[0, :]
shift_h.to_json(os.path.join(folder, 'shift_h_AUC.json'))
shift_n = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_n[mod] = pd.read_json(json_file)['n'].sort_index()
shift_n.sort_index(inplace=True)
shift_n.replace(0., np.NaN, inplace=True)
shift_n = (shift_n - shift_n.loc[0, :]) / shift_n.loc[0, :]
shift_n.to_json(os.path.join(folder, 'shift_n_AUC.json'))
shift_s = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_s[mod] = pd.read_json(json_file)['s'].sort_index()
shift_s.sort_index(inplace=True)
shift_s.replace(0., np.NaN, inplace=True)
shift_s = (shift_s - shift_s.loc[0, :]) / shift_s.loc[0, :]
shift_s.to_json(os.path.join(folder, 'shift_s_AUC.json'))
shift_u = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_u[mod] = pd.read_json(json_file)['u'].sort_index()
shift_u.sort_index(inplace=True)
shift_u.replace(0., np.NaN, inplace=True)
shift_u = (shift_u - shift_u.loc[0, :]) / shift_u.loc[0, :]
shift_u.to_json(os.path.join(folder, 'shift_u_AUC.json'))
shift_a = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_a[mod] = pd.read_json(json_file)['n_A'].sort_index()
models = ['STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_a[mod] = pd.read_json(json_file)['a'].sort_index()
shift_a.sort_index(inplace=True)
shift_a.replace(0., np.NaN, inplace=True)
shift_a = (shift_a - shift_a.loc[0, :]) / shift_a.loc[0, :]
shift_a.to_json(os.path.join(folder, 'shift_a_AUC.json'))
shift_b = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_b[mod] = pd.read_json(json_file)['h_A'].sort_index()
models = ['STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_shift_AUC.json'.format(mod)) as json_file:
shift_b[mod] = pd.read_json(json_file)['b'].sort_index()
shift_b.sort_index(inplace=True)
shift_b.replace(0., np.NaN, inplace=True)
shift_b = (shift_b - shift_b.loc[0, :]) / shift_b.loc[0, :]
shift_b.to_json(os.path.join(folder, 'shift_b_AUC.json'))
# % slope
slope_m = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_m[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['m'].sort_index()
slope_m.index = slope_m.index.map(float)
slope_m.sort_index(inplace=True)
slope_m.replace(0., np.NaN, inplace=True)
slope_m = (slope_m - slope_m.loc[1.0, :]) / slope_m.loc[1.0, :]
slope_m.to_json(os.path.join(folder, 'slope_m_AUC.json'))
slope_h = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_h[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['h'].sort_index()
slope_h.index = slope_h.index.map(float)
slope_h.sort_index(inplace=True)
slope_h.replace(0., np.NaN, inplace=True)
slope_h = (slope_h - slope_h.loc[1.0, :]) / slope_h.loc[1.0, :]
slope_h.to_json(os.path.join(folder, 'slope_h_AUC.json'))
slope_n = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_n[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['n'].sort_index()
slope_n.index = slope_n.index.map(float)
slope_n.sort_index(inplace=True)
slope_n.replace(0., np.NaN, inplace=True)
slope_n = (slope_n - slope_n.loc[1.0, :]) / slope_n.loc[1.0, :]
slope_n.to_json(os.path.join(folder, 'slope_n_AUC.json'))
slope_s = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_s[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['s'].sort_index()
slope_s.index = slope_s.index.map(float)
slope_s.sort_index(inplace=True)
slope_s.replace(0., np.NaN, inplace=True)
slope_s = (slope_s - slope_s.loc[1.0, :]) / slope_s.loc[1.0, :]
slope_s.to_json(os.path.join(folder, 'slope_s_AUC.json'))
slope_u = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_u[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['u'].sort_index()
slope_u.index = slope_u.index.map(float)
slope_u.sort_index(inplace=True)
slope_u.replace(0., np.NaN, inplace=True)
slope_u = (slope_u - slope_u.loc[1.0, :]) / slope_u.loc[1.0, :]
slope_u.to_json(os.path.join(folder, 'slope_u_AUC.json'))
slope_a = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_a[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['n_A'].sort_index()
models = ['STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_a[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['a'].sort_index()
slope_a.index = slope_a.index.map(float)
slope_a.sort_index(inplace=True)
slope_a.replace(0., np.NaN, inplace=True)
slope_a = (slope_a - slope_a.loc[1.0, :]) / slope_a.loc[1.0, :]
slope_a.to_json(os.path.join(folder, 'slope_a_AUC.json'))
slope_b = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_b[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['h_A'].sort_index()
models = ['STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_slope_AUC.json'.format(mod)) as json_file:
slope_b[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['b'].sort_index()
slope_b.index = slope_b.index.map(float)
slope_b.sort_index(inplace=True)
slope_b.replace(0., np.NaN, inplace=True)
slope_b = (slope_b - slope_b.loc[1.0, :]) / slope_b.loc[1.0, :]
slope_b.to_json(os.path.join(folder, 'slope_b_AUC.json'))
# % g
g_Na = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_g_AUC.json'.format(mod)) as json_file:
g_Na[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['Na'].sort_index()
g_Na.index = g_Na.index.map(float)
g_Na.sort_index(inplace=True)
g_Na.replace(0., np.NaN, inplace=True)
g_Na = (g_Na - g_Na.loc[1.0, :]) / g_Na.loc[1.0, :]
g_Na.to_json(os.path.join(folder, 'g_Na_AUC.json'))
g_Kd = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_g_AUC.json'.format(mod)) as json_file:
g_Kd[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['Kd'].sort_index()
g_Kd.index = g_Kd.index.map(float)
g_Kd.sort_index(inplace=True)
g_Kd.replace(0., np.NaN, inplace=True)
g_Kd = (g_Kd - g_Kd.loc[1.0, :]) / g_Kd.loc[1.0, :]
g_Kd.to_json(os.path.join(folder, 'g_Kd_AUC.json'))
g_Kv = pd.DataFrame()
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_g_AUC.json'.format(mod)) as json_file:
g_Kv[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['Kv'].sort_index()
g_Kv.index = g_Kv.index.map(float)
g_Kv.sort_index(inplace=True)
g_Kv.replace(0., np.NaN, inplace=True)
g_Kv = (g_Kv - g_Kv.loc[1.0, :]) / g_Kv.loc[1.0, :]
g_Kv.to_json(os.path.join(folder, 'g_Kv_AUC.json'))
g_A = pd.DataFrame()
models = ['Cb_stellate', 'Cb_stellate_Kv', 'STN', 'STN_Kv']
for mod in models:
with open('./SA_summary_df/{}_g_AUC.json'.format(mod)) as json_file:
g_A[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['A'].sort_index()
g_A.index = g_A.index.map(float)
g_A.sort_index(inplace=True)
g_A.replace(0., np.NaN, inplace=True)
g_A = (g_A - g_A.loc[1.0, :]) / g_A.loc[1.0, :]
g_A.to_json(os.path.join(folder, 'g_A_AUC.json'))
g_Leak = pd.DataFrame()
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
for mod in models:
with open('./SA_summary_df/{}_g_AUC.json'.format(mod)) as json_file:
g_Leak[mod] = pd.read_json(json_file, convert_axes=False, convert_dates=False)['Leak'].sort_index()
g_Leak.index = g_Leak.index.map(float)
g_Leak.sort_index(inplace=True)
g_Leak.replace(0., np.NaN, inplace=True)
g_Leak = (g_Leak - g_Leak.loc[1.0, :]) / g_Leak.loc[1.0, :]
g_Leak.to_json(os.path.join(folder, 'g_Leak_AUC.json'))
#%% todo: CREATE CSV FILES ###################################################################################################
#% AUC
# from ./Code/From_Neuronal_models/tau_analysis/AUC_corr_df_gen.py
AUC_shift_df = pd.read_json('./Sensitivity_analysis/shift_box_kendall_corr_rel.json', orient='records')
AUC_slope_df = pd.read_json('./Sensitivity_analysis/slope_box_kendall_corr_rel.json', orient='records') #, lines=True)
AUC_g_df = pd.read_json('./Sensitivity_analysis/g_box_kendall_corr_rel.json', orient='records')
# for i in np.array(['FS', 'IB', 'RS inhibitory', 'RS pyramidal']):
# AUC_shift_df.loc[AUC_shift_df['model'] == i, 'model'] = i + ' +$K_V1.1$' # ''+$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
# AUC_slope_df.loc[AUC_slope_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
# AUC_g_df.loc[AUC_g_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
AUC_shift_df_posp = pd.read_json('./Sensitivity_analysis/shift_box_kendall_corr_rel_pospischil.json', orient='records')
AUC_slope_df_posp = pd.read_json('./Sensitivity_analysis/slope_box_kendall_corr_rel_pospischil.json', orient='records') #, lines=True)
AUC_g_df_posp = pd.read_json('./Sensitivity_analysis/g_box_kendall_corr_rel_pospischil.json', orient='records')
AUC_shift_df = AUC_shift_df.append(AUC_shift_df_posp)
AUC_slope_df = AUC_slope_df.append(AUC_slope_df_posp)
AUC_g_df = AUC_g_df.append(AUC_g_df_posp)
AUC_shift_df.to_csv('AUC_shift_corr.csv')
AUC_slope_df.to_csv('AUC_scale_corr.csv')
AUC_g_df.to_csv('AUC_g_corr.csv')
#% rheo
rheo_shift_df = pd.read_json('./Sensitivity_analysis/rheo_shift_box_kendall_corr.json', orient='records')
rheo_slope_df = pd.read_json('./Sensitivity_analysis/rheo_slope_box_kendall_corr.json', orient='records') #, lines=True)
rheo_g_df = pd.read_json('./Sensitivity_analysis/rheo_g_box_kendall_corr.json', orient='records')
for i in np.array(['FS', 'IB', 'RS inhibitory', 'RS pyramidal']):
rheo_shift_df.loc[rheo_shift_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
rheo_slope_df.loc[rheo_slope_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
rheo_g_df.loc[rheo_g_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
rheo_shift_df_posp = pd.read_json('./Sensitivity_analysis/rheo_shift_box_kendall_corr_pospischil.json', orient='records')
rheo_slope_df_posp = pd.read_json('./Sensitivity_analysis/rheo_slope_box_kendall_corr_pospischil.json', orient='records') #, lines=True)
rheo_g_df_posp = pd.read_json('./Sensitivity_analysis/rheo_g_box_kendall_corr_pospischil.json', orient='records')
rheo_shift_df = rheo_shift_df.append(rheo_shift_df_posp)
rheo_slope_df = rheo_slope_df.append(rheo_slope_df_posp)
rheo_g_df = rheo_g_df.append(rheo_g_df_posp)
rheo_shift_df.to_csv('rheo_shift_corr.csv')
rheo_slope_df.to_csv('rheo_scale_corr.csv')
rheo_g_df.to_csv('rheo_g_corr.csv')

134
Code/Old/FS_mut_pd.py Normal file
View File

@@ -0,0 +1,134 @@
# -*- coding: utf-8 -*-
"""
Created on Sat May 29 21:10:20 2021
@author: nils
"""
import numpy as np
import os
import h5py
import json
from Utility import capacitance, stimulus_init, init_dict, NumpyEncoder
# model parameters
dt = 0.01
sec = 2
low = 0
high = 0.001
number_steps = 200
initial_period = 1000
num_gating = 10
num_current = 7
C, surf_area = capacitance(56.9, 1)
stim_time, I_in, stim_num, V_m = stimulus_init(low, high, number_steps, initial_period, dt, sec)
shift, scale, slope_shift, E, currents_included, b_param, g = init_dict(
np.array(['m', 'h', 'n', 'q', 'r', 'p', 's', 'u', 's_mut', 'u_mut']))
tau_max_p = 502
V_init = -70
V_T = -57.9
# initialize arrays
current = np.zeros((num_current, stim_num))
gating_out = np.zeros((num_gating, stim_num))
# gating parameters
b_param = {}
b_param['m'] = np.array([-34.33054521, -8.21450277, 1.42295686])
b_param['h'] = np.array([-34.51951036, 4.04059373, 1., 0.])
b_param['n'] = np.array([-63.76096946, -13.83488194, 7.35347425])
b_param['q'] = np.array([-39.03684525, -5.57756176, 2.25190197])
b_param['r'] = np.array([-57.37, 20.98, 1.])
b_param['p'] = np.array([-45., -9.9998807337, 1.])
b_param['s'] = np.array([-14.16, -10.15, 1.])
b_param['u'] = np.array([-31., 5.256, 1., 0.245])
b_param['s_mut'] = np.array([-14.16, -10.15, 1.])
b_param['u_mut'] = np.array([-31., 5.256, 1., 0.245])
mut_act_Vhalf_wt = -30.01851851851851
mut_act_k_wt = -7.7333333333333325
s_diff_Vhalf = mut_act_Vhalf_wt - b_param['s'][0]
s_diff_k = mut_act_k_wt - b_param['s'][1]
b_param['s'][1] = b_param['s'][1] + s_diff_k
b_param['u'][1] = b_param['u'][1] + s_diff_k
b_param['s'][0] = b_param['s'][0] + s_diff_Vhalf
b_param['u'][0] = b_param['u'][0] + s_diff_Vhalf
b_param['s_mut'][1] = b_param['s_mut'][1] + s_diff_k
b_param['u_mut'][1] = b_param['u_mut'][1] + s_diff_k
b_param['s_mut'][0] = b_param['s_mut'][0] + s_diff_Vhalf
b_param['u_mut'][0] = b_param['u_mut'][0] + s_diff_Vhalf
# reversal potentials
E["Na"] = 50.
E["K"] = -90.
E["Ca"] = 120.
E["Leak"] = -70.4
# model currents
currents_included["Na"] = True
currents_included["Kd"] = True
currents_included["Kv"] = True
currents_included["Kv_mut"] = True
currents_included["L"] = False
currents_included["M"] = True
currents_included["Leak"] = True
# model conductances
Kv_ratio = 0.1
g["Na"] = 58. * surf_area
g["Kd"] = 3.9 * (1 - Kv_ratio) * surf_area
g["M"] = 0.075 * surf_area
if currents_included["Kv_mut"] == True:
g["Kv"] = 3.9 * Kv_ratio / 2 * surf_area
else:
g["Kv"] = 3.9 * Kv_ratio / 2 * surf_area * 2
g["Kv_mut"] = 3.9 * Kv_ratio / 2 * surf_area
g["L"] = 0. * surf_area
g["Leak"] = 0.038 * surf_area
# save folder
folder = './KCNA1_mutations/FS'
if not os.path.isdir(folder):
os.makedirs(folder)
# mutation properties
mutations = json.load(open("mutations_effects_dict.json"))
# prominence = 50
# # min_spike_height = 0
# desired_AUC_width = high/5
#
# Parallel(n_jobs=8, verbose=9)(
# delayed(Pospischil_multi)(V_init, V_T, g, E, I_in, dt, currents_included, stim_time, stim_num, C, tau_max_p,
# shift, scale, b_param, slope_shift, gating_out, current, prominence,
# desired_AUC_width, mutations, mut, folder, high,low, number_steps, initial_period, sec, save_gating=True)
# for mut in list(mutations.keys()))
#%% Get pd Dataframes for certain variables
import pandas as pd
AUC = pd.DataFrame(columns=mutations.keys())
AUC_rel = pd.DataFrame(columns=mutations.keys())
rheobase = pd.DataFrame(columns=mutations.keys())
rheobase_fit = pd.DataFrame(columns=mutations.keys())
rheobase_null_fit = pd.DataFrame(columns=mutations.keys())
for mut in list(mutations.keys()):
fname = os.path.join(folder, "{}.hdf5".format(mut.replace(" ", "_")))
f = h5py.File(fname, "r")
AUC['{}'.format(mut.replace(" ", "_"))] = f['analysis']['AUC']
AUC_rel['{}'.format(mut.replace(" ", "_"))] = f['analysis']['AUC_rel']
rheobase['{}'.format(mut.replace(" ", "_"))] = f['analysis']['rheobase']
rheobase_fit['{}'.format(mut.replace(" ", "_"))] = f['analysis']['rheobase_fit']
rheobase_null_fit['{}'.format(mut.replace(" ", "_"))] = f['analysis']['rheobase_null_fit']
top_dir = '../KCNA1_mut'
model_name = 'FS'
save_folder = os.path.join(top_dir, 'mut_summary_df')
if not os.path.isdir(save_folder):
os.makedirs(save_folder)
AUC.to_json(os.path.join(save_folder, '{}_AUC.json'.format(model_name)))
AUC_rel.to_json(os.path.join(save_folder, '{}_AUC_rel.json'.format(model_name)))
rheobase.to_json(os.path.join(save_folder, '{}_rheobase.json'.format(model_name)))
rheobase_fit.to_json(os.path.join(save_folder, '{}_rheobase_fit.json'.format(model_name)))
rheobase_null_fit.to_json(os.path.join(save_folder, '{}_rheobase_null_fit.json'.format(model_name)))

View File

@@ -0,0 +1,227 @@
import h5py
import numpy as np
import os
import pandas as pd
spiking = pd.DataFrame(columns=['t', 'RS Pyramidal','RS Inhibitory','FS','IB',
'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'IB +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'Cb stellate','Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$','STN','STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'])
values = pd.DataFrame(index = ['spike_ind', 'ramp_up','ramp_down'], columns=['RS Pyramidal','RS Inhibitory','FS','IB',
'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'IB +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$','Cb stellate','Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$','STN','STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'])
F = pd.DataFrame(columns=['I','I_inhib', 'RS Pyramidal','RS Inhibitory','FS','IB',
'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'IB +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$','Cb stellate','Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$','STN','STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'])
# RS Pyramidal #########################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/RS_pyramidal.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 60
spiking['RS Pyramidal'] = f['data']['V_m'][ind][start:]
spiking['t'] = time
F['I'] = I_mag
F['RS Pyramidal'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'RS Pyramidal'] = I_mag[ind]
values.loc['ramp_up', 'RS Pyramidal'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'RS Pyramidal'] = f['analysis']['ramp_I_down'][()]
# RS Inhibitory #########################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/RS_inhib.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 25
spiking['RS Inhibitory'] = f['data']['V_m'][ind][start:]
F['I_inhib'] = I_mag
F['RS Inhibitory'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'RS Inhibitory'] = I_mag[ind]
values.loc['ramp_up', 'RS Inhibitory'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'RS Inhibitory'] = f['analysis']['ramp_I_down'][()]
# FS#####################################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/FS.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 50
spiking['FS'] = f['data']['V_m'][ind][start:]
F['FS'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'FS'] = I_mag[ind]
values.loc['ramp_up', 'FS'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'FS'] = f['analysis']['ramp_I_down'][()]
# RS Pyramidal Kv #########################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/RS_pyramidal_Kv.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 60
spiking['RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['data']['V_m'][ind][start:]
spiking['t'] = time
F['I'] = I_mag
F['RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = I_mag[ind]
values.loc['ramp_up', 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_down'][()]
# RS Inhibitory #########################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/RS_inhib_Kv.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 50
spiking['RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['data']['V_m'][ind][start:]
F['I_inhib'] = I_mag
F['RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = I_mag[ind]
values.loc['ramp_up', 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_down'][()]
# FS#####################################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/FS_Kv.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 50
spiking['FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['data']['V_m'][ind][start:]
F['FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = I_mag[ind]
values.loc['ramp_up', 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_down'][()]
# Cb Stellate cell ######################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/Cb_stellate.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 60
spiking['Cb stellate'] = f['data']['V_m'][ind][start:]
F['Cb stellate'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'Cb stellate'] = I_mag[ind]
values.loc['ramp_up', 'Cb stellate'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'Cb stellate'] = f['analysis']['ramp_I_down'][()]
# 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
# Cb stellate Kv #############################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/Cb_stellate_Kv.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 130
spiking['Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['data']['V_m'][ind][start:]
F['Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = I_mag[ind]
values.loc['ramp_up', 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_down'][()]
# 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
# Cb stellate Kv only ####################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/Cb_stellate_Delta_Kv.hdf5.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 75
spiking['Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['data']['V_m'][ind][start:]
F['Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = I_mag[ind]
values.loc['ramp_up', 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_down'][()]
# STN ###################################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/STN.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 25
spiking['STN'] = f['data']['V_m'][ind][start:]
F['STN'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'STN'] = I_mag[ind]
values.loc['ramp_up', 'STN'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'STN'] = f['analysis']['ramp_I_down'][()]
# 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
# STN Kv ##################################################################################################
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/STN_Kv.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 95
spiking['STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['data']['V_m'][ind][start:]
F['STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = I_mag[ind]
values.loc['ramp_up', 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_down'][()]
# 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
# STN Kv only #############################################################################################3
script_dir = os.path.dirname(os.path.realpath("__file__"))
fname = os.path.join(script_dir, '../Neuron_models/STN_Delta_Kv.hdf5')
f = h5py.File(fname, "r")
I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'], (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num'])*1000
start = np.int(f['data'].attrs['initial_period']*1/f['data'].attrs['dt'])
stim_len = np.int((f['data'].attrs['stim_time'] - start) *f['data'].attrs['dt'])
time = np.arange(0, stim_len,f['data'].attrs['dt'])
ind = 80
spiking['STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['data']['V_m'][ind][start:]
F['STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['F_inf'][:]
values.loc['spike_ind', 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = I_mag[ind]
values.loc['ramp_up', 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_up'][()]
values.loc['ramp_down', 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] = f['analysis']['ramp_I_down'][()]
#%%
spiking.to_csv('model_spiking.csv')
values.to_csv('firing_values.csv')
F.to_csv('model_F_inf.csv')

18
Code/Old/README.md Normal file
View File

@@ -0,0 +1,18 @@
### Python code repository for Koch et al. 2022
Modelling on the effects of ion current property changes on firing behaviour in diverse neuronal models and in with Kv1.1 mutations that cause episodic ataxia type 1.
## ./Functions
- Python function files for models
- RS pyramidal, RS inhibitory and FS from Pospischil et al. (2008)
- Cb stellate from Alexander et al. (2019) with and without added Kv1.1
- STN from Otsuka et al. (2004) with and without added Kv1.1
- Utility_fxns.py for common useful functions
## ./Neuron_models
- Scripts for simulation of each model to current steps and ramp currents
## ./Sensitivity_Analysis
- Scripts for sensitivity analysis in each model
## ./KCNA1_mutations
- Scripts for simulation of KCNA1 mutations described in Lauxmann et al. (2021)