Program: 149556
Project: 149556
Buggy source:
/** 
 * @return The traces that have been found using {@link #traceMolecules(double,int)}
 */
public Trace[] getTraces(){
  if (totalTraces == localisations.length) {
    if (filterActivationFrames) {
      ArrayList<Trace> traces=new ArrayList<Trace>();
      for (int index=0; index < totalTraces; index++) {
        PeakResult peakResult=results.getResults().get(localisations[index].id);
        if (!outsideActivationWindow(peakResult.peak))         traces.add(new Trace(peakResult));
      }
      return traces.toArray(new Trace[traces.size()]);
    }
 else {
      Trace[] traces=new Trace[localisations.length];
      for (int index=0; index < traces.length; index++)       traces[index]=new Trace(results.getResults().get(localisations[index].id));
      return traces;
    }
  }
  if (tracker != null)   tracker.progress(0);
  Trace[] traces=new Trace[getTotalTraces()];
  int n=0;
  TreeSet<Integer> processedTraces=new TreeSet<Integer>();
  for (int index=0; index < localisations.length; index++) {
    if (tracker != null && index % 256 == 0)     tracker.progress(index,localisations.length);
    final int traceId=localisations[index].trace;
    if (processedTraces.contains(traceId))     continue;
    processedTraces.add(traceId);
    if (filterActivationFrames && outsideActivationWindow(localisations[index].t))     continue;
    PeakResult peakResult=results.getResults().get(localisations[index].id);
    Trace nextTrace=new Trace(peakResult);
    final int tLimit=maxT[traceId];
    if (tLimit > localisations[index].t) {
      for (int j=index + 1; j < localisations.length; j++) {
        if (localisations[j].t > tLimit) {
          break;
        }
        if (localisations[j].trace == traceId)         nextTrace.add(results.getResults().get(localisations[j].id));
      }
    }
    traces[n++]=nextTrace;
  }
  if (tracker != null)   tracker.progress(1.0);
  return traces;
}

Fixed version (ground truth):
/** 
 * @return The traces that have been found using {@link #traceMolecules(double,int)}
 */
public Trace[] getTraces(){
  if (totalTraces == localisations.length) {
    if (filterActivationFrames) {
      ArrayList<Trace> traces=new ArrayList<Trace>();
      for (int index=0; index < totalTraces; index++) {
        PeakResult peakResult=results.getResults().get(localisations[index].id);
        if (!outsideActivationWindow(peakResult.peak))         traces.add(new Trace(peakResult));
      }
      return traces.toArray(new Trace[traces.size()]);
    }
 else {
      Trace[] traces=new Trace[localisations.length];
      for (int index=0; index < traces.length; index++)       traces[index]=new Trace(results.getResults().get(localisations[index].id));
      return traces;
    }
  }
  if (tracker != null)   tracker.progress(0);
  Trace[] traces=new Trace[getTotalTraces()];
  int n=0;
  TreeSet<Integer> processedTraces=new TreeSet<Integer>();
  for (int index=0; index < localisations.length; index++) {
    if (tracker != null && index % 256 == 0)     tracker.progress(index,localisations.length);
    final int traceId=localisations[index].trace;
    if (processedTraces.contains(traceId))     continue;
    processedTraces.add(traceId);
    if (filterActivationFrames && outsideActivationWindow(localisations[index].t))     continue;
    PeakResult peakResult=results.getResults().get(localisations[index].id);
    Trace nextTrace=new Trace(peakResult);
    nextTrace.setId(traceId);
    final int tLimit=maxT[traceId];
    if (tLimit > localisations[index].t) {
      for (int j=index + 1; j < localisations.length; j++) {
        if (localisations[j].t > tLimit) {
          break;
        }
        if (localisations[j].trace == traceId)         nextTrace.add(results.getResults().get(localisations[j].id));
      }
    }
    traces[n++]=nextTrace;
  }
  if (tracker != null)   tracker.progress(1.0);
  return traces;
}