Program: 22736
Project: 22736
Buggy source:
/** 
 * Calculate the pixel error and its derived statistics in 2D between  some original labels and the corresponding proposed labels. Both images  are binarized. 
 * @param binaryThreshold threshold value to binarize proposal (larger than 0 and smaller than 1)
 * @param mask mask image
 * @return pixel error value and derived statistics
 */
public ClassificationStatistics getPrecisionRecallStats(double binaryThreshold,ImagePlus mask){
  final ImageStack labelSlices=originalLabels.getImageStack();
  final ImageStack proposalSlices=proposedLabels.getImageStack();
  double pixelError=0;
  double tp=0;
  double tn=0;
  double fp=0;
  double fn=0;
  final ExecutorService exe=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<ClassificationStatistics>> futures=new ArrayList<Future<ClassificationStatistics>>();
  try {
    for (int i=1; i <= labelSlices.getSize(); i++) {
      futures.add(exe.submit(getPrecisionRecallStatsConcurrent(labelSlices.getProcessor(i).convertToFloat(),proposalSlices.getProcessor(i).convertToFloat(),(null != mask) ? mask.getImageStack().getProcessor(i) : null,binaryThreshold)));
    }
    for (    Future<ClassificationStatistics> f : futures) {
      ClassificationStatistics cs=f.get();
      pixelError+=cs.metricValue;
      tp+=cs.truePositives;
      tn+=cs.trueNegatives;
      fp+=cs.falsePositives;
      fn+=cs.falseNegatives;
    }
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
  }
 finally {
    exe.shutdown();
  }
  return new ClassificationStatistics(tp,tn,fp,fn,pixelError / labelSlices.getSize());
}

Fixed version (ground truth):
/** 
 * Calculate the pixel error and its derived statistics in 2D between  some original labels and the corresponding proposed labels. Both images  are binarized. 
 * @param binaryThreshold threshold value to binarize proposal (larger than 0 and smaller than 1)
 * @param mask mask image
 * @return pixel error value and derived statistics
 */
public ClassificationStatistics getPrecisionRecallStats(double binaryThreshold,ImagePlus mask){
  final ImageStack labelSlices=originalLabels.getImageStack();
  final ImageStack proposalSlices=proposedLabels.getImageStack();
  double pixelError=0;
  double tp=0;
  double tn=0;
  double fp=0;
  double fn=0;
  final ExecutorService exe=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<ClassificationStatistics>> futures=new ArrayList<Future<ClassificationStatistics>>();
  try {
    for (int i=1; i <= labelSlices.getSize(); i++) {
      futures.add(exe.submit(getPrecisionRecallStatsConcurrent(labelSlices.getProcessor(i).convertToFloat(),proposalSlices.getProcessor(i).convertToFloat(),(null != mask) ? mask.getImageStack().getProcessor(i).convertToFloat() : null,binaryThreshold)));
    }
    for (    Future<ClassificationStatistics> f : futures) {
      ClassificationStatistics cs=f.get();
      pixelError+=cs.metricValue;
      tp+=cs.truePositives;
      tn+=cs.trueNegatives;
      fp+=cs.falsePositives;
      fn+=cs.falseNegatives;
    }
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
  }
 finally {
    exe.shutdown();
  }
  return new ClassificationStatistics(tp,tn,fp,fn,pixelError / labelSlices.getSize());
}