Пример #1
0
def func_to_optimize(parameters, saveFig="", deleteFiles=True, rankID=0):
    A = run_model(parameters, saveFig, deleteFiles, rankID)
    timesAll = A[0]
    timeCoursesAll = A[1]

    mydict = {}
    if len(saveFig) > 0:
        close("all")
        f, axarr = subplots(len(OBJECTIVE_DATA), 1)
    objs = []
    imeas = [0, 5]  # cAMP and PKAc traces
    for iobjective in range(0, len(OBJECTIVE_DATA)):
        objs_thisobj = []
        times = timesAll[0]
        timeCourses = mytools.interpolate(times[0],
                                          timeCoursesAll[0][imeas[iobjective]],
                                          OBJECTIVE_ts)
        mydict['f' + str(iobjective)] = sum(
            abs(array(timeCourses) - array(OBJECTIVE_DATA[iobjective]))) / max(
                array(OBJECTIVE_DATA[iobjective]))

        if len(saveFig) > 0:
            axarr[iobjective].plot(OBJECTIVE_ts_highres,
                                   OBJECTIVE_DATA_highres[iobjective], 'b--')
            axarr[iobjective].plot(OBJECTIVE_ts, OBJECTIVE_DATA[iobjective],
                                   'bx')
            axarr[iobjective].plot(times[0],
                                   timeCoursesAll[0][imeas[iobjective]], 'r--')
            axarr[iobjective].plot(OBJECTIVE_ts, timeCourses, 'rx')
            #axarr[iobjective].text(times[0],Ylims[1]*0.2+Ylims[0]*0.8,str(objs[iobjective]),fontsize=5)
            #axarr[iobjective].set_ylabel(Objective_titles[iobjective],fontsize=5)
            for tick in axarr[iobjective].xaxis.get_major_ticks(
            ) + axarr[iobjective].yaxis.get_major_ticks():
                tick.label.set_fontsize(3.5)
        Ylims = axarr[iobjective].get_ylim()
        if iobjective == 0:
            axarr[0].text(OBJECTIVE_ts[0],
                          Ylims[1] * 0.8 + Ylims[0] * 0.2,
                          str(parameters),
                          color='#0000FF',
                          fontsize=5)
        else:
            axarr[1].text(OBJECTIVE_ts[0],
                          Ylims[1] * 0.8 + Ylims[0] * 0.2,
                          str(mydict),
                          color='#0000FF',
                          fontsize=5)

    if len(saveFig) > 0:
        picklelist = A
        file = open(saveFig + '_data.sav', 'w')
        pickle.dump(picklelist, file)
        file.close()
        f.savefig(saveFig + '_obj.eps')
    return mydict
                        Cadend3 = np.array(h.cadend3)
                        SKdend3 = np.array(h.skdend3)
                        spikes = mytools.spike_times(times, Vsoma, -35, -45)

                        CasomaupThisIter.append(max(Casoma))
                        SKsomaupThisIter.append(max(SKsoma))
                        VdendupThisIter.append(max(Vdend))
                        Vdend2upThisIter.append(max(Vdend2))
                        Vdend3upThisIter.append(max(Vdend3))
                        Cadend3upThisIter.append(max(Cadend3))
                        SKdend3upThisIter.append(max(SKdend3))
                        spikesupThisIter.append(spikes[:])

                        times_tcshort = [2900 + x for x in range(0, 301)]
                        Vdend3tcupThisIter.append(
                            mytools.interpolate(times, Vdend3, times_tcshort))
                        Cadend3tcupThisIter.append(
                            mytools.interpolate(times, Cadend3, times_tcshort))
                        SKdend3tcupThisIter.append(
                            mytools.interpolate(times, SKdend3, times_tcshort))

                        if epspdts[idt] in epspdts_savetimecourses:
                            times_tc = [2680 + x for x in range(0, 641)]
                            Vsoma_tc = mytools.interpolate(
                                times, Vsoma, times_tc)
                            Casoma_tc = mytools.interpolate(
                                times, Casoma, times_tc)
                            SKsoma_tc = mytools.interpolate(
                                times, SKsoma, times_tc)
                            Vdend_tc = mytools.interpolate(
                                times, Vdend, times_tc)
Пример #3
0
if len(sys.argv) > 5 and (sys.argv[1].find("mpi") > -1
                          or sys.argv[2].find("mpi") > -1):
    argv_i_flux = 4

if len(sys.argv) > argv_i_flux:
    cAMP_flux = float(sys.argv[argv_i_flux])

A = scipy.io.loadmat(
    'cAMP_withdiss_test_tstop22000_tol1e-08_onset800.0_n1_freq1.0_dur16000.0_flux'
    + str(cAMP_flux) + '.mat')
if A['times'].shape[1] == 1:
    A['times'] = A['times'].T

OBJECTIVE_ts = [1000 + 1000 * i for i in range(0, 21)]
OBJECTIVE_DATA = [
    mytools.interpolate(A['times'][0], A['tcDATA'][0] + A['tcDATA'][1],
                        OBJECTIVE_ts),  #Time course of cAMP
    mytools.interpolate(A['times'][0], A['tcDATA'][5], OBJECTIVE_ts)
]  #Time course of PKAc
OBJECTIVE_ts_highres = [1000 + 100 * i for i in range(0, 201)]
OBJECTIVE_DATA_highres = [
    mytools.interpolate(A['times'][0], A['tcDATA'][0] + A['tcDATA'][1],
                        OBJECTIVE_ts_highres),  #Time course of cAMP
    mytools.interpolate(A['times'][0], A['tcDATA'][5], OBJECTIVE_ts_highres)
]  #Time course of PKAc

