nus-yam/ex-repair huggingface dataset:
Program: 149520
Project: 149520
Buggy source:
private static void loadCustomTemplate(String name,String path,String tifPath){
  TemplateSettings.Builder builder=TemplateSettings.newBuilder();
  File file=new File(path);
  if (SettingsManager.fromJSON(file,builder,0)) {
    addTemplate(name,builder.build(),TemplateType.CUSTOM,file,tifPath);
  }
}

Fixed version (ground truth):
private static void loadCustomTemplate(String name,String path,String tifPath){
  if (TextUtils.isNullOrEmpty(path))   return;
  TemplateSettings.Builder builder=TemplateSettings.newBuilder();
  File file=new File(path);
  if (SettingsManager.fromJSON(file,builder,0)) {
    addTemplate(name,builder.build(),TemplateType.CUSTOM,file,tifPath);
  }
}
Program: 149521
Project: 149521
Buggy source:
/** 
 * Save template configuration. If an existing template exists with the same name it will be over-written. If an existing template was loaded from file it will be saved back to the same file, or optionally a new file.
 * @param name The name of the template
 * @param settings The template settings
 * @param file The file to save the template (over-riding the file the template was loaded from)
 * @return true, if successful
 */
public static boolean saveTemplate(String name,TemplateSettings settings,File file){
  Template template=map.get(name);
  if (template != null) {
    if (file == null)     file=template.file;
  }
  template=new Template(settings,TemplateType.CUSTOM,file,null);
  boolean result=true;
  if (file != null)   result=template.save(file);
  if (result) {
    map.put(name,template);
    saveLoadedTemplates();
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Save template configuration. If an existing template exists with the same name it will be over-written. If an existing template was loaded from file it will be saved back to the same file, or optionally a new file.
 * @param name The name of the template
 * @param settings The template settings
 * @param file The file to save the template (over-riding the file the template was loaded from)
 * @return true, if successful
 */
public static boolean saveTemplate(String name,TemplateSettings settings,File file){
  Template template=map.get(name);
  if (template != null) {
    if (file == null)     file=template.file;
  }
  template=new Template(settings,TemplateType.CUSTOM,file,null);
  boolean result=true;
  if (file != null)   result=template.save(file);
  if (result) {
    map.put(name,template);
    if (file != null)     saveLoadedTemplates();
  }
  return result;
}
Program: 149522
Project: 149522
Buggy source:
private void checkLoaded(String test,TemplateResource[] templates,String[] before,String[] after){
  HashSet<String> set=new HashSet<String>(Arrays.asList(after));
  set.removeAll(Arrays.asList(before));
  Assert.assertEquals("String_Node_Str",templates.length,set.size());
  for (  TemplateResource template : templates) {
    if (set.contains(template.name)) {
      System.out.println(test + "String_Node_Str" + template);
      continue;
    }
    Assert.assertTrue(test + "String_Node_Str" + template,false);
  }
}

Fixed version (ground truth):
private void checkLoaded(String test,TemplateResource[] templates,String[] before,String[] after){
  HashSet<String> set=new HashSet<String>(Arrays.asList(after));
  set.removeAll(Arrays.asList(before));
  Assert.assertEquals("String_Node_Str",templates.length,set.size());
  for (  TemplateResource template : templates) {
    if (set.contains(template.name)) {
      TestSettings.info(test + "String_Node_Str" + template);
      continue;
    }
    Assert.assertTrue(test + "String_Node_Str" + template,false);
  }
}
Program: 149523
Project: 149523
Buggy source:
private void canTestDoubleError(BaseTestLog f,double[] d,double[] logD){
  DPair pair=new DPair();
  if (!next(f,pair,d))   return;
  double v=logD[pair.i - 1];
  double delta=v - pair.f;
  delta=Math.abs(delta);
  Stats s1=new Stats(delta,d[pair.i - 1]);
  Stats s2=new Stats(Math.abs(delta / v),d[pair.i - 1]);
  while (next(f,pair,d)) {
    v=logD[pair.i - 1];
    delta=v - pair.f;
    delta=Math.abs(delta);
    s1.add(delta,d[pair.i - 1]);
    s2.add(Math.abs(delta / v),d[pair.i - 1]);
  }
  System.out.printf("String_Node_Str",f.name,f.getN(),s1.n,s1.summary(),s2.summary());
}

Fixed version (ground truth):
private void canTestDoubleError(BaseTestLog f,double[] d,double[] logD){
  DPair pair=new DPair();
  if (!next(f,pair,d))   return;
  double v=logD[pair.i - 1];
  double delta=v - pair.f;
  delta=Math.abs(delta);
  Stats s1=new Stats(delta,d[pair.i - 1]);
  Stats s2=(v != 0) ? new Stats(Math.abs(delta / v),d[pair.i - 1]) : new Stats(0,d[pair.i - 1]);
  while (next(f,pair,d)) {
    v=logD[pair.i - 1];
    delta=v - pair.f;
    delta=Math.abs(delta);
    s1.add(delta,d[pair.i - 1]);
    if (v != 0)     s2.add(Math.abs(delta / v),d[pair.i - 1]);
  }
  System.out.printf("String_Node_Str",f.name,f.getN(),s1.n,s1.summary(),s2.summary());
}
Program: 149524
Project: 149524
Buggy source:
private boolean next(BaseTestLog f,DPair pair,double[] d){
  while (pair.i < d.length) {
    pair.f=f.log(d[pair.i++]);
    if (pair.f != Double.NEGATIVE_INFINITY)     return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean next(BaseTestLog f,DPair pair,double[] d){
  while (pair.i < d.length) {
    double x=d[pair.i++];
    if (x == 0)     continue;
    pair.f=f.log(d[pair.i++]);
    if (pair.f != Double.NEGATIVE_INFINITY)     return true;
  }
  return false;
}
Program: 149525
Project: 149525
Buggy source:
private void canTestFloatError(BaseTestLog f,float[] d,float[] logD){
  FPair pair=new FPair();
  if (!next(f,pair,d))   return;
  float v=logD[pair.i - 1];
  double delta=v - pair.f;
  delta=Math.abs(delta);
  Stats s1=new Stats(delta,d[pair.i - 1]);
  Stats s2=new Stats(Math.abs(delta / v),d[pair.i - 1]);
  while (next(f,pair,d)) {
    v=logD[pair.i - 1];
    delta=v - pair.f;
    delta=Math.abs(delta);
    s1.add(delta,d[pair.i - 1]);
    s2.add(Math.abs(delta / v),d[pair.i - 1]);
  }
  System.out.printf("String_Node_Str",f.name,f.getN(),s1.n,s1.summary(),s2.summary());
}

Fixed version (ground truth):
private void canTestFloatError(BaseTestLog f,float[] d,float[] logD){
  FPair pair=new FPair();
  if (!next(f,pair,d))   return;
  float v=logD[pair.i - 1];
  double delta=v - pair.f;
  delta=Math.abs(delta);
  Stats s1=new Stats(delta,d[pair.i - 1]);
  Stats s2=(v != 0) ? new Stats(Math.abs(delta / v),d[pair.i - 1]) : new Stats(0,d[pair.i - 1]);
  while (next(f,pair,d)) {
    v=logD[pair.i - 1];
    delta=v - pair.f;
    delta=Math.abs(delta);
    s1.add(delta,d[pair.i - 1]);
    if (v != 0)     s2.add(Math.abs(delta / v),d[pair.i - 1]);
  }
  System.out.printf("String_Node_Str",f.name,f.getN(),s1.n,s1.summary(),s2.summary());
}
Program: 149529
Project: 149529
Buggy source:
public boolean accept(File arg0,String arg1){
  return arg0.isFile() && !arg1.toLowerCase().endsWith("String_Node_Str");
}

Fixed version (ground truth):
public boolean accept(File file){
  return file.isFile() && !file.getName().toLowerCase().endsWith("String_Node_Str");
}
Program: 149534
Project: 149534
Buggy source:
private void add(StringBuilder sb,PeakResult result){
  addStandardData(sb,result.getId(),result.getFrame(),result.getEndFrame(),result.origX,result.origY,result.origValue,result.error,result.noise);
  final float[] params=result.params;
  if (isShowDeviations()) {
    final float[] paramsStdDev=result.paramsStdDev;
    if (paramsStdDev != null) {
      for (int i=0; i < converters.length; i++) {
        add(sb,converters[i].convert(params[i]));
        add(sb,converters[i].convert(paramsStdDev[i]));
      }
    }
 else {
      for (int i=0; i < converters.length; i++) {
        add(sb,converters[i].convert(params[i]));
        sb.append("String_Node_Str");
      }
    }
  }
 else {
    for (int i=0; i < converters.length; i++) {
      add(sb,converters[i].convert(params[i]));
      sb.append("String_Node_Str");
    }
  }
  if (canComputePrecision) {
    addResult(sb,(float)calculator.getPrecision(params,result.noise));
  }
  sb.append('\n');
}

Fixed version (ground truth):
private void add(StringBuilder sb,PeakResult result){
  addStandardData(sb,result.getId(),result.getFrame(),result.getEndFrame(),result.origX,result.origY,result.origValue,result.error,result.noise);
  final float[] params=result.params;
  if (isShowDeviations()) {
    final float[] paramsStdDev=result.paramsStdDev;
    if (paramsStdDev != null) {
      for (int i=0; i < converters.length; i++) {
        add(sb,converters[i].convert(params[i]));
        add(sb,converters[i].convert(paramsStdDev[i]));
      }
    }
 else {
      for (int i=0; i < converters.length; i++) {
        add(sb,converters[i].convert(params[i]));
        sb.append("String_Node_Str");
      }
    }
  }
 else {
    for (int i=0; i < converters.length; i++) {
      add(sb,converters[i].convert(params[i]));
    }
  }
  if (canComputePrecision) {
    addResult(sb,(float)calculator.getPrecision(params,result.noise));
  }
  sb.append('\n');
}
Program: 149536
Project: 149536
Buggy source:
/** 
 * @return The header from the results file
 */
public String getHeader(){
  if (header == null) {
    BufferedReader input=null;
    try {
      FileInputStream fis=new FileInputStream(filename);
      input=new BufferedReader(new UnicodeReader(fis,null));
      StringBuffer sb=new StringBuffer();
      String line;
      int count=0;
      while ((line=input.readLine()) != null) {
        count++;
        if (count == 1) {
          if (line.startsWith("String_Node_Str")) {
            sb.append(line).append("String_Node_Str");
            break;
          }
          if (line.contains("String_Node_Str")) {
            sb.append(line).append("String_Node_Str");
            break;
          }
        }
        if (line.length() == 0)         continue;
        if (line.charAt(0) == '#')         sb.append(line).append("String_Node_Str");
 else         break;
      }
      header=sb.toString();
      version=getField("String_Node_Str");
      guessFormat(line);
    }
 catch (    IOException e) {
    }
 finally {
      try {
        if (input != null)         input.close();
      }
 catch (      IOException e) {
      }
    }
  }
  return header;
}

Fixed version (ground truth):
/** 
 * @return The header from the results file
 */
public String getHeader(){
  if (header == null) {
    BufferedReader input=null;
    try {
      FileInputStream fis=new FileInputStream(filename);
      input=new BufferedReader(new UnicodeReader(fis,null));
      StringBuffer sb=new StringBuffer();
      String line;
      int count=0;
      while ((line=input.readLine()) != null) {
        count++;
        if (count == 1) {
          if (line.startsWith("String_Node_Str")) {
            sb.append(line).append("String_Node_Str");
            break;
          }
          if (line.contains(IMAGEJ_TABLE_RESULTS_HEADER)) {
            sb.append(line).append("String_Node_Str");
            break;
          }
        }
        if (line.length() == 0)         continue;
        if (line.charAt(0) == '#')         sb.append(line).append("String_Node_Str");
 else         break;
      }
      header=sb.toString();
      version=getField("String_Node_Str");
      guessFormat(line);
    }
 catch (    IOException e) {
    }
 finally {
      try {
        if (input != null)         input.close();
      }
 catch (      IOException e) {
      }
    }
  }
  return header;
}
Program: 149539
Project: 149539
Buggy source:
/** 
 * Gets the sample.
 * @param nNo the number of samples with no localisations
 * @param nLow the number of samples with low localisations
 * @param nHigh the number of samples with high localisations
 * @return the sample (could be empty if no samples were made)
 */
public ImageStack getSample(int nNo,int nLow,int nHigh){
  ImageStack out=new ImageStack(size,size);
  if (!isValid())   return out;
  list.clearf();
  for (  int i : r.sample(nNo,no.length))   list.add(new long[]{no[i],0});
  for (  int i : r.sample(nLow,lower))   list.add(data[i]);
  for (  int i : r.sample(nHigh,upper))   list.add(data[i + lower]);
  if (list.isEmpty())   return out;
  long[][] sample=list.toArray(new long[list.size()][]);
  Arrays.sort(sample,lc);
  int[] xyz=new int[3];
  Rectangle stackBounds=new Rectangle(stack.getWidth(),stack.getHeight());
  for (  long[] s : sample) {
    getXYZ(s[0],xyz);
    Rectangle target=new Rectangle(xyz[0],xyz[1],size,size);
    target=target.intersection(stackBounds);
    if (target.width == 0 || target.height == 0)     continue;
    int slice=xyz[2];
    ImageProcessor ip=stack.getProcessor(slice);
    float[] pixels=new float[size * size];
    for (int y=0; y < target.height; y++)     for (int x=0, i=y * size, index=target.y * ip.getWidth() + target.x; x < target.width; x++, i++, index++) {
      pixels[i]=ip.getf(index);
    }
    out.addSlice(String.format("String_Node_Str",slice,xyz[0],xyz[1],s[1]),pixels);
  }
  return out;
}

Fixed version (ground truth):
/** 
 * Gets the sample.
 * @param nNo the number of samples with no localisations
 * @param nLow the number of samples with low localisations
 * @param nHigh the number of samples with high localisations
 * @return the sample (could be empty if no samples were made)
 */
public ImageStack getSample(int nNo,int nLow,int nHigh){
  ImageStack out=new ImageStack(size,size);
  if (!isValid())   return out;
  list.clearf();
  for (  int i : r.sample(nNo,no.length))   list.add(new long[]{no[i],0});
  for (  int i : r.sample(nLow,lower))   list.add(data[i]);
  for (  int i : r.sample(nHigh,upper))   list.add(data[i + lower]);
  if (list.isEmpty())   return out;
  long[][] sample=list.toArray(new long[list.size()][]);
  Arrays.sort(sample,lc);
  int[] xyz=new int[3];
  Rectangle stackBounds=new Rectangle(stack.getWidth(),stack.getHeight());
  for (  long[] s : sample) {
    getXYZ(s[0],xyz);
    Rectangle target=new Rectangle(xyz[0],xyz[1],size,size);
    target=target.intersection(stackBounds);
    if (target.width == 0 || target.height == 0)     continue;
    int slice=xyz[2];
    ImageProcessor ip=stack.getProcessor(slice);
    float[] pixels=new float[size * size];
    for (int y=0; y < target.height; y++)     for (int x=0, i=y * size, index=(y + target.y) * ip.getWidth() + target.x; x < target.width; x++, i++, index++) {
      pixels[i]=ip.getf(index);
    }
    out.addSlice(String.format("String_Node_Str",slice,xyz[0],xyz[1],s[1]),pixels);
  }
  return out;
}
Program: 149541
Project: 149541
Buggy source:
@Override public FitResult getMultiFitResult(){
  FitResult result=super.getMultiFitResult();
  if (result == null) {
    result=spotFitter.getResultMulti();
    setMultiFitResult(result);
    fitType.setMulti(true);
  }
  return result;
}

Fixed version (ground truth):
@Override public FitResult getMultiFitResult(){
  FitResult result=super.getMultiFitResult();
  if (result == null) {
    result=spotFitter.getResultMulti();
    setMultiFitResult(result);
    if (result != null)     fitType.setMulti(true);
  }
  return result;
}
Program: 149542
Project: 149542
Buggy source:
public int validate(PreprocessedPeakResult peak){
  final int flags=doValidate(peak);
  if (flags == 0 || log == null)   return 0;
  log.info("String_Node_Str",peak.getCandidateId(),peak.getId(),DirectFilter.getStatusMessage(peak,flags));
  return flags;
}

Fixed version (ground truth):
public int validate(PreprocessedPeakResult peak){
  final int flags=doValidate(peak);
  if (log == null)   return flags;
  if (flags != 0)   log.info("String_Node_Str",peak.getCandidateId(),peak.getX(),peak.getY(),peak.getId(),DirectFilter.getStatusMessage(peak,flags));
  return flags;
}
Program: 149544
Project: 149544
Buggy source:
/** 
 * Updates the configuration for peak fitting. Configures the calculation of residuals, logging and peak validation.
 * @return
 */
private void updateFitConfiguration(FitEngineConfiguration config){
  FitConfiguration fitConfig=config.getFitConfiguration();
  fitConfig.setComputeResiduals(config.getResidualsThreshold() < 1);
  logger=(resultsSettings.logProgress) ? new IJLogger() : null;
  fitConfig.setLog(logger);
  fitConfig.setComputeDeviations(resultsSettings.showDeviations);
  fitConfig.setFitValidation(true);
  fitConfig.setNmPerPixel(calibration.nmPerPixel);
  fitConfig.setGain(calibration.gain);
  fitConfig.setBias(calibration.bias);
  fitConfig.setEmCCD(calibration.emCCD);
}

Fixed version (ground truth):
/** 
 * Updates the configuration for peak fitting. Configures the calculation of residuals, logging and peak validation.
 * @return
 */
private void updateFitConfiguration(FitEngineConfiguration config){
  FitConfiguration fitConfig=config.getFitConfiguration();
  fitConfig.setComputeResiduals(config.getResidualsThreshold() < 1);
  logger=(resultsSettings.logProgress) ? new IJLogger() : null;
  fitConfig.setLog(logger);
  fitConfig.setComputeDeviations(resultsSettings.showDeviations);
  fitConfig.setFitValidation(!fitConfig.isSmartFilter());
  fitConfig.setNmPerPixel(calibration.nmPerPixel);
  fitConfig.setGain(calibration.gain);
  fitConfig.setBias(calibration.bias);
  fitConfig.setEmCCD(calibration.emCCD);
}
Program: 149548
Project: 149548
Buggy source:
/** 
 * The fit result of the specified index in the array of fitted indices. This is only set if the fit was attempted with neighbours.
 * @param n
 * @return
 */
public FitResult getFitResultWithNeighbours(int i){
  return fitResultsWithNeighbours[i];
}

Fixed version (ground truth):
/** 
 * The fit result of the specified index in the array of fitted indices. This is only set if the fit was attempted with neighbours.
 * @param n
 * @return
 */
public FitResult getFitResultWithNeighbours(int n){
  if (fitResultsWithNeighbours != null && n < fitResultsWithNeighbours.length)   return fitResultsWithNeighbours[n];
  return null;
}
Program: 149550
Project: 149550
Buggy source:
/** 
 * Adds a new ROI to the overlay using the coordinates from start to end (non-inclusive)
 * @param x
 * @param y
 * @param slice
 * @param indices
 * @param o
 * @param start
 * @param end
 */
private void appendRoi(float[] x,float[] y,int[] slice,int[] indices,Overlay o,int start,int end){
  int p=end - start;
  float[] x2=new float[p];
  float[] y2=new float[p];
  for (int j=start, ii=0; j < end; j++, ii++) {
    x2[ii]=x[indices[start]];
    y2[ii]=y[indices[start]];
  }
  PointRoi roi=new PointRoi(x2,y2,p);
  roi.setPosition(slice[indices[start]]);
  o.add(roi);
}

Fixed version (ground truth):
/** 
 * Adds a new ROI to the overlay using the coordinates from start to end (non-inclusive)
 * @param x
 * @param y
 * @param slice
 * @param indices
 * @param o
 * @param start
 * @param end
 */
private void appendRoi(float[] x,float[] y,int[] slice,int[] indices,Overlay o,int start,int end){
  int p=end - start;
  float[] x2=new float[p];
  float[] y2=new float[p];
  for (int j=start, ii=0; j < end; j++, ii++) {
    x2[ii]=x[indices[j]];
    y2[ii]=y[indices[j]];
  }
  PointRoi roi=new PointRoi(x2,y2,p);
  roi.setPosition(slice[indices[start]]);
  o.add(roi);
}
Program: 149553
Project: 149553
Buggy source:
public void itemStateChanged(ItemEvent e){
  if (e.getSource() instanceof Choice) {
    Choice choice=(Choice)e.getSource();
    String templateName=choice.getSelectedItem();
    GlobalSettings template=ConfigurationTemplate.getTemplate(templateName);
    if (template != null) {
      boolean custom=ConfigurationTemplate.isCustomTemplate(templateName);
      if (template.isFitEngineConfiguration()) {
        FitEngineConfiguration templateConfig=template.getFitEngineConfiguration().clone();
        if (!custom) {
          FitConfiguration templateFitConfig=templateConfig.getFitConfiguration();
          templateFitConfig.setInitialPeakStdDev0(fitConfig.getInitialPeakStdDev0());
          templateFitConfig.setInitialPeakStdDev1(fitConfig.getInitialPeakStdDev1());
          templateFitConfig.setInitialAngle(fitConfig.getInitialAngle());
          templateFitConfig.setFitFunction(fitConfig.getFitFunction());
        }
        refreshSettings(templateConfig);
      }
      if (template.isCalibration()) {
        refreshSettings(template.getCalibration().clone());
      }
      if (template.isResultsSettings()) {
        refreshSettings(template.getResultsSettings().clone());
      }
    }
  }
 else   if (e.getSource() instanceof Checkbox) {
    Checkbox cb=(Checkbox)e.getSource();
    if (cb.getState()) {
      cb.setState(false);
      PSFCalculator calculator=new PSFCalculator();
      calculatorSettings.pixelPitch=calibration.nmPerPixel / 1000.0;
      calculatorSettings.magnification=1;
      calculatorSettings.beamExpander=1;
      double sd=calculator.calculate(calculatorSettings,true);
      if (sd > 0)       textInitialPeakStdDev0.setText(Double.toString(sd));
    }
  }
}

Fixed version (ground truth):
public void itemStateChanged(ItemEvent e){
  if (e.getSource() instanceof Choice) {
    Choice choice=(Choice)e.getSource();
    String templateName=choice.getSelectedItem();
    GlobalSettings template=ConfigurationTemplate.getTemplate(templateName);
    if (template != null) {
      boolean custom=ConfigurationTemplate.isCustomTemplate(templateName);
      if (template.isFitEngineConfiguration()) {
        FitEngineConfiguration templateConfig=template.getFitEngineConfiguration().clone();
        refreshSettings(templateConfig,custom);
      }
      if (template.isCalibration()) {
        refreshSettings(template.getCalibration().clone());
      }
      if (template.isResultsSettings()) {
        refreshSettings(template.getResultsSettings().clone());
      }
    }
  }
 else   if (e.getSource() instanceof Checkbox) {
    Checkbox cb=(Checkbox)e.getSource();
    if (cb.getState()) {
      cb.setState(false);
      PSFCalculator calculator=new PSFCalculator();
      calculatorSettings.pixelPitch=calibration.nmPerPixel / 1000.0;
      calculatorSettings.magnification=1;
      calculatorSettings.beamExpander=1;
      double sd=calculator.calculate(calculatorSettings,true);
      if (sd > 0)       textInitialPeakStdDev0.setText(Double.toString(sd));
    }
  }
}
Program: 149557
Project: 149557
Buggy source:
private void erase(float[] data,Spot spot){
  if (spot.samplePositions != null) {
    psfModel.eraseSample(data,settings.size,settings.size);
  }
 else {
    psfModel.erase(data,settings.size,settings.size,spot.psf,spot.x0min,spot.x0max,spot.x1min,spot.x1max);
  }
}

Fixed version (ground truth):
private void erase(float[] data,Spot spot){
  if (spot.samplePositions != null) {
    psfModel.eraseSample(data,settings.size,settings.size,spot.samplePositions);
  }
 else {
    psfModel.erase(data,settings.size,settings.size,spot.psf,spot.x0min,spot.x0max,spot.x1min,spot.x1max);
  }
}
Program: 149558
Project: 149558
Buggy source:
/** 
 * Save the filter set to a file prompted from the user
 * @param filterSet
 * @param setNumber
 */
private void saveFilterSet(FilterSet filterSet,int setNumber){
  stopTimer();
  String filename=Utils.getFilename("String_Node_Str" + setNumber,filterSetFilename);
  if (filename != null) {
    filterSetFilename=filename;
    saveFilterSet(filterSet,filename);
  }
  startTimer();
}

Fixed version (ground truth):
/** 
 * Save the filter set to a file prompted from the user
 * @param filterSet
 * @param setNumber
 */
private void saveFilterSet(FilterSet filterSet,int setNumber){
  stopTimer();
  String filename=getFilename("String_Node_Str" + setNumber,filterSetFilename);
  if (filename != null) {
    filterSetFilename=filename;
    saveFilterSet(filterSet,filename);
  }
  startTimer();
}
Program: 149559
Project: 149559
Buggy source:
private static String getFilename(String title,String filename){
  filename=getFilename(title,filename);
  if (filename != null)   filename=Utils.replaceExtension(filename,"String_Node_Str");
  return filename;
}

Fixed version (ground truth):
private static String getFilename(String title,String filename){
  filename=Utils.getFilename(title,filename);
  if (filename != null)   filename=Utils.replaceExtension(filename,"String_Node_Str");
  return filename;
}
Program: 149561
Project: 149561
Buggy source:
/** 
 * Calculate the fitness of the population
 * @param fitnessFunction
 * @return The fittest individual
 */
private Chromosome evaluateFitness(FitnessFunction fitnessFunction){
  Chromosome best=null;
  double max=Double.NEGATIVE_INFINITY;
  ArrayList<Chromosome> subset=new ArrayList<Chromosome>(individuals.size());
  for (  Chromosome c : individuals) {
    final double f=c.getFitness();
    if (f == 0) {
      subset.add(c);
    }
 else     if (max < f) {
      max=f;
      best=c;
    }
  }
  fitnessFunction.initialise(subset);
  for (  Chromosome c : individuals) {
    final double f=fitnessFunction.fitness(c);
    c.setFitness(f);
    if (max < f) {
      max=f;
      best=c;
    }
  }
  fitnessFunction.shutdown();
  return best;
}

Fixed version (ground truth):
/** 
 * Calculate the fitness of the population
 * @param fitnessFunction
 * @return The fittest individual
 */
private Chromosome evaluateFitness(FitnessFunction fitnessFunction){
  if (tracker != null)   tracker.status("String_Node_Str",iteration);
  Chromosome best=null;
  double max=Double.NEGATIVE_INFINITY;
  ArrayList<Chromosome> subset=new ArrayList<Chromosome>(individuals.size());
  long count=0;
  for (  Chromosome c : individuals) {
    final double f=c.getFitness();
    if (f == 0) {
      subset.add(c);
    }
 else {
      if (tracker != null)       tracker.progress(++count,individuals.size());
      if (max < f) {
        max=f;
        best=c;
      }
    }
  }
  fitnessFunction.initialise(subset);
  for (  Chromosome c : subset) {
    final double f=fitnessFunction.fitness(c);
    c.setFitness(f);
    if (max < f) {
      max=f;
      best=c;
    }
    if (tracker != null)     tracker.progress(++count,individuals.size());
  }
  fitnessFunction.shutdown();
  return best;
}
Program: 149562
Project: 149562
Buggy source:
/** 
 * Select a subset of the population
 * @param selection The selection strategy
 */
private void select(SelectionStrategy selection){
  individuals=selection.select(individuals);
  checkSize(individuals.size());
}

Fixed version (ground truth):
/** 
 * Select a subset of the population
 * @param selection The selection strategy
 */
private void select(SelectionStrategy selection){
  if (tracker != null) {
    tracker.status("String_Node_Str",iteration);
  }
  individuals=selection.select(individuals);
  checkSize(individuals.size());
}
Program: 149565
Project: 149565
Buggy source:
/** 
 * Select the top individuals using the configured fraction. The resulting subset will be at least size 2 (unless the input is smaller or there are not enough valid individuals (fitness above zero)).
 * @param individuals
 * @return the subset
 * @see gdsc.smlm.ga.SelectionStrategy#select(java.util.List)
 */
@Override public List<? extends Chromosome> select(List<? extends Chromosome> individuals){
  if (individuals == null || individuals.size() < 2)   return individuals;
  ArrayList<Chromosome> subset=new ArrayList<Chromosome>();
  for (  Chromosome c : individuals)   if (c.getFitness() > 0)   subset.add(c);
  if (subset.size() < 3)   return subset;
  ChromosomeComparator.sort(subset);
  int size=(int)Math.round(subset.size() * fraction);
  if (size < 2)   size=2;
  return subset.subList(0,size);
}

Fixed version (ground truth):
/** 
 * Select the top individuals using the configured fraction. The resulting subset will be at least size 2 (unless the input is smaller or there are not enough valid individuals (fitness above zero)).
 * @param individuals
 * @return the subset
 * @see gdsc.smlm.ga.SelectionStrategy#select(java.util.List)
 */
@Override public List<? extends Chromosome> select(List<? extends Chromosome> individuals){
  if (individuals == null || individuals.size() < 2)   return individuals;
  ArrayList<Chromosome> subset=new ArrayList<Chromosome>();
  for (  Chromosome c : individuals)   if (c.getFitness() > 0)   subset.add(c);
  if (subset.size() < 3)   return subset;
  if (tracker != null)   tracker.progress(0.5);
  ChromosomeComparator.sort(subset);
  int size=(int)Math.round(subset.size() * fraction);
  if (size < 2)   size=2;
  if (tracker != null)   tracker.progress(1);
  return subset.subList(0,size);
}
Program: 149566
Project: 149566
Buggy source:
@Override public void setup(MemoryPeakResults peakResults){
  ok=new HashSet<PeakResult>();
  MemoryPeakResults traceResults=new MemoryPeakResults();
  LinkedList<PeakResult> candidates=new LinkedList<PeakResult>();
  for (  PeakResult result : peakResults.getResults()) {
switch (getStatus(result)) {
case OK:
      ok.add(result);
    traceResults.add(result);
  break;
case CANDIDATE:
candidates.add(result);
traceResults.add(result);
break;
default :
break;
}
}
if (candidates.isEmpty()) {
return;
}
double distanceThreshold;
switch (searchDistanceMode) {
case 1:
distanceThreshold=searchDistance / peakResults.getNmPerPixel();
break;
case 0:
default :
distanceThreshold=getSearchDistanceUsingCandidates(peakResults,candidates);
}
if (distanceThreshold <= 0) return;
int myTimeThreshold;
switch (timeThresholdMode) {
case 1:
if (peakResults.getCalibration() != null) {
myTimeThreshold=(int)Math.round((this.timeThreshold / peakResults.getCalibration().exposureTime));
}
 else myTimeThreshold=1;
break;
case 0:
default :
myTimeThreshold=(int)this.timeThreshold;
}
if (myTimeThreshold <= 0) return;
TraceManager tm=new TraceManager(traceResults);
tm.setTraceMode(TraceMode.LATEST_FORERUNNER);
tm.traceMolecules(distanceThreshold,myTimeThreshold);
Trace[] traces=tm.getTraces();
for (Trace trace : traces) {
if (trace.size() > 1) {
boolean isOk=false;
for (PeakResult result : trace.getPoints()) {
if (ok.contains(result)) {
isOk=true;
break;
}
ok.add(result);
}
if (isOk) {
for (PeakResult result : trace.getPoints()) {
ok.add(result);
}
}
}
}
}

Fixed version (ground truth):
@Override public void setup(MemoryPeakResults peakResults){
  ok=new HashSet<PeakResult>();
  MemoryPeakResults traceResults=new MemoryPeakResults();
  LinkedList<PeakResult> candidates=new LinkedList<PeakResult>();
  for (  PeakResult result : peakResults.getResults()) {
switch (getStatus(result)) {
case OK:
      ok.add(result);
    traceResults.add(result);
  break;
case CANDIDATE:
candidates.add(result);
traceResults.add(result);
break;
default :
break;
}
}
if (candidates.isEmpty()) {
return;
}
double distanceThreshold;
switch (searchDistanceMode) {
case 1:
distanceThreshold=searchDistance / peakResults.getNmPerPixel();
break;
case 0:
default :
distanceThreshold=getSearchDistanceUsingCandidates(peakResults,candidates);
}
if (distanceThreshold <= 0) return;
int myTimeThreshold;
switch (timeThresholdMode) {
case 1:
if (peakResults.getCalibration() != null) {
myTimeThreshold=(int)Math.round((this.timeThreshold / peakResults.getCalibration().exposureTime));
}
 else myTimeThreshold=1;
break;
case 0:
default :
myTimeThreshold=(int)this.timeThreshold;
}
if (myTimeThreshold <= 0) return;
TraceManager tm=new TraceManager(traceResults);
tm.setTraceMode(TraceMode.LATEST_FORERUNNER);
tm.traceMolecules(distanceThreshold,myTimeThreshold);
Trace[] traces=tm.getTraces();
for (Trace trace : traces) {
if (trace.size() > 1) {
boolean isOk=false;
for (PeakResult result : trace.getPoints()) {
if (ok.contains(result)) {
isOk=true;
break;
}
}
if (isOk) {
for (PeakResult result : trace.getPoints()) {
ok.add(result);
}
}
}
}
}
Program: 149567
Project: 149567
Buggy source:
@Override public void setup(MemoryPeakResults peakResults){
  ok=new HashSet<PeakResult>();
  MemoryPeakResults traceResults=new MemoryPeakResults();
  LinkedList<PeakResult> candidates=new LinkedList<PeakResult>();
  for (  PeakResult result : peakResults.getResults()) {
switch (getStatus(result)) {
case OK:
      ok.add(result);
    traceResults.add(result);
  break;
case CANDIDATE:
candidates.add(result);
traceResults.add(result);
break;
default :
break;
}
}
if (candidates.isEmpty()) {
return;
}
double distanceThreshold;
switch (searchDistanceMode) {
case 1:
distanceThreshold=searchDistance / peakResults.getNmPerPixel();
break;
case 0:
default :
distanceThreshold=getSearchDistanceUsingCandidates(peakResults,candidates);
}
if (distanceThreshold <= 0) return;
int timeThreshold;
switch (searchDistanceMode) {
case 1:
if (peakResults.getCalibration() != null) {
timeThreshold=(int)Math.round((this.timeThreshold / peakResults.getCalibration().exposureTime));
}
 else timeThreshold=1;
break;
case 0:
default :
timeThreshold=(int)this.timeThreshold;
}
if (timeThreshold <= 0) return;
TraceManager tm=new TraceManager(traceResults);
tm.setTraceMode(TraceMode.LATEST_FORERUNNER);
tm.traceMolecules(distanceThreshold,timeThreshold);
Trace[] traces=tm.getTraces();
for (Trace trace : traces) {
if (trace.size() > 1) {
boolean isOk=false;
for (PeakResult result : trace.getPoints()) {
if (ok.contains(result)) {
isOk=true;
break;
}
ok.add(result);
}
if (isOk) {
for (PeakResult result : trace.getPoints()) {
ok.add(result);
}
}
}
}
}

Fixed version (ground truth):
@Override public void setup(MemoryPeakResults peakResults){
  ok=new HashSet<PeakResult>();
  MemoryPeakResults traceResults=new MemoryPeakResults();
  LinkedList<PeakResult> candidates=new LinkedList<PeakResult>();
  for (  PeakResult result : peakResults.getResults()) {
switch (getStatus(result)) {
case OK:
      ok.add(result);
    traceResults.add(result);
  break;
case CANDIDATE:
candidates.add(result);
traceResults.add(result);
break;
default :
break;
}
}
if (candidates.isEmpty()) {
return;
}
double distanceThreshold;
switch (searchDistanceMode) {
case 1:
distanceThreshold=searchDistance / peakResults.getNmPerPixel();
break;
case 0:
default :
distanceThreshold=getSearchDistanceUsingCandidates(peakResults,candidates);
}
if (distanceThreshold <= 0) return;
int myTimeThreshold;
switch (timeThresholdMode) {
case 1:
if (peakResults.getCalibration() != null) {
myTimeThreshold=(int)Math.round((this.timeThreshold / peakResults.getCalibration().exposureTime));
}
 else myTimeThreshold=1;
break;
case 0:
default :
myTimeThreshold=(int)this.timeThreshold;
}
if (myTimeThreshold <= 0) return;
TraceManager tm=new TraceManager(traceResults);
tm.setTraceMode(TraceMode.LATEST_FORERUNNER);
tm.traceMolecules(distanceThreshold,myTimeThreshold);
Trace[] traces=tm.getTraces();
for (Trace trace : traces) {
if (trace.size() > 1) {
boolean isOk=false;
for (PeakResult result : trace.getPoints()) {
if (ok.contains(result)) {
isOk=true;
break;
}
ok.add(result);
}
if (isOk) {
for (PeakResult result : trace.getPoints()) {
ok.add(result);
}
}
}
}
}
Program: 149568
Project: 149568
Buggy source:
private void grow(SelectionStrategy selectionStrategy,Mutator mutator,Recombiner recombiner){
  if (individuals.size() >= populationSize)   return;
  selectionStrategy.initialiseBreeding(individuals);
  int fails=0;
  int target=populationSize - individuals.size();
  ArrayList<Chromosome> newIndividuals=new ArrayList<Chromosome>(target);
  while (newIndividuals.size() < target && fails < failureLimit) {
    ChromosomePair pair=selectionStrategy.next();
    Chromosome[] children=recombiner.cross(pair.c1,pair.c2);
    if (children == null || children.length == 0) {
      fails++;
      continue;
    }
    for (int i=0; i < children.length && newIndividuals.size() < target; i++) {
      Chromosome c=mutator.mutate(children[i]);
      if (c == null) {
        fails++;
        continue;
      }
      if (isDuplicate(newIndividuals,c)) {
        fails++;
        continue;
      }
      newIndividuals.add(c);
    }
  }
  selectionStrategy.finishBreeding();
  newIndividuals.addAll(individuals);
  individuals=newIndividuals;
}

Fixed version (ground truth):
private void grow(SelectionStrategy selectionStrategy,Mutator mutator,Recombiner recombiner){
  if (individuals.size() >= populationSize)   return;
  selectionStrategy.initialiseBreeding(individuals);
  int fails=0;
  int target=populationSize - individuals.size();
  ArrayList<Chromosome> newIndividuals=new ArrayList<Chromosome>(target);
  int previousSize=-1;
  while (newIndividuals.size() < target && fails < failureLimit) {
    previousSize=newIndividuals.size();
    ChromosomePair pair=selectionStrategy.next();
    Chromosome[] children=recombiner.cross(pair.c1,pair.c2);
    if (children != null && children.length != 0) {
      for (int i=0; i < children.length && newIndividuals.size() < target; i++) {
        Chromosome c=mutator.mutate(children[i]);
        if (c == null)         continue;
        if (isDuplicate(newIndividuals,c))         continue;
        newIndividuals.add(c);
      }
    }
    if (previousSize == newIndividuals.size())     fails++;
 else     fails=0;
  }
  selectionStrategy.finishBreeding();
  newIndividuals.addAll(individuals);
  individuals=newIndividuals;
}
Program: 149569
Project: 149569
Buggy source:
/** 
 * Mutates the chromosome to form a new sequence. <p> The number of positions are chosen from a Poisson distribution with an average using a fraction of the total positions. The positions are then chosen randomly. Note that the same position may be chosen multiple times. The random shifts for each mutation are taken from a Gaussian using the chromosome mutation step range as the standard deviation.
 * @see gdsc.smlm.ga.Mutator#mutate(gdsc.smlm.ga.Chromosome)
 */
@Override public Chromosome mutate(Chromosome chromosome){
  final double[] sequence=chromosome.sequence().clone();
  final double mean=fraction * chromosome.length();
  if (mean > 0) {
    int count=(int)random.nextPoisson(mean);
    final double[] step, min, max;
    if (override) {
      step=stepSize;
      min=lower;
      max=upper;
    }
 else {
      step=chromosome.mutationStepRange();
      min=chromosome.lowerLimit();
      max=chromosome.upperLimit();
    }
    while (count-- > 0) {
      int i=random.nextInt(0,chromosome.length());
      sequence[i]=random.nextGaussian(sequence[i],step[i]);
      if (min != null) {
        if (sequence[i] < min[i])         sequence[i]=min[i];
      }
      if (max != null) {
        if (sequence[i] > max[i])         sequence[i]=max[i];
      }
    }
  }
  return chromosome.newChromosome(sequence);
}

Fixed version (ground truth):
/** 
 * Mutates the chromosome to form a new sequence. <p> The number of positions are chosen from a Poisson distribution with an average using a fraction of the total positions. The positions are then chosen randomly. Note that the same position may be chosen multiple times. The random shifts for each mutation are taken from a Gaussian using the chromosome mutation step range as the standard deviation.
 * @see gdsc.smlm.ga.Mutator#mutate(gdsc.smlm.ga.Chromosome)
 */
@Override public Chromosome mutate(Chromosome chromosome){
  final double[] sequence=chromosome.sequence().clone();
  final double mean=fraction * chromosome.length();
  if (mean > 0) {
    int count=(int)random.nextPoisson(mean);
    final double[] step, min, max;
    if (override) {
      step=stepSize;
      min=lower;
      max=upper;
    }
 else {
      step=chromosome.mutationStepRange();
      min=chromosome.lowerLimit();
      max=chromosome.upperLimit();
    }
    final int upper=chromosome.length() - 1;
    while (count-- > 0) {
      int i=random.nextInt(0,upper);
      sequence[i]=random.nextGaussian(sequence[i],step[i]);
      if (min != null) {
        if (sequence[i] < min[i])         sequence[i]=min[i];
      }
      if (max != null) {
        if (sequence[i] > max[i])         sequence[i]=max[i];
      }
    }
  }
  return chromosome.newChromosome(sequence);
}
Program: 149570
Project: 149570
Buggy source:
/** 
 * Select pairs randomly from the population
 * @see gdsc.smlm.ga.SelectionStrategy#next()
 */
@Override public ChromosomePair next(){
  if (individuals == null)   return null;
  int first, second;
  if (individuals.size() == 2) {
    first=0;
    second=1;
  }
 else {
    first=random.nextInt(0,individuals.size());
    second=random.nextInt(0,individuals.size());
    while (second != first)     second=random.nextInt(0,individuals.size());
  }
  return new ChromosomePair(individuals.get(first),individuals.get(second));
}

Fixed version (ground truth):
/** 
 * Select pairs randomly from the population
 * @see gdsc.smlm.ga.SelectionStrategy#next()
 */
@Override public ChromosomePair next(){
  if (individuals == null)   return null;
  int first, second;
  if (individuals.size() == 2) {
    first=0;
    second=1;
  }
 else {
    final int upper=individuals.size() - 1;
    first=random.nextInt(0,upper);
    second=random.nextInt(0,upper);
    while (second == first)     second=random.nextInt(0,upper);
  }
  return new ChromosomePair(individuals.get(first),individuals.get(second));
}
Program: 149572
Project: 149572
Buggy source:
@Override public double fitness(Chromosome chromosome){
  Filter filter=(Filter)chromosome;
  FractionClassificationResult r;
  if (ga_subset)   r=filter.fractionScoreSubset(ga_resultsListToScore,failCount,ga_tn,ga_fn);
 else   r=scoreFilter(filter,ga_resultsListToScore);
  double score=getScore(r);
  final double criteria=getCriteria(r);
  if (criteria >= minCriteria)   score+=1;
  return score;
}

Fixed version (ground truth):
@Override public double fitness(Chromosome chromosome){
  if (ga_count++ % 16 == 0) {
    IJ.showProgress(ga_count,ga_total);
  }
  Filter filter=(Filter)chromosome;
  FractionClassificationResult r;
  if (ga_subset)   r=filter.fractionScoreSubset(ga_resultsListToScore,failCount,ga_tn,ga_fn);
 else   r=scoreFilter(filter,ga_resultsListToScore);
  double score=getScore(r);
  final double criteria=getCriteria(r);
  if (criteria >= minCriteria)   score+=1;
  return score;
}
Program: 149573
Project: 149573
Buggy source:
private void updateGAStatus(){
  IJ.showStatus(ga_statusPrefix + ga_checker.getIterations());
}

Fixed version (ground truth):
private void updateGAStatus(){
  IJ.showStatus(ga_statusPrefix + ga_iteration);
}
Program: 149574
Project: 149574
Buggy source:
@Override public void shutdown(){
  List<? extends Chromosome> individuals=ga_population.getIndividuals();
  ChromosomeComparator.sort(individuals);
  Filter filter=(Filter)individuals.get(0);
  FractionClassificationResult r;
  if (ga_subset)   r=filter.fractionScoreSubset(ga_resultsListToScore,failCount,ga_tn,ga_fn);
 else   r=scoreFilter(filter,ga_resultsListToScore);
  String text=createResult(filter,r);
  gaWindow.append(text + "String_Node_Str" + ga_checker.getIterations());
}

Fixed version (ground truth):
@Override public void shutdown(){
  List<? extends Chromosome> individuals=ga_population.getIndividuals();
  ChromosomeComparator.sort(individuals);
  Filter filter=(Filter)individuals.get(0);
  FractionClassificationResult r;
  if (ga_subset)   r=filter.fractionScoreSubset(ga_resultsListToScore,failCount,ga_tn,ga_fn);
 else   r=scoreFilter(filter,ga_resultsListToScore);
  String text=createResult(filter,r);
  gaWindow.append(text + "String_Node_Str" + ga_iteration);
}
Program: 149575
Project: 149575
Buggy source:
@Override public void initialise(List<? extends Chromosome> individuals){
  updateGAStatus();
  initialiseScoring(new FilterSet(populationToFilters(individuals)));
}

Fixed version (ground truth):
@Override public void initialise(List<? extends Chromosome> individuals){
  ga_count=0;
  ga_total=individuals.size();
  ga_iteration++;
  updateGAStatus();
  initialiseScoring(new FilterSet(populationToFilters(individuals)));
}
Program: 149576
Project: 149576
Buggy source:
@Override public boolean converged(Chromosome previous,Chromosome current){
  if (IJ.escapePressed()) {
    Utils.log("String_Node_Str" + ga_statusPrefix);
    IJ.resetEscape();
  }
  return super.converged(previous,current);
}

Fixed version (ground truth):
@Override public boolean converged(Chromosome previous,Chromosome current){
  if (super.converged(previous,current))   count++;
 else   count=0;
  if (convergedCount >= 0 && count > convergedCount)   return true;
  if (IJ.escapePressed()) {
    Utils.log("String_Node_Str" + ga_statusPrefix);
    IJ.resetEscape();
    return true;
  }
  return false;
}
Program: 149577
Project: 149577
Buggy source:
public InterruptChecker(double relative,double absolute){
  super(relative,absolute);
}

Fixed version (ground truth):
public InterruptChecker(double relative,double absolute,int convergedCount){
  super(relative,absolute);
  this.convergedCount=convergedCount;
}
Program: 149578
Project: 149578
Buggy source:
/** 
 * Trace localisations
 * @param results The results
 * @param distance The distance threshold (nm)
 * @param time The time threshold (frames)
 * @param singles a list of the singles (not grouped into molecules)
 * @return a list of molecules
 */
private ArrayList<Molecule> traceMolecules(MemoryPeakResults results,double distance,int time,ArrayList<Molecule> singles){
  TraceManager tm=new TraceManager(results);
  double distanceThreshold=distance / results.getNmPerPixel();
  tm.traceMolecules(distanceThreshold,time);
  Trace[] traces=tm.getTraces();
  ArrayList<Molecule> molecules=new ArrayList<Molecule>(traces.length);
  final double nmPerPixel=results.getNmPerPixel();
  final double gain=results.getGain();
  final boolean emCCD=results.isEMCCD();
  for (  Trace t : traces) {
    double p=t.getLocalisationPrecision(nmPerPixel,gain,emCCD);
    if (t.size() == 1) {
      float[] centroid=t.getCentroid();
      singles.add(new Molecule(centroid[0] * nmPerPixel,centroid[1] * nmPerPixel,p,t.getSignal() / gain));
    }
 else {
      float[] centroid=t.getCentroid();
      molecules.add(new Molecule(centroid[0] * nmPerPixel,centroid[1] * nmPerPixel,p,t.getSignal() / gain));
    }
  }
  log("String_Node_Str",results.size(),molecules.size(),singles.size(),molecules.size() - singles.size(),distance,time,Utils.rounded(time * results.getCalibration().exposureTime / 1000.0));
  return molecules;
}

Fixed version (ground truth):
/** 
 * Trace localisations
 * @param results The results
 * @param distance The distance threshold (nm)
 * @param time The time threshold (frames)
 * @param singles a list of the singles (not grouped into molecules)
 * @return a list of molecules
 */
private ArrayList<Molecule> traceMolecules(MemoryPeakResults results,double distance,int time,ArrayList<Molecule> singles){
  TraceManager tm=new TraceManager(results);
  double distanceThreshold=distance / results.getNmPerPixel();
  tm.traceMolecules(distanceThreshold,time);
  Trace[] traces=tm.getTraces();
  ArrayList<Molecule> molecules=new ArrayList<Molecule>(traces.length);
  final double nmPerPixel=results.getNmPerPixel();
  final double gain=results.getGain();
  final boolean emCCD=results.isEMCCD();
  for (  Trace t : traces) {
    double p=t.getLocalisationPrecision(nmPerPixel,gain,emCCD);
    if (t.size() == 1) {
      float[] centroid=t.getCentroid();
      singles.add(new Molecule(centroid[0] * nmPerPixel,centroid[1] * nmPerPixel,p,t.getSignal() / gain));
    }
 else {
      float[] centroid=t.getCentroid();
      molecules.add(new Molecule(centroid[0] * nmPerPixel,centroid[1] * nmPerPixel,p,t.getSignal() / gain));
    }
  }
  log("String_Node_Str",results.size(),molecules.size() + singles.size(),singles.size(),molecules.size(),distance,time,Utils.rounded(time * results.getCalibration().exposureTime / 1000.0));
  return molecules;
}
Program: 149579
Project: 149579
Buggy source:
public Worker(BlockingQueue<Integer> jobs,ImageStack stack,HashMap<Integer,ArrayList<Coordinate>> actualCoordinates,HashMap<Integer,FilterCandidates> filterCandidates){
  this.jobs=jobs;
  this.stack=stack;
  this.fitWorker=new FitWorker((FitEngineConfiguration)config.clone(),new NullPeakResults(),null);
  this.actualCoordinates=actualCoordinates;
  this.filterCandidates=filterCandidates;
  this.results=new HashMap<Integer,FilterCandidates>();
  bounds=new Rectangle(0,0,stack.getWidth(),stack.getHeight());
}

Fixed version (ground truth):
public Worker(BlockingQueue<Integer> jobs,ImageStack stack,HashMap<Integer,ArrayList<Coordinate>> actualCoordinates,HashMap<Integer,FilterCandidates> filterCandidates){
  this.jobs=jobs;
  this.stack=stack;
  this.fitWorker=new FitWorker((FitEngineConfiguration)(config.clone()),new NullPeakResults(),null);
  final int fitting=config.getRelativeFitting();
  fitWorker.setSearchParameters(spotFilter,fitting);
  this.actualCoordinates=actualCoordinates;
  this.filterCandidates=filterCandidates;
  this.results=new HashMap<Integer,FilterCandidates>();
  bounds=new Rectangle(0,0,stack.getWidth(),stack.getHeight());
}