Program: 149588
Project: 149588
Buggy source:
/** 
 * Perform the PC Analysis <p> Spatial domain results can just be combined to an average curve. <p> Frequency domain results can be fit using the g(r) model.
 */
private void analyse(){
  previous_gr=gr;
  previous_peakDensity=peakDensity;
  previous_spatialDomain=spatialDomain;
  String axisTitle;
  if (spatialDomain) {
    offset=0;
    axisTitle="String_Node_Str";
  }
 else {
    offset=(gr[0][0] == 0) ? 1 : 0;
    axisTitle="String_Node_Str";
  }
  String title=TITLE + "String_Node_Str" + axisTitle;
  Plot plot=PCPALMAnalysis.plotCorrelation(gr,offset,title,axisTitle,spatialDomain,showErrorBars);
  if (spatialDomain) {
    saveCorrelationCurve(gr);
    log("String_Node_Str" + title + "String_Node_Str");
    return;
  }
  log("String_Node_Str");
  log("String_Node_Str",Utils.rounded(peakDensity,4),Utils.rounded(blinkingRate,4));
  createResultsTable();
  peakDensity/=1e6;
  double proteinDensity=peakDensity / blinkingRate;
  ArrayList<double[]> curves=new ArrayList<double[]>();
  double[] parameters=fitRandomModel(gr,PCPALMMolecules.sigmaS,proteinDensity);
  if (parameters != null) {
    log("String_Node_Str",randomModel.getName(),Utils.rounded(peakDensity / parameters[1],4));
    log("String_Node_Str",randomModel.getName());
    plot.setColor(Color.red);
    plot.addPoints(randomModel.getX(),randomModel.value(parameters),Plot.LINE);
    addNonFittedPoints(plot,gr,randomModel,parameters);
    Utils.display(title,plot);
    if (saveCorrelationCurve)     curves.add(extractCurve(gr,randomModel,parameters));
  }
  if (!valid1 || fitClusteredModels) {
    parameters=fitClusteredModel(gr,PCPALMMolecules.sigmaS,proteinDensity);
    if (parameters != null) {
      log("String_Node_Str",clusteredModel.getName(),Utils.rounded(peakDensity / parameters[1],4));
      log("String_Node_Str",clusteredModel.getName());
      plot.setColor(Color.blue);
      plot.addPoints(clusteredModel.getX(),clusteredModel.value(parameters),Plot.LINE);
      addNonFittedPoints(plot,gr,clusteredModel,parameters);
      Utils.display(title,plot);
      if (saveCorrelationCurve)       curves.add(extractCurve(gr,clusteredModel,parameters));
    }
    parameters=fitEmulsionModel(gr,PCPALMMolecules.sigmaS,proteinDensity);
    if (parameters != null) {
      log("String_Node_Str",emulsionModel.getName(),Utils.rounded(peakDensity / parameters[1],4));
      log("String_Node_Str",emulsionModel.getName());
      plot.setColor(Color.magenta);
      plot.addPoints(emulsionModel.getX(),emulsionModel.value(parameters),Plot.LINE);
      addNonFittedPoints(plot,gr,emulsionModel,parameters);
      Utils.display(title,plot);
      if (saveCorrelationCurve)       curves.add(extractCurve(gr,emulsionModel,parameters));
    }
  }
  saveCorrelationCurve(gr,curves.toArray(new double[0][0]));
}

Fixed version (ground truth):
/** 
 * Perform the PC Analysis <p> Spatial domain results can just be combined to an average curve. <p> Frequency domain results can be fit using the g(r) model.
 */
private void analyse(){
  previous_gr=gr;
  previous_peakDensity=peakDensity;
  previous_spatialDomain=spatialDomain;
  String axisTitle;
  if (spatialDomain) {
    offset=0;
    axisTitle="String_Node_Str";
  }
 else {
    offset=(gr[0][0] == 0) ? 1 : 0;
    axisTitle="String_Node_Str";
  }
  String title=TITLE + "String_Node_Str" + axisTitle;
  Plot plot=PCPALMAnalysis.plotCorrelation(gr,offset,title,axisTitle,spatialDomain,showErrorBars);
  if (spatialDomain) {
    saveCorrelationCurve(gr);
    log("String_Node_Str" + title + "String_Node_Str");
    return;
  }
  log("String_Node_Str");
  log("String_Node_Str",Utils.rounded(peakDensity,4),Utils.rounded(blinkingRate,4));
  createResultsTable();
  peakDensity/=1e6;
  double proteinDensity=peakDensity / blinkingRate;
  ArrayList<double[]> curves=new ArrayList<double[]>();
  double[] parameters=fitRandomModel(gr,estimatedPrecision,proteinDensity);
  if (parameters != null) {
    log("String_Node_Str",randomModel.getName(),Utils.rounded(peakDensity / parameters[1],4));
    log("String_Node_Str",randomModel.getName());
    plot.setColor(Color.red);
    plot.addPoints(randomModel.getX(),randomModel.value(parameters),Plot.LINE);
    addNonFittedPoints(plot,gr,randomModel,parameters);
    Utils.display(title,plot);
    if (saveCorrelationCurve)     curves.add(extractCurve(gr,randomModel,parameters));
  }
  if (!valid1 || fitClusteredModels) {
    parameters=fitClusteredModel(gr,estimatedPrecision,proteinDensity);
    if (parameters != null) {
      log("String_Node_Str",clusteredModel.getName(),Utils.rounded(peakDensity / parameters[1],4));
      log("String_Node_Str",clusteredModel.getName());
      plot.setColor(Color.blue);
      plot.addPoints(clusteredModel.getX(),clusteredModel.value(parameters),Plot.LINE);
      addNonFittedPoints(plot,gr,clusteredModel,parameters);
      Utils.display(title,plot);
      if (saveCorrelationCurve)       curves.add(extractCurve(gr,clusteredModel,parameters));
    }
    parameters=fitEmulsionModel(gr,estimatedPrecision,proteinDensity);
    if (parameters != null) {
      log("String_Node_Str",emulsionModel.getName(),Utils.rounded(peakDensity / parameters[1],4));
      log("String_Node_Str",emulsionModel.getName());
      plot.setColor(Color.magenta);
      plot.addPoints(emulsionModel.getX(),emulsionModel.value(parameters),Plot.LINE);
      addNonFittedPoints(plot,gr,emulsionModel,parameters);
      Utils.display(title,plot);
      if (saveCorrelationCurve)       curves.add(extractCurve(gr,emulsionModel,parameters));
    }
  }
  saveCorrelationCurve(gr,curves.toArray(new double[0][0]));
}