def chirpForMulti(invar): sec_num, loc, filename = invar from getCells import HayCell pt_cell = HayCell() seg = pt_cell.apic[sec_num](loc) from neuron import h for sec in h.allsec(): try: sec.uninsert('SK_E2') except: pass from chirpUtils import applyChirp, getChirp amp = 0.0025 f0, f1, t0, Fs, delay = 0.5, 20, 20, 1000, 5 # for looking at bimodal leading phase response in Hay cell I, t = getChirp(f0, f1, t0, amp, Fs, delay) print('running chirp on ' + str(seg)) applyChirp(I, t, seg, pt_cell.soma[0](0.5), t0, delay, Fs, f1, out_file_name=filename)
def chirpForMulti(invar): model, sec_num, loc, filename = invar if model == 'kole': from getCells import KoleCell cell, _ = KoleCell() seg = cell.apic[sec_num](loc) soma_seg = cell.soma(0.5) if model == 'kolenoim': from getCells import KoleCell cell, _ = KoleCell() from neuron import h for sec in h.allsec(): try: sec.uninsert('Km') except: pass seg = cell.apic[sec_num](loc) soma_seg = cell.soma(0.5) elif model == 'neymotinkole': from getCells import NeymotinKoleCell cell = NeymotinKoleCell() seg = cell.apic[sec_num](loc) soma_seg = cell.soma(0.5) elif model == 'neymotinharnett': from getCells import NeymotinHarnettCell cell = NeymotinHarnettCell() seg = cell.apic[sec_num](loc) soma_seg = cell.soma(0.5) elif model == 'neymotinmigliore': from getCells import NeymotinMiglioreCell cell = NeymotinMiglioreCell() seg = cell.apic[sec_num](loc) soma_seg = cell.soma(0.5) elif model == 'hay': from getCells import HayCell cell, _ = HayCell() seg = cell.apic[sec_num](loc) soma_seg = cell.soma[0](0.5) elif model == 'ackerantic': from getCells import AckerAnticCell cell = AckerAnticCell() seg = cell.apical[sec_num](loc) soma_seg = cell.soma[0](0.5) elif model == 'haymig': from getCells import HayCellMig cell, _ = HayCellMig() seg = cell.apic[sec_num](loc) soma_seg = cell.soma[0](0.5) from chirpUtils import applyChirp, getChirp amp = 0.025 f0, f1, t0, Fs, delay = 0.5, 10, 10, 1000, 5 # for looking at bimodal leading phase response in Hay cell I, t = getChirp(f0, f1, t0, amp, Fs, delay) print('running chirp on ' + str(seg)) applyChirp(I, t, seg, soma_seg, t0, delay, Fs, f1, out_file_name=filename) print(str(sec) + ' ' + str(loc) + ': done')
def chirpForMulti(invar): model, sec_num, loc, filename = invar cell = HayCellSWC('../suter_shepherd/' + model) seg = cell.apic[sec_num](loc) soma_seg = cell.soma[0](0.5) from chirpUtils import applyChirp, getChirp amp = 0.025 f0, f1, t0, Fs, delay = 0.5, 10, 10, 1000, 5 # for looking at bimodal leading phase response in Hay cell I, t = getChirp(f0, f1, t0, amp, Fs, delay) print('running chirp on ' + str(seg)) applyChirp(I, t, seg, soma_seg, t0, delay, Fs, f1, out_file_name=filename) print(str(seg) + ': done')
def chirpForMulti(invar): sec_num, loc, filename = invar from getCells import M1Cell s = M1Cell() seg = s.net.cells[0].secs[sec_num]['hObj'](loc) soma_seg = s.net.cells[0].secs['soma']['hObj'](0.5) from chirpUtils import applyChirp, getChirp amp = 0.025 f0, f1, t0, Fs, delay = 0.5, 10, 10, 1000, 5 # for looking at bimodal leading phase response in Hay cell I, t = getChirp(f0, f1, t0, amp, Fs, delay) print('running chirp on ' + str(seg)) applyChirp(I, t, seg, soma_seg, t0, delay, Fs, f1, out_file_name=filename) print(str(seg) + ': done')
# f0, f1, t0, Fs, delay = 0.5, 100, 100, 1000, 5 # for looking at bimodal leading phase response in Hay cell I, t = getChirp(f0, f1, t0, amp, Fs, delay) # define output variables #main loop for sec in secList: nseg = sec.nseg if nseg == 1: loc = 0.5 applyChirp( I, t, sec(loc), soma_seg, t0, delay, Fs, f1, out_file_name= '/home/craig_kelley_downstate_edu/L5PYR_Resonance/allen_phase/' + str(sec(loc))) else: for loc in np.linspace(1 / (nseg + 1), nseg / (nseg + 1), nseg): applyChirp( I, t, sec(loc), soma_seg, t0, delay, Fs,
## record voltages from neuron import h, gui soma_v = h.Vector().record(soma_seg._ref_v) dend_v = h.Vector().record(seg._ref_v) time = h.Vector().record(h._ref_t) ## parameters of the chirp stimulus from chirpUtils import applyChirp, getChirp amp = 0.025 # amplitude of chirp stim f0, f1, t0, Fs, delay = 0.5, 20, 20, 1000, 5 # initial and final frequencies, duration, sampling freq, delay I, t = getChirp(f0, f1, t0, amp, Fs, delay) # defines current clamp ## run simulation print('Running chirp on ' + str(seg)) out = applyChirp(I, t, seg, soma_seg, t0, delay, Fs, f1) ## plotting from matplotlib import pyplot as plt ### traces trace_fig = plt.figure(figsize=(8,10)) plt.subplot(3,1,1) plt.plot(t,I) plt.title('Chirp Sitmulation', fontsize=14) plt.ylabel('Current (mA)', fontsize=14) plt.xticks(fontsize=12) plt.yticks(fontsize=12) plt.xlim(4000,16000) plt.subplot(3,1,2) plt.plot(time, dend_v) plt.title(r'Local V$_{memb}$', fontsize=14)
ZinPeakPhaseFreq = [] ZinLeadPhaseBW = [] ZinLeadPhaseMinFreq = [] ZinSynchFreq = [] ZinLeadPhaseBool = [] ZcPeakPhaseFreq = [] ZcLeadPhaseBW = [] ZcLeadPhaseMinFreq = [] ZcSynchFreq = [] ZcLeadPhaseBool = [] #main loop nseg = sec.nseg if nseg == 1: loc = 0.5 out = applyChirp(I, t, sec(loc), soma_seg, t0, delay, Fs, f1) ZinResAmp.append(out['ZinResAmp']) ZinResFreq.append(out['ZinResFreq']) ZcResAmp.append(out['ZcResAmp']) ZcResFreq.append(out['ZcResFreq']) dist.append(out['dist']) QfactorIn.append(out['QfactorIn']) QfactorTrans.append(out['QfactorTrans']) fVarIn.append(out['fVarIn']) fVarTrans.append(out['fVarTrans']) freqs = out['Freq'][np.argwhere(out['ZinPhase'] > 0)] if len(freqs) > 0: ZinPeakPhaseFreq.append(out['Freq'][np.argwhere( out['ZinPhase'] == np.max(out['ZinPhase']))]) ZinLeadPhaseBW.append(freqs[-1] - freqs[0])
def chirpForMulti(invar): sec_num, loc, filename = invar from getCells import AllenCell pt_cell = AllenCell('./497232419') seg = pt_cell.apical[sec_num](loc) from neuron import h for sec in h.allsec(): try: sec.uninsert('SK') except: pass from chirpUtils import applyChirp, getChirp amp = 0.0025 f0, f1, t0, Fs, delay = 0.5, 20, 20, 1000, 5 I, t = getChirp(f0, f1, t0, amp, Fs, delay) print('running chirp on ' + str(seg)) # applyChirp(I, t, seg, pt_cell.soma[0](0.5), t0, delay, Fs, f1, out_file_name=filename) out = applyChirp(I, t, seg, pt_cell.soma[0](0.5), t0, delay, Fs, f1) ZinResAmp = [] ZinResFreq = [] ZcResAmp = [] ZcResFreq = [] dist = [] QfactorIn = [] QfactorTrans = [] fVarIn = [] fVarTrans = [] ZinPeakPhaseFreq = [] ZinLeadPhaseBW = [] ZinLeadPhaseMinFreq = [] ZinSynchFreq = [] ZinLeadPhaseBool = [] ZcPeakPhaseFreq = [] ZcLeadPhaseBW = [] ZcLeadPhaseMinFreq = [] ZcSynchFreq = [] ZcLeadPhaseBool = [] ZinResAmp.append(out['ZinResAmp']) ZinResFreq.append(out['ZinResFreq']) ZcResAmp.append(out['ZcResAmp']) ZcResFreq.append(out['ZcResFreq']) dist.append(out['dist']) QfactorIn.append(out['QfactorIn']) QfactorTrans.append(out['QfactorTrans']) fVarIn.append(out['fVarIn']) fVarTrans.append(out['fVarTrans']) freqs = out['Freq'][np.argwhere(out['ZinPhase'] > 0)] if len(freqs) > 0: ZinPeakPhaseFreq.append(out['Freq'][np.argwhere( out['ZinPhase'] == np.max(out['ZinPhase']))]) ZinLeadPhaseBW.append(freqs[-1] - freqs[0]) ZinLeadPhaseMinFreq.append(freqs[0]) ZinSynchFreq.append(freqs[-1]) ZinLeadPhaseBool.append(out['ZinPhase'] > 0) else: ZinPeakPhaseFreq.append(nan) ZinLeadPhaseBW.append(0) ZinLeadPhaseMinFreq.append(nan) ZinSynchFreq.append(nan) ZinLeadPhaseBool.append(out['ZinPhase'] > 0) freqs = out['Freq'][np.argwhere(out['ZcPhase'] > 0)] if len(freqs) > 0: ZcPeakPhaseFreq.append( out['Freq'][np.argwhere(out['ZcPhase'] == np.max(out['ZcPhase']))]) ZcLeadPhaseBW.append(freqs[-1] - freqs[0]) ZcLeadPhaseMinFreq.append(freqs[0]) ZcSynchFreq.append(freqs[-1]) ZcLeadPhaseBool.append(out['ZcPhase']) else: ZcPeakPhaseFreq.append(nan) ZcLeadPhaseBW.append(0) ZcLeadPhaseMinFreq.append(nan) ZcSynchFreq.append(nan) ZcLeadPhaseBool.append(out['ZcPhase']) print(str(sec) + ' ' + str(loc) + ': done') output = { 'ZinResAmp': ZinResAmp, 'ZinResFreq': ZinResFreq, 'ZcResAmp': ZcResAmp, 'ZcResFreq': ZcResFreq, 'dist': dist, 'QfactorIn': QfactorIn, 'QfactorTrans': QfactorTrans, 'fVarIn': fVarIn, 'fVarTrans': fVarTrans, 'ZinPeakPhaseFreq': ZinPeakPhaseFreq, 'ZinLeadPhaseBW': ZinLeadPhaseBW, 'ZinLeadPhaseMinFreq': ZinLeadPhaseMinFreq, 'ZinSynchFreq': ZinSynchFreq, 'ZinLeadPhaseBool': ZinLeadPhaseBool, 'ZcPeakPhaseFreq': ZcPeakPhaseFreq, 'ZcLeadPhaseBW': ZcLeadPhaseBW, 'ZcLeadPhaseMinFreq': ZcLeadPhaseMinFreq, 'ZcSynchFreq': ZcSynchFreq, 'ZcLeadPhaseBool': ZcLeadPhaseBool } savemat(filename + '.mat', output)
from getCells import AckerAnticCell import numpy as np import sys from scipy.io import savemat from math import nan pt_cell = AckerAnticCell() sec_list = [pt_cell.apical[15], pt_cell.apical[34], pt_cell.basal[8]] soma_seg = pt_cell.soma[0](0.5) from chirpUtils import applyChirp from chirpUtils import getChirp amp = 0.0025 amp = amp * 10 # as per srdjan's suggestion f0, f1, t0, Fs, delay = 0.5, 50, 50, 1000, 5 # 12 # original for all cells I, t = getChirp(f0, f1, t0, amp, Fs, delay) loc = 0.5 for sec in sec_list: out = applyChirp(I, t, sec(loc), soma_seg, t0, delay, Fs, f1, out_file_name='/u/craig/L5PYR_Resonance/amplitude_test/' + str(sec))
import multiprocessing from math import nan from scipy.io import savemat from getCells import M1Cell s = M1Cell() sec_num = 'apic_22' loc = 0.5 Ks = float(sys.argv[-1]) Kh = float(sys.argv[-2]) from neuron import h for sec in h.allsec(): for seg in sec.allseg(): try: seg.hd.Ks = Ks seg.hd.Kh = Kh except: pass seg = s.net.cells[0].secs[sec_num]['hObj'](loc) soma_seg = s.net.cells[0].secs['soma']['hObj'](0.5) from chirpUtils import applyChirp, getChirp amp = 0.025 f0, f1, t0, Fs, delay = 0.5, 20, 20, 1000, 5 # for looking at bimodal leading phase response in Hay cell I, t = getChirp(f0, f1, t0, amp, Fs, delay) print('running chirp on ' + str(seg)) filename = 'M1_PTcell/vary_ih_ilk/' + sec_num + '_kh_' + sys.argv[ -2] + '_ks_' + sys.argv[-1] applyChirp(I, t, seg, soma_seg, t0, delay, Fs, f1, out_file_name=filename)
def chirpForMulti(invar): sec_num, loc, morph_file, filename = invar from getCells import HayCellSWC pt_cell = HayCellSWC(morphology_file=morph_file) seg = pt_cell.apic[sec_num](loc) from chirpUtils import applyChirp, getChirp amp = 0.0025 f0, f1, t0, Fs, delay = 0.5, 30, 30, 1000, 5 # for looking at bimodal leading phase response in Hay cell I, t = getChirp(f0, f1, t0, amp, Fs, delay) print('running chirp on ' + str(seg)) out = applyChirp(I, t, seg, pt_cell.soma[0](0.5), t0, delay, Fs, f1) ZinResAmp = [] ZinResFreq = [] ZcResAmp = [] ZcResFreq = [] dist = [] QfactorIn = [] QfactorTrans = [] fVarIn = [] fVarTrans = [] ZinPeakPhaseFreq = [] ZinLeadPhaseBW = [] ZinLeadPhaseMinFreq = [] ZinSynchFreq = [] ZinLeadPhaseBool = [] ZcPeakPhaseFreq = [] ZcLeadPhaseBW = [] ZcLeadPhaseMinFreq = [] ZcSynchFreq = [] ZcLeadPhaseBool = [] ZinResAmp.append(out['ZinResAmp']) ZinResFreq.append(out['ZinResFreq']) ZcResAmp.append(out['ZcResAmp']) ZcResFreq.append(out['ZcResFreq']) dist.append(out['dist']) QfactorIn.append(out['QfactorIn']) QfactorTrans.append(out['QfactorTrans']) fVarIn.append(out['fVarIn']) fVarTrans.append(out['fVarTrans']) freqs = out['Freq'][np.argwhere(out['ZinPhase'] > 0)] if len(freqs) > 0: ZinSynchFreq.append(freqs[-1]) else: ZinSynchFreq.append(nan) freqs = out['Freq'][np.argwhere(out['ZcPhase'] > 0)] if len(freqs) > 0: freqs = freqs[freqs < 10] ZcSynchFreq.append(freqs[-1]) else: ZcSynchFreq.append(nan) print(str(sec) + ' ' + str(loc) + ': done') output = { 'ZinResAmp': ZinResAmp, 'ZinResFreq': ZinResFreq, 'ZcResAmp': ZcResAmp, 'ZcResFreq': ZcResFreq, 'dist': dist, 'QfactorIn': QfactorIn, 'QfactorTrans': QfactorTrans, 'fVarIn': fVarIn, 'fVarTrans': fVarTrans, 'ZinSynchFreq': ZinSynchFreq, 'ZcSynchFreq': ZcSynchFreq } savemat(filename + '.mat', output)