示例#1
0
 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;
 }
示例#2
0
 private static void displayForBrian(EAGenes genes, int idx) {
   String forBrian = "";
   forBrian =
       "\n\nk"
           + idx
           + "="
           + genes.getK()[idx]
           + "/ms/mV\na"
           + idx
           + "="
           + genes.getA()[idx]
           + "\nb"
           + idx
           + "="
           + genes.getB()[idx]
           + "\nd"
           + idx
           + "="
           + genes.getD()[idx]
           + "\nC"
           + idx
           + "="
           + genes.getCM()[idx]
           + "\nvR"
           + idx
           + "="
           + genes.getVR()
           + "*mV\nvT"
           + idx
           + "="
           + genes.getVT()[idx]
           + "*mV\nvPeak"
           + idx
           + "="
           + genes.getVPEAK()[idx]
           + "*mV\nc"
           + idx
           + "="
           + genes.getVMIN()[idx]
           + "*mV";
   System.out.println(forBrian);
 }
示例#3
0
  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);
    }
  }