Program: 22771
Project: 22771
Buggy source:
/** 
 * Load a new image to segment (no GUI)
 * @param newImage new image to segment
 * @return false if error
 */
public boolean loadNewImage(ImagePlus newImage){
  if (Math.max(newImage.getWidth(),newImage.getHeight()) > 1024)   if (!IJ.showMessageWithCancel("String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"))   return false;
  IJ.log("String_Node_Str");
  if (featureStack.isEmpty() || updateFeatures) {
    IJ.log("String_Node_Str");
    featureStack.updateFeaturesMT();
    filterFeatureStackByList();
    updateFeatures=false;
    IJ.log("String_Node_Str");
  }
  Instances data=createTrainingInstances();
  if (null != loadedTrainingData && null != data) {
    data.setClassIndex(data.numAttributes() - 1);
    IJ.log("String_Node_Str");
    for (int i=0; i < loadedTrainingData.numInstances(); i++) {
      data.add(loadedTrainingData.instance(i));
    }
    IJ.log("String_Node_Str");
  }
 else   if (null == data)   data=loadedTrainingData;
  loadedTrainingData=data;
  if (null != loadedTrainingData) {
    Attribute classAttribute=loadedTrainingData.classAttribute();
    Enumeration<String> classValues=classAttribute.enumerateValues();
    loadedClassNames=new ArrayList<String>();
    while (classValues.hasMoreElements()) {
      final String className=classValues.nextElement().trim();
      loadedClassNames.add(className);
    }
    IJ.log("String_Node_Str" + loadedTrainingData.numInstances());
  }
 else   IJ.log("String_Node_Str");
  IJ.log("String_Node_Str");
  for (int i=0; i < numOfClasses; i++) {
    examples[i]=new ArrayList<Roi>();
  }
  IJ.log("String_Node_Str");
  trainingImage.setProcessor("String_Node_Str",newImage.getProcessor().duplicate().convertToByte(true));
  final boolean[] enabledFeatures=featureStack.getEnableFeatures();
  featureStack=new FeatureStack(trainingImage);
  featureStack.setEnableFeatures(enabledFeatures);
  updateFeatures=true;
  updateWholeData=true;
  classifiedImage=null;
  IJ.log("String_Node_Str");
  return true;
}

Fixed version (ground truth):
/** 
 * Load a new image to segment (no GUI)
 * @param newImage new image to segment
 * @return false if error
 */
public boolean loadNewImage(ImagePlus newImage){
  if (Math.max(newImage.getWidth(),newImage.getHeight()) > 1024)   if (!IJ.showMessageWithCancel("String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"))   return false;
  IJ.log("String_Node_Str");
  if (featureStack.isEmpty() || updateFeatures) {
    IJ.log("String_Node_Str");
    featureStack.updateFeaturesMT();
    filterFeatureStackByList();
    updateFeatures=false;
    IJ.log("String_Node_Str");
  }
  Instances data=createTrainingInstances();
  if (null != loadedTrainingData && null != data) {
    data.setClassIndex(data.numAttributes() - 1);
    IJ.log("String_Node_Str");
    for (int i=0; i < loadedTrainingData.numInstances(); i++) {
      data.add(loadedTrainingData.instance(i));
    }
    IJ.log("String_Node_Str");
  }
 else   if (null == data)   data=loadedTrainingData;
  loadedTrainingData=data;
  if (null != loadedTrainingData) {
    Attribute classAttribute=loadedTrainingData.classAttribute();
    Enumeration<String> classValues=classAttribute.enumerateValues();
    loadedClassNames=new ArrayList<String>();
    while (classValues.hasMoreElements()) {
      final String className=classValues.nextElement().trim();
      loadedClassNames.add(className);
    }
    IJ.log("String_Node_Str" + loadedTrainingData.numInstances());
  }
 else   IJ.log("String_Node_Str");
  IJ.log("String_Node_Str");
  for (int i=0; i < numOfClasses; i++) {
    examples[i]=new ArrayList<Roi>();
  }
  IJ.log("String_Node_Str");
  trainingImage.setProcessor("String_Node_Str",newImage.getProcessor().duplicate().convertToByte(true));
  final boolean[] enabledFeatures=featureStack.getEnableFeatures();
  featureStack=new FeatureStack(trainingImage);
  featureStack.setEnableFeatures(enabledFeatures);
  featureStack.setMaximumSigma(this.maximumSigma);
  featureStack.setMinimumSigma(this.minimumSigma);
  featureStack.setMembranePatchSize(this.membranePatchSize);
  featureStack.setMembraneSize(this.membraneThickness);
  updateFeatures=true;
  updateWholeData=true;
  classifiedImage=null;
  IJ.log("String_Node_Str");
  return true;
}