Started working on Uli's comments
This commit is contained in:
134
Code/FS_mut_pd.py
Normal file
134
Code/FS_mut_pd.py
Normal 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)))
|
||||
227
Code/Firing_csv_generation.py
Normal file
227
Code/Firing_csv_generation.py
Normal 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')
|
||||
BIN
Code/Functions/__pycache__/Cb_stellate_fxns.cpython-39.pyc
Normal file
BIN
Code/Functions/__pycache__/Cb_stellate_fxns.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Code/Functions/__pycache__/Cb_stellate_fxns_Kv.cpython-39.pyc
Normal file
BIN
Code/Functions/__pycache__/Cb_stellate_fxns_Kv.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Code/Functions/__pycache__/Pospischil_fxns.cpython-39.pyc
Normal file
BIN
Code/Functions/__pycache__/Pospischil_fxns.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Code/Functions/__pycache__/STN_fxns.cpython-39.pyc
Normal file
BIN
Code/Functions/__pycache__/STN_fxns.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Code/Functions/__pycache__/STN_fxns_Kv.cpython-39.pyc
Normal file
BIN
Code/Functions/__pycache__/STN_fxns_Kv.cpython-39.pyc
Normal file
Binary file not shown.
@@ -105,7 +105,7 @@ g["T"] = 0.45045 * surf_area
|
||||
g["Leak"] = 0.07407 * surf_area
|
||||
|
||||
# save folder
|
||||
folder = './KCNA1_mutations/Cb_stellate_Kv_only'
|
||||
folder = './KCNA1_mutations/Cb_stellate_Delta_Kv'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
#
|
||||
|
||||
@@ -112,7 +112,7 @@ g["Leak"] = 0.035 * surf_area
|
||||
|
||||
|
||||
# save folder
|
||||
folder = './KCNA1_mutations/STN_Kv_only'
|
||||
folder = './KCNA1_mutations/STN_Delta_Kv'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
#
|
||||
|
||||
477
Code/Plotting_data_collection.py
Normal file
477
Code/Plotting_data_collection.py
Normal file
@@ -0,0 +1,477 @@
|
||||
import pandas as pd
|
||||
import h5py
|
||||
import json
|
||||
import os
|
||||
import numpy as np
|
||||
from ast import literal_eval
|
||||
# todo: run some and test
|
||||
# todo: develop consistent file structure
|
||||
# todo: Model fI
|
||||
# %% todo: Model fI
|
||||
# for each model
|
||||
# | (index) | mag | alt | type | F | I |
|
||||
# | 0 | -10 | m | shift | array | array |
|
||||
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_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'RS pyramidal +Kv1.1', 'RS inhibitory +Kv1.1', 'FS +Kv1.1',
|
||||
'Cb stellate', 'Cb stellate +Kv1.1', 'Cb stellate $\Delta$Kv1.1', 'STN', 'STN +Kv1.1',
|
||||
'STN $\Delta$Kv1.1']
|
||||
# for each model get csv file with all shifts, scale and g
|
||||
for model_name in models:
|
||||
df = pd.DataFrame(columns=['mag', 'alt', 'type', 'F', 'I'])
|
||||
folder = '../Neuron_models/{}'.format(model_name)
|
||||
fname = os.path.join(folder, "{}.hdf5".format(model_name))
|
||||
# for each alt in model
|
||||
# with h5py.File(fname, "r+") as f:
|
||||
# df.loc[model_name, '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]
|
||||
# df.loc[model_name, 'mag'] = var
|
||||
# df.loc[model_name, 'type'] = alt_type
|
||||
# df.loc[model_name, 'F'] = f['analysis']['F_inf'][:]
|
||||
# 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
|
||||
# df.loc[model_name, 'I'] = I
|
||||
# df.to_csv('./Model_fI/{}.csv'.format(model_name))
|
||||
# %% todo: rheo/AUC_{}_corr
|
||||
# | (index) | model | corr | p_value | g | color
|
||||
rheo_corr = pd.DataFrame(columns=['model', 'corr', 'p_value', 'g', 'color'])
|
||||
rheo_corr.to_csv('rheo_corr.csv')
|
||||
|
||||
AUC_corr = pd.DataFrame(columns=['model', 'corr', 'p_value', 'g', 'color'])
|
||||
AUC_corr.to_csv('AUC_corr.csv')
|
||||
|
||||
|
||||
# # AUC_shift = pd.DataFrame(columns=['alteration', 'RS Pyramidal','RS Inhibitory','FS','IB',
|
||||
# # 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$',
|
||||
# # 'FS +$K_V1.1$','IB +$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$'])
|
||||
# #
|
||||
# # AUC_slope = pd.DataFrame(columns=['alteration','RS Pyramidal','RS Inhibitory','FS','IB','RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$',
|
||||
# # 'FS +$K_V1.1$','IB +$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$'])
|
||||
# #
|
||||
# # AUC_g = pd.DataFrame(columns=['alteration','RS Pyramidal','RS Inhibitory','FS','IB','RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$',
|
||||
# # 'FS +$K_V1.1$','IB +$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$'])
|
||||
# #
|
||||
# # script_dir = os.path.dirname(os.path.realpath("__file__"))
|
||||
# # fname = os.path.join(script_dir, )
|
||||
# # # f = h5py.File(fname, "r")
|
||||
# #
|
||||
# # models = ['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate','Cb_stellate_Kv','Cb_stellate_Kv_only','STN','STN_Kv',
|
||||
# # 'STN_Kv_only']
|
||||
# # model_labels = ['RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$',
|
||||
# # 'FS +$K_V1.1$','IB +$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$']
|
||||
# # posp_models = ['RS_pyramidal', 'RS_inhib', 'FS', 'IB']
|
||||
# # posp_model_labels = ['RS Pyramidal','RS Inhibitory', 'FS','IB']
|
||||
# #
|
||||
# #
|
||||
# # shift_interest = 'n'
|
||||
# # for i in range(len(models)):
|
||||
# # with open('./SA_summary_df/{}_shift_AUC_rel_acc.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['0', :])/ data.loc['0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # AUC_shift[model_labels[i]] =data[shift_interest]
|
||||
# # for i in range(len(posp_models)):
|
||||
# # with open('./SA_summary_df_pospischil/{}_shift_AUC_rel_acc_pospischil.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['0', :])/ data.loc['0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # AUC_shift[posp_model_labels[i]] =data[shift_interest]
|
||||
# # AUC_shift['alteration'] = AUC_shift.index
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# # slope_interest = 's'
|
||||
# # for i in range(len(models)):
|
||||
# # with open('./SA_summary_df/{}_slope_AUC_rel_acc.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['1.0', :])/ data.loc['1.0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # try:
|
||||
# # AUC_slope[model_labels[i]] = data[slope_interest]
|
||||
# # except:
|
||||
# # pass
|
||||
# # for i in range(len(posp_models)):
|
||||
# # with open('./SA_summary_df_pospischil/{}_slope_AUC_rel_acc_pospischil.json'.format(models[i])) as json_file:
|
||||
# #
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['1.0', :])/ data.loc['1.0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # try:
|
||||
# # AUC_slope[posp_model_labels[i]] =data[slope_interest]
|
||||
# # except:
|
||||
# # pass
|
||||
# # AUC_slope['alteration'] = AUC_slope.index
|
||||
# #
|
||||
# # g_interest = 'Kd'
|
||||
# # for i in range(len(models)):
|
||||
# # with open('./SA_summary_df/{}_g_AUC_rel_acc.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['1.0', :])/ data.loc['1.0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # AUC_g[model_labels[i]] =data[g_interest]
|
||||
# # for i in range(len(posp_models)):
|
||||
# # with open('./SA_summary_df_pospischil/{}_g_AUC_rel_acc_pospischil.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['1.0', :])/ data.loc['1.0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # AUC_g[posp_model_labels[i]] =data[g_interest]
|
||||
# # AUC_g['alteration'] = AUC_g.index
|
||||
# #
|
||||
# # AUC_shift.to_csv('AUC_shift_ex.csv')
|
||||
# # AUC_slope.to_csv('AUC_slope_ex.csv')
|
||||
# # AUC_g.to_csv('AUC_g_ex.csv')
|
||||
#
|
||||
#
|
||||
# # rheo_shift = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'IB',
|
||||
# # 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$',
|
||||
# # 'FS +$K_V1.1$','IB +$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$'])
|
||||
# #
|
||||
# # rheo_slope = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'IB','RS Pyramidal +$K_V1.1$',
|
||||
# # 'RS Inhibitory +$K_V1.1$',
|
||||
# # 'FS +$K_V1.1$','IB +$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$'])
|
||||
# #
|
||||
# # rheo_g = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'IB',
|
||||
# # 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$',
|
||||
# # 'FS +$K_V1.1$','IB +$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$'])
|
||||
# #
|
||||
# # script_dir = os.path.dirname(os.path.realpath("__file__"))
|
||||
# # fname = os.path.join(script_dir, )
|
||||
# # # f = h5py.File(fname, "r")
|
||||
# #
|
||||
# # models = ['RS_pyramidal', 'RS_inhib', 'FS', 'IB', 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN',
|
||||
# # 'STN_Kv',
|
||||
# # 'STN_Kv_only']
|
||||
# # model_labels = ['RS Pyramidal +$K_V1.1$', 'RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$', 'IB +$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$']
|
||||
# # posp_models = ['RS_pyramidal', 'RS_inhib', 'FS', 'IB']
|
||||
# # posp_model_labels = ['RS Pyramidal','RS Inhibitory', 'FS','IB']
|
||||
# #
|
||||
# # shift_interest = 's'
|
||||
# # for i in range(len(models)):
|
||||
# # with open('./SA_summary_df/{}_shift_rheo.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['0', :]) #/ data.loc['0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # try:
|
||||
# # rheo_shift[model_labels[i]] = data[shift_interest]
|
||||
# # except:
|
||||
# # pass
|
||||
# # for i in range(len(posp_models)):
|
||||
# # with open('./SA_summary_df_pospischil/{}_shift_rheo_pospischil.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['0', :]) #/ data.loc['0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # try:
|
||||
# # rheo_shift[posp_model_labels[i]] = data[shift_interest]
|
||||
# # except:
|
||||
# # pass
|
||||
# # rheo_shift['alteration'] = rheo_shift.index
|
||||
# #
|
||||
# # slope_interest = 'u'
|
||||
# # for i in range(len(models)):
|
||||
# # with open('./SA_summary_df/{}_slope_rheo.json'.format(models[i])) as json_file:
|
||||
# #
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['1.0', :]) #/ data.loc['1.0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # try:
|
||||
# # rheo_slope[model_labels[i]] = data[slope_interest]
|
||||
# # except:
|
||||
# # pass
|
||||
# # for i in range(len(posp_models)):
|
||||
# # with open('./SA_summary_df_pospischil/{}_slope_rheo_pospischil.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['1.0', :]) #/ data.loc['1.0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # # if models[i] == 'STN_Kv_only' or models[i] == 'Cb_stellate_Kv_only':
|
||||
# # # data = data.drop(columns=['A'])
|
||||
# # try:
|
||||
# # rheo_slope[posp_model_labels[i]] = data[slope_interest]
|
||||
# # except:
|
||||
# # pass
|
||||
# # rheo_slope['alteration'] = rheo_slope.index
|
||||
# #
|
||||
# # g_interest = 'Leak'
|
||||
# # for i in range(len(models)):
|
||||
# # with open('./SA_summary_df/{}_g_rheo.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['1.0', :]) #/ data.loc['1.0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # rheo_g[model_labels[i]] = data[g_interest]
|
||||
# # for i in range(len(posp_models)):
|
||||
# # with open('./SA_summary_df_pospischil/{}_g_rheo_pospischil.json'.format(models[i])) as json_file:
|
||||
# # data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # data.replace(0., np.NaN, inplace=True)
|
||||
# # data = (data - data.loc['1.0', :]) #/ data.loc['1.0', :] # normalize AUC
|
||||
# # data.sort_index(inplace=True)
|
||||
# # rheo_g[posp_model_labels[i]] = data[g_interest]
|
||||
# # rheo_g['alteration'] = rheo_g.index
|
||||
# #
|
||||
# #
|
||||
# # rheo_shift.to_csv('rheo_shift_ex.csv')
|
||||
# # rheo_slope.to_csv('rheo_slope_ex.csv')
|
||||
# # rheo_g.to_csv('rheo_g_ex.csv')
|
||||
#
|
||||
# %% firing_values.csv,model_spiking.csv, model_F_inf.csv
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
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_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'RS pyramidal +Kv1.1', 'RS inhibitory +Kv1.1', 'FS +Kv1.1',
|
||||
'Cb stellate', 'Cb stellate +Kv1.1', 'Cb stellate $\Delta$Kv1.1', 'STN', 'STN +Kv1.1',
|
||||
'STN $\Delta$Kv1.1']
|
||||
firing_values = pd.DataFrame(columns=models, index=['spike_ind', 'ramp_up', 'ramp_down'])
|
||||
# firing_values.loc['spike_ind', :] = np.array(
|
||||
# [0.3, 0.04375, 0.25, 0.3, 0.0875, 0.25, 0.3, 0.65, 0.375, 0.125, 0.475, 0.4])
|
||||
|
||||
models = ['RS_pyr', 'RS_pyr_Kv', 'RS_inhib', 'RS_inhib_Kv', 'FS', 'FS_Kv',
|
||||
'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Delta_Kv',
|
||||
'STN', 'STN_Kv', 'STN_Delta_Kv']
|
||||
col_names = ['I', 'I_inhib']
|
||||
for mod in models: col_names.append(mod)
|
||||
model_F_inf = pd.DataFrame(columns=col_names)
|
||||
col_names = ['t']
|
||||
for mod in models: col_names.append(mod)
|
||||
spiking = pd.DataFrame(columns=col_names)
|
||||
|
||||
|
||||
# index for example trace
|
||||
spike_ind = {'RS_pyramidal': 60, 'RS_inhib':25, 'FS':50, 'RS_pyramidal_Kv':60,
|
||||
'RS_inhib_Kv':50, 'FS_Kv':50, 'Cb_stellate':60, 'Cb_stellate_Kv':130,
|
||||
'Cb_stellate_Kv_only':75, 'STN': 25, 'STN_Kv':95, 'STN_Kv_only':80}
|
||||
|
||||
for model_name in models:
|
||||
folder = '../Neuron_models/{}'.format(model_name)
|
||||
fname = os.path.join(folder, "{}.hdf5".format(model_name)) # RS_inhib
|
||||
with h5py.File(fname, "r+") as f:
|
||||
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'])
|
||||
spiking[model_name] = f['data']['V_m'][spike_ind[model_name]][start:]
|
||||
model_F_inf[model_name] = f['analysis']['F_inf'][:]
|
||||
firing_values.loc['spike_ind', model_name] = I_mag[spike_ind[model_name]]
|
||||
firing_values.loc['ramp_down', model_name] = f['analysis']['ramp_I_down'][()]
|
||||
firing_values.loc['ramp_up', model_name] = f['analysis']['ramp_I_up'][()]
|
||||
firing_values.to_csv('firing_values.csv')
|
||||
spiking.to_csv('model_spiking.csv')
|
||||
model_F_inf.to_csv('model_F_inf.csv')
|
||||
# %% model_ramp.csv
|
||||
# | (index) | t | models ....
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN',
|
||||
'STN_Kv', 'STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'Cb stellate', 'Cb stellate +Kv1.1', 'Cb stellate $\Delta$Kv1.1',
|
||||
'STN', 'STN +Kv1.1', 'STN $\Delta$Kv1.1']
|
||||
col_names = ['t']
|
||||
for mod in models: col_names.append(mod)
|
||||
model_ramp = pd.DataFrame(columns=col_names)
|
||||
sec = 4
|
||||
dt = 0.01
|
||||
ramp_len = int(sec * 1000 * 1 / dt)
|
||||
t_ramp = np.arange(0, ramp_len) * dt
|
||||
model_ramp.loc[:, 't'] = t_ramp
|
||||
|
||||
for model_name in models:
|
||||
folder = '../Neuron_models/{}'.format(model_name)
|
||||
fname = os.path.join(folder, "{}.hdf5".format(model_name)) # RS_inhib
|
||||
with h5py.File(fname, "r+") as f:
|
||||
model_ramp.loc[:, model_name] = f['analysis']['V_m_ramp'][()]
|
||||
|
||||
model_ramp.to_csv('model_ramp.csv')
|
||||
|
||||
# %% sim_mut_AUC.csv, sim_mut_rheo.csv
|
||||
# generate mutation plot data
|
||||
|
||||
mutations = json.load(open("../mutations_effects_dict.json"))
|
||||
keys_to_remove = ['V408L', 'T226R', 'R239S', 'R324T']
|
||||
for key in keys_to_remove:
|
||||
del mutations[key]
|
||||
mutations_f = []
|
||||
mutations_n = []
|
||||
for mut in mutations:
|
||||
mutations_n.append(mut)
|
||||
mutations_f.append(mut.replace(" ", "_"))
|
||||
|
||||
models = ['RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN',
|
||||
'STN_Kv', 'STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'Cb stellate', 'Cb stellate +Kv1.1', 'Cb stellate $\Delta$Kv1.1',
|
||||
'STN', 'STN +Kv1.1', 'STN $\Delta$Kv1.1']
|
||||
AUC = pd.DataFrame(columns=mutations_n)
|
||||
rheobase = pd.DataFrame(columns=mutations_n)
|
||||
save_folder = '../KCNA1_mutations'
|
||||
if not os.path.isdir(save_folder):
|
||||
os.makedirs(save_folder)
|
||||
for model_name in models:
|
||||
folder = '../KCNA1_mutations/{}'.format(model_name)
|
||||
for mut in list(mutations_n):
|
||||
fname = os.path.join(folder, "{}.hdf5".format(mut.replace(" ", "_")))
|
||||
with h5py.File(fname, "r+") as f:
|
||||
rheobase.loc[mut.replace(" ", "_"), model_name] = f['analysis']['rheobase'][()]
|
||||
AUC.loc[mut.replace(" ", "_"), model_name] = f['analysis']['AUC'][()]
|
||||
AUC.replace(0., np.NaN, inplace=True)
|
||||
rheobase.replace(0., np.NaN, inplace=True)
|
||||
rheobase = (rheobase - rheobase.loc['WT', :]) /rheobase.loc['WT', :]
|
||||
AUC = (AUC - AUC.loc['WT', :]) /AUC.loc['WT', :]
|
||||
AUC.to_csv(os.path.join(save_folder, 'sim_mut_AUC.csv'))
|
||||
rheobase.to_csv(os.path.join(save_folder, 'sim_mut_rheobase.csv'))
|
||||
|
||||
|
||||
#########################################################################################################################
|
||||
#########################################################################################################################
|
||||
#########################################################################################################################
|
||||
#########################################################################################################################
|
||||
#########################################################################################################################
|
||||
#########################################################################################################################
|
||||
#########################################################################################################################
|
||||
#########################################################################################################################
|
||||
#%% sim_mut_rheo.csv, sim_mut_AUC.csv
|
||||
# models = ['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate','Cb_stellate_Kv','Cb_stellate_Kv_only','STN','STN_Kv','STN_Kv_only']
|
||||
# mutations = json.load(open("./mutations_effects_dict.json"))
|
||||
# mutations2 = []
|
||||
# for mut in mutations:
|
||||
# mutations2.append(mut.replace(" ", "_"))
|
||||
# AUC_total = pd.DataFrame(columns=list(mutations2), index=models)
|
||||
# AUC_rel_total = pd.DataFrame(columns=list(mutations2), index=models)
|
||||
# rheo_total = pd.DataFrame(columns=list(mutations2), index=models)
|
||||
# rheo_fit_total = pd.DataFrame(columns=list(mutations2), index=models)
|
||||
# for mod in models:
|
||||
# print(mod)
|
||||
# with open('./mut_summary_df/{}_AUC.json'.format(mod)) as json_file:
|
||||
# df = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # df[mutations2].to_json('./mut_summary_df/{}_AUC.json'.format(mod))
|
||||
# AUC_total.loc[mod, :] = df.loc['0',:]
|
||||
# with open('./mut_summary_df/{}_AUC_rel.json'.format(mod)) as json_file:
|
||||
# df = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # df[mutations2].to_json('./mut_summary_df/{}_AUC.json'.format(mod))
|
||||
# AUC_rel_total.loc[mod, :] = df.loc['0',:]
|
||||
# with open('./mut_summary_df/{}_rheobase.json'.format(mod)) as json_file:
|
||||
# df = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # df[mutations2].to_json('./mut_summary_df/{}_AUC.json'.format(mod))
|
||||
# rheo_total.loc[mod, :] = df.loc['0',:]
|
||||
# with open('./mut_summary_df/{}_rheobase_fit.json'.format(mod)) as json_file:
|
||||
# df = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
# # df[mutations2].to_json('./mut_summary_df/{}_AUC.json'.format(mod))
|
||||
# rheo_fit_total.loc[mod, :] = df.loc['0',:]
|
||||
#
|
||||
# # AUC_diff = (AUC_score.subtract(AUC_score['wt'], axis =0))#.divide(AUC_score['wt'], axis=0)
|
||||
# AUC_total.to_json('mutation_AUC_summary.json')
|
||||
# AUC_rel_total.to_json('mutation_AUC_rel_summary.json')
|
||||
# rheo_total.to_json('mutation_rheo_summary.json')
|
||||
# rheo_fit_total.to_json('mutation_rheo_fit_summary.json')
|
||||
|
||||
# models = ['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN',
|
||||
# 'STN_Kv', 'STN_Kv_only']
|
||||
# model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'IB', '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}$']
|
||||
#
|
||||
# all_mut_rheo = pd.DataFrame(columns=[model_names])
|
||||
# all_mut_AUC = pd.DataFrame(columns=[model_names])
|
||||
# for mod in range(len(models)):
|
||||
# AUC = pd.read_json('./CBZ_summary_df/{}_CBZ_AUC_rel_acc.json'.format(models[mod]), convert_axes=False,
|
||||
# convert_dates=False)
|
||||
# rheo = pd.read_json('./CBZ_summary_df/{}_CBZ_rheobase.json'.format(models[mod]), convert_axes=False,
|
||||
# convert_dates=False)
|
||||
# AUC.index = AUC.index.astype(float)
|
||||
#
|
||||
# rheo.index = rheo.index.astype(float)
|
||||
#
|
||||
# conc = np.array(AUC.index)
|
||||
# mut_names = AUC.columns
|
||||
# for m in mut_names:
|
||||
# rheo[m] = rheo[m].map(lambda x: x[0])
|
||||
# AUC[m] = AUC[m].map(lambda x: x[0])
|
||||
# AUC.replace(0., np.NaN, inplace=True)
|
||||
# rheo.replace(0., np.NaN, inplace=True)
|
||||
# AUC = (AUC - AUC.loc[0, 'wt']) / AUC.loc[0, :] # normalize AUC
|
||||
# AUC.sort_index(inplace=True)
|
||||
# rheo = (rheo - rheo.loc[0, 'wt'])#/ rheo.loc[0, :] # normalize AUC
|
||||
# rheo.sort_index(inplace=True)
|
||||
#
|
||||
#
|
||||
# for mut in mut_names: # for each mutation
|
||||
# x_mut = rheo.loc[:, mut.replace(" ", "_")]
|
||||
# y_mut = AUC.loc[:, mut.replace(" ", "_")]
|
||||
#
|
||||
# all_mut_rheo[model_names[mod]] = rheo.loc[0.0, mut_names]
|
||||
# all_mut_AUC[model_names[mod]] = AUC.loc[0.0, mut_names]
|
||||
#
|
||||
#
|
||||
#
|
||||
# all_mut_rheo.to_csv('sim_mut_rheo.csv')
|
||||
# all_mut_AUC.to_csv('sim_mut_AUC.csv')
|
||||
|
||||
|
||||
|
||||
|
||||
# # %% model_F_inf.csv
|
||||
# # | (index) | I | I_inhib | models ....
|
||||
#
|
||||
# # models
|
||||
# models = ['RS_pyr', 'RS_pyr_Kv', 'RS_inhib', 'RS_inhib_Kv', 'FS', 'FS_Kv',
|
||||
# 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Delta_Kv',
|
||||
# 'STN', 'STN_Kv', 'STN_Delta_Kv']
|
||||
# col_names = ['I', 'I_inhib']
|
||||
# for mod in models: col_names.append(mod)
|
||||
# model_F_inf = pd.DataFrame(columns=col_names)
|
||||
# folder = '../Neuron_models'
|
||||
# with h5py.File(os.path.join(folder, "RS_pyr.hdf5"), "r+") as f:
|
||||
# model_F_inf['I'] = np.arange(f['data'].attrs['low'][()], f['data'].attrs['high'][()],
|
||||
# (f['data'].attrs['high'][()] - f['data'].attrs['low'][()]) /
|
||||
# f['data'].attrs['stim_num'][()])
|
||||
# with h5py.File(os.path.join(folder, "RS_inhib.hdf5"), "r+") as f:
|
||||
# model_F_inf['I_inhib'] = np.arange(f['data'].attrs['low'][()], f['data'].attrs['high'][()],
|
||||
# (f['data'].attrs['high'][()] - f['data'].attrs['low'][()]) /
|
||||
# f['data'].attrs['stim_num'][()])
|
||||
#
|
||||
# for model_name in models:
|
||||
# fname = os.path.join(folder, "{}.hdf5".format(model_name)) # RS_inhib
|
||||
# with h5py.File(fname, "r+") as f:
|
||||
# model_F_inf[model_name] = f['analysis']['F_inf'][()]
|
||||
#
|
||||
# # save df
|
||||
# model_F_inf.to_csv('model_F_inf.csv')
|
||||
@@ -5,7 +5,7 @@ Modelling on the effects of ion current property changes on firing behaviour in
|
||||
- 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
|
||||
- STN from Otsuka et al. (2004) with and without added Kv1.1
|
||||
- Utility_fxns.py for common useful functions
|
||||
|
||||
## ./Neuron_models
|
||||
|
||||
@@ -80,7 +80,7 @@ g["Leak"] = 0.07407 * surf_area
|
||||
|
||||
|
||||
# save folder
|
||||
folder = './SA/Cb_stellate'
|
||||
folder = '../Sensitivity_Analysis/Cb_stellate'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ g["T"] = 0.45045 * surf_area
|
||||
g["Leak"] = 0.07407 * surf_area
|
||||
|
||||
# save folder
|
||||
folder = './SA/Cb_stellate_Kv_only'
|
||||
folder = './Sensitivity_Analysis/Cb_stellate_Delta_Kv'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ g["Leak"] = 0.038 * surf_area
|
||||
|
||||
|
||||
# folder to save to
|
||||
folder = './Sensitivity_Analysis/FS'
|
||||
folder = '../Sensitivity_Analysis/FS'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ g["L"] = 0. * surf_area
|
||||
g["Leak"] = 0.038 * surf_area
|
||||
|
||||
# save folder
|
||||
folder = './Sensitivity_Analysis/FS_Kv'
|
||||
folder = '../Sensitivity_Analysis/FS_Kv'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ g["L"] = 0.
|
||||
g["Leak"] = 0.0205 * surf_area
|
||||
|
||||
# save folder
|
||||
folder = './Sensitivity_Analysis/RS_inhib'
|
||||
folder = '../Sensitivity_Analysis/RS_inhib'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ g["L"] = 0. * surf_area
|
||||
g["Leak"] = 0.0205 * surf_area
|
||||
|
||||
# save folder
|
||||
folder = './Sensitivity_Analysis/RS_inhib_Kv'
|
||||
folder = '../Sensitivity_Analysis/RS_inhib_Kv'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ g["Kv_mut"] = 0.
|
||||
g["L"] = 0.
|
||||
g["Leak"] = 0.0205 * surf_area
|
||||
|
||||
folder = './Sensitivity_Analysis/RS_pyramidal'
|
||||
folder = '../Sensitivity_Analysis/RS_pyramidal'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ g["L"] = 0. * surf_area
|
||||
g["Leak"] = 0.0205 * surf_area
|
||||
|
||||
# save folder
|
||||
folder = './Sensitivity_Analysis/RS_pyramidal_Kv'
|
||||
folder = '../Sensitivity_Analysis/RS_pyramidal_Kv'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ g["Leak"] = 0.035 * surf_area
|
||||
V_init = -70
|
||||
|
||||
# save folder
|
||||
folder = './Sensitivity_Analysis/STN_Kv_only'
|
||||
folder = '../Sensitivity_Analysis/STN_Delta_Kv'
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user