private static void displayForBrian(Izhikevich9pModelMC model, int idx) { String forBrian = ""; forBrian = "\n\nk" + idx + "=" + model.getK()[idx] + "/ms/mV\na" + idx + "=" + model.getA()[idx] + "\nb" + idx + "=" + model.getB()[idx] + "\nd" + idx + "=" + model.getD()[idx] + "\nC" + idx + "=" + model.getcM()[idx] + "\nvR" + idx + "=" + model.getvR()[idx] + "*mV\nvT" + idx + "=" + model.getvT()[idx] + "*mV\nvPeak" + idx + "=" + model.getvPeak()[idx] + "*mV\nc" + idx + "=" + model.getvMin()[idx] + "*mV"; System.out.println(forBrian); }
private static void runWithUserParmValues() { Izhikevich9pModelMC model = getRightInstanceForModel(); double k0, k1, k2; double a0, a1, a2; double b0, b1, b2; double d0, d1, d2; double C0, C1, C2; double vR0; double vT0, vT1, vT2; double vPeak0, vPeak1, vPeak2; double c0, c1, c2; double Gt_1, P_1, Gt_2, P_2; double[] newCurrents = new double[] {408}; // , currents[1]}; k0 = 1.029252f; a0 = 0.0015812784f; b0 = 2.3435593f; d0 = 3.0f; C0 = 85.0f; vR0 = -60.772045f; vT0 = -30.712957f; vPeak0 = 19.3511f; c0 = -53.59736f; model.setK(getDouble1dArray(k0)); model.setA(getDouble1dArray(a0)); model.setB(getDouble1dArray(b0)); model.setD(getDouble1dArray(d0)); model.setcM(getDouble1dArray(C0)); model.setvR(vR0); model.setvT(getDouble1dArray(vT0)); model.setvMin(getDouble1dArray(c0)); model.setvPeak(getDouble1dArray(vPeak0)); model.setG(getDouble1dArray(0)); model.setP(getDouble1dArray(0)); double[] weights = new double[] {}; ModelEvaluatorMC evaluator = new ModelEvaluatorMC( model, ModelEvaluatorWrapper.INPUT_SPIKE_PATTERN_CONS, ModelEvaluatorWrapper.INPUT_PHENOTYPE_CONSTRAINT, ModelEvaluatorWrapper.INPUT_PAT_REP_WEIGHTS, ModelEvaluatorWrapper.INPUT_MC_CONS, newCurrents, weights); evaluator.setDisplayAll(true); evaluator.getFitness(); System.out.println("\nSpike Times: "); GeneralUtils.displayArray(evaluator.getModelSomaSpikePatternHolder().getSpikeTimes()); }
public static Izhikevich9pModelMC readModel(String exp, int trial) { File newFile = new File("output/" + exp + "/job." + trial + ".Full"); if (!(newFile).exists()) { System.out.println("file not found! skipping.." + "file: " + newFile.getAbsolutePath()); return null; } double[] parms = ECStatOutputReader.readBestSolution("output/" + exp + "/job." + trial + ".Full", 50); Izhikevich9pModelMC model = getRightInstanceForModel(); EAGenes genes = new EAGenes(parms, iso_comp); model.setK(genes.getK()); model.setA(genes.getA()); model.setB(genes.getB()); model.setD(genes.getD()); model.setcM(genes.getCM()); model.setvR(genes.getVR()); model.setvT(genes.getVT()); model.setvMin(genes.getVMIN()); model.setvPeak(genes.getVPEAK()); model.setG(genes.getG()); model.setP(genes.getP()); double[] I = genes.getI(); // System.out.println(I[0]); model.setInputParameters(new double[] {I[0]}, 0d, 0d); return model; }
private static void runPrimary( double[] parms, String opFolder, boolean displayParms, boolean displayErrors, boolean drawPlots) { Izhikevich9pModelMC model = getRightInstanceForModel(); EAGenes genes = new EAGenes(parms, iso_comp); model.setK(genes.getK()); model.setA(genes.getA()); model.setB(genes.getB()); model.setD(genes.getD()); model.setcM(genes.getCM()); model.setvR(genes.getVR()); model.setvT(genes.getVT()); model.setvMin(genes.getVMIN()); model.setvPeak(genes.getVPEAK()); model.setG(genes.getG()); model.setP(genes.getP()); double[] currents = genes.getI(); // float[] newCurrents = new float[currents.length]; // for(int i=0;i<newCurrents.length;i++) // newCurrents[i] = currents[i]; double[] weights = new double[model.getNCompartments() - 1]; // genes.getW(); for (int wi = 0; wi < weights.length; wi++) { weights[wi] = 1; } ModelEvaluatorMC evaluator = new ModelEvaluatorMC( model, ModelEvaluatorWrapper.INPUT_SPIKE_PATTERN_CONS, ModelEvaluatorWrapper.INPUT_PHENOTYPE_CONSTRAINT, ModelEvaluatorWrapper.INPUT_PAT_REP_WEIGHTS, ModelEvaluatorWrapper.INPUT_MC_CONS, currents, weights); evaluator.setRampRheo(false); if (displayErrors || displayOnlyFitness) { if (displayOnlyFitness) { evaluator.setDisplayAll(false); evaluator.setDisplayOnlyClass(true); } else { evaluator.setDisplayAll(true); } // evaluator.setDisplayForPlotIdx(0); float f = evaluator.getFitness(); if (displayOnlyFitness) { System.out.print("\t" + f + "\t"); } // System.out.println(); // evaluator.get double[] spikeTimes = evaluator.getModelSomaSpikePatternHolder().getSpikeTimes(); spikeTimes = GeneralUtils.roundOff(spikeTimes); // GeneralUtils.displayArray(spikeTimes); } if (displayParms) { for (int idx = 0; idx < model.getNCompartments(); idx++) { displayForBrian(model, idx); } for (int idx = 0; idx < model.getNCompartments() - 1; idx++) { System.out.println("Gt_" + (idx + 1) + "=" + model.getG()[idx] + "/ms"); System.out.println("P_" + (idx + 1) + "=" + model.getP()[idx]); System.out.println("W" + idx + "=" + weights[idx]); } // System.out.println(); GeneralUtils.displayArrayUnformatWithSpace(parms, 1, 3); } if (drawPlots) { // float I = currents[0]; double[][] Is = null; double[] Idurs = null; if (model.getNCompartments() > 1) { Idurs = new double [ModelEvaluatorWrapper.INPUT_SPIKE_PATTERN_CONS.length + 4]; // exc., ir., sp., EPSP int i; for (i = 0; i < ModelEvaluatorWrapper.INPUT_SPIKE_PATTERN_CONS.length; i++) { Idurs[i] = (float) ModelEvaluatorWrapper.INPUT_SPIKE_PATTERN_CONS[i].getCurrentDuration(); } if (!ModelEvaluatorWrapper.ISO_COMPS) { Idurs[i++] = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[0].getAttribute( MCConstraintAttributeID.current_duration); // exc. Idurs[i++] = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[1].getAttribute( MCConstraintAttributeID.current_duration); // ir. Idurs[i++] = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[2].getAttribute( MCConstraintAttributeID.dend_current_duration); // sp. Idurs[i++] = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[3].getAttribute( MCConstraintAttributeID.sim_duration); // epsp. } // *** similarly additional mc currents double[] somaCurrents = new double[currents.length + 4]; double[] dend1Currents = new double[currents.length + 4]; for (i = 0; i < currents.length; i++) { somaCurrents[i] = currents[i]; // somatic scenarios dend1Currents[i] = 0; // no dend current for somatic scenarios } double[] rheoComp = model.getRheoBases(); somaCurrents[i] = rheoComp[0]; // exc. dend1Currents[i++] = rheoComp[1]; // exc. if (!ModelEvaluatorWrapper.ISO_COMPS) { somaCurrents[i] = (double) ModelEvaluatorWrapper.INPUT_MC_CONS[1].getAttribute( MCConstraintAttributeID.current); // ir dend1Currents[i++] = (double) ModelEvaluatorWrapper.INPUT_MC_CONS[1].getAttribute( MCConstraintAttributeID.current); // ir somaCurrents[i] = 0; // indirectly get the I required for single spike prop as below: (have to go // through unnecessary steps?!) float dend_curr_min = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[2].getAttribute( MCConstraintAttributeID.dend_current_min); float dend_curr_max = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[2].getAttribute( MCConstraintAttributeID.dend_current_max); float dend_current_time_min = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[2].getAttribute( MCConstraintAttributeID.dend_current_time_min); float dend_current_duration = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[2].getAttribute( MCConstraintAttributeID.dend_current_duration); float dend_current_step = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[2].getAttribute( MCConstraintAttributeID.dend_current_step); float dend_target_spike_freq = (float) ModelEvaluatorWrapper.INPUT_MC_CONS[2].getAttribute( MCConstraintAttributeID.dend_target_spike_freq); for (int c = 1; c < model.getNCompartments(); c++) { float[] spikeCounts = evaluator .getMcEvalholder() .propagatedSpikeCounts( c, MultiCompConstraintEvaluator.forwardConnectionIdcs[c], dend_curr_min, dend_curr_max, dend_current_time_min, dend_current_duration, dend_current_step, dend_target_spike_freq); dend1Currents[i++] = spikeCounts[2]; // MUST HAVE 2D ARRAY for dend currents for more than 2 comps!!!! } } somaCurrents[i] = 0; // epsp; syn simulation dend1Currents[i++] = 0; // epsp; syn simulation Is = new double[model.getNCompartments()][]; Is[0] = somaCurrents; Is[1] = dend1Currents; } else { Is = new double[1][]; Idurs = new double[ModelEvaluatorWrapper.INPUT_SPIKE_PATTERN_CONS.length]; for (int i = 0; i < ModelEvaluatorWrapper.INPUT_SPIKE_PATTERN_CONS.length; i++) { Idurs[i] = (float) ModelEvaluatorWrapper.INPUT_SPIKE_PATTERN_CONS[i].getCurrentDuration(); } Is[0] = currents; } BrianInvoker invoker = new BrianInvoker(opFolder, Is, Idurs); invoker.setDisplayErrorStream(true); invoker.invoke(model); } }