mesh_input_file = open('mesh_general.out', 'r')
mesh_firstline = mesh_input_file.readline()
mesh_secondline = mesh_input_file.readline()
mesh_values = mesh_secondline.split()
my_volume = float(mesh_values[-2]) * 1e-15  #litres
mesh_input_file.close()
Пример #4
0
    mySquareAmpsAll = unpickledlist[0]
    mySynAmpsAll = unpickledlist[1]

    squareAmps = [
        mySquareAmpsAll[i][0][-1] for i in range(0, len(mySquareAmpsAll))
    ]
    synAmps = [mySynAmpsAll[i][0][-1] for i in range(0, len(mySynAmpsAll))]
    squareDurs = [5, 5, 5]

    unpicklefile = open('control_cs' + str(icell) + '.sav', 'r')
    unpickledlist = pickle.load(unpicklefile)
    unpicklefile.close()

    Is = [0.7, 0.75, 0.8, 0.85]
    Is_control = unpickledlist[19]
    spikfreqs_control = mytools.interpolate(Is_control, unpickledlist[0], Is)
    timesc_control = unpickledlist[1]
    Vsomac_control = unpickledlist[2]
    VDerivc_control = unpickledlist[3]
    VDcoeff_control = unpickledlist[4][0]

    counter = -1
    for igene in range(0, len(MT)):
        #for igene in range(0,1):
        theseCoeffsGene = []
        for imut in range(0, len(MT[igene])):
            #for imut in range(0,1):
            theseCoeffsMut = []
            nVals = len(MT[igene][imut]) * [0]
            thesemutvars = []
            for imutvar in range(0, len(MT[igene][imut])):
 "noisy_icell" + str(icell) + "_n" + str(stimN) + "_" + str(stimfreq) +
 "_neckLen" + str(neckLen) + "_neckDiam" + str(neckDiam) + "_Nsyn" +
 str(Nsyn) + "_Ninputs" + str(Ninputs) + dendtree + spinelocations +
 "_Econ" + str(Econ) + '_wNMDA' + str(weight_factor_NMDA) + "_rateE" +
 str(rateE) + "_Npulses" + str(Npulses) + "_ISI" + str(ISIpairing) +
 "_dtpulses" + str(dtpulses) + "_pulseamp" + str(pulseamp) + "_seed" +
 str(rdSeed) + ".mat", {
     'tstart_samp':
     tstart_samp,
     'dt_samp':
     dt_samp,
     'Nsamp':
     Nsamp,
     'DATA': [
         mytools.interpolate(
             array(h.time), array(h.iNMDAs_stim[isyn]),
             [tstart_samp + i * dt_samp for i in range(0, Nsamp)])
         for isyn in range(0, len(h.iNMDAs_stim))
     ],
     'stimdistances':
     stimdistances,
     'stimcomps':
     stimcomps,
     'stimsecs':
     stimsecs,
     'stimxs':
     stimxs,
     'vsoma':
     array(h.voltage),
     'times':
     array(h.time)
Пример #6
0
  for ifile in range(0,len(filenames_nrn)):
    filename_nrn = filenames_nrn[ifile]
    assert exists(filename_nrn), filename_nrn+' does not exist'
    DATANRNs.append(scipy.io.loadmat(filename_nrn))
    print "loaded "+filename_nrn
  mydraw(axarr[4],['PKCt'],DATANRNs,[[],[3,1],[1,3]],['#000000','#808080','#808080']) ############# E ################# (PKCt)
  mydraw(axarr[5],['PKCp'],DATANRNs,[[],[3,1],[1,3]],['#000000','#808080','#808080']) ############# F ################# (PKCp)
  GluR2_S880_tcs = mydraw(axarr[6],['GluR2_S880','GluR2_S880_PP2A','GluR2_memb_S880','GluR2_memb_S880_PP2A'],DATANRNs,[[],[3,1],[1,3]],['#000000','#808080','#808080']) ############# G ################# (GluR2 S880 time course)

########## H ############
if True:
  A = scipy.io.loadmat('cAMP_withdiss_test_tstop22000_tol1e-08_onset800.0_n1_freq1.0_dur16000.0_flux0.64.mat')
  if A['times'].shape[1] == 1:
    A['times'] = A['times'].T
  OBJECTIVE_ts = [1000+1000*i for i in range(0,18)]
  OBJECTIVE_DATA = [mytools.interpolate(A['times'][0],A['tcDATA'][0]+A['tcDATA'][1],OBJECTIVE_ts), #Time course of cAMP                                                                                              
                    mytools.interpolate(A['times'][0],A['tcDATA'][5],OBJECTIVE_ts)] #Time course of PKAc                                                                                         
  ks = [0.4e9, 1.0e9, 1.6e9, 2.2e9, 2.8e9]
  fs = []

  polygon = Polygon(array([[1000,17000,17000,1000],[0,0,100,100]]).T, True)
  p = PatchCollection([polygon], cmap=matplotlib.cm.jet)
  p.set_facecolor('#E0E0E0')
  p.set_edgecolor('none')
  axarr[7].add_collection(p)

  mydashes = [[2,2],[1,3],[1,1],[1,3,2,2],[3,1]]
  for ik in range(0,len(ks)):
    unpicklefile = open('run_cAMP_withdiss_flux0.64_k'+str(ks[ik])+'_data.sav','r')
    unpickledlist = pickle.load(unpicklefile)
    unpicklefile.close()