Few questions on trainable weka segmentation

I have images of tumor sections, and I’m attempting to use trainable weka segmentation to build a model to segment a full image.
Parts of different images are annotated by manual reviewers and stored as xml. The images are 15040 x 18040 size. The approach I’m taking is to construct an image stack, feed it as input to a segmentator, and then use AddExample API to add rois to each slice along with their class.

After reading the docs, I had a few questions on whether I’m doing it right or can be improved.

  1. When should AddClass be called? I see that number of classes by default returned by segmentor.getNumOfClasses() is 2. It remains 2 even after AddExample method has been called with other class ids. My code is something like:
                // construct list of polygonROI from xml for a slice
                segmentator.addExample(annotation_id, polyROIs[j], slice_index);
	            segmentator.setClassLabel(annotation_id, annotation_name);

Should I call AddClass just before this or after this?
Totally I have 16 classes. Not all classes appear in each image. To simplify book keeping can I call AddClass 14 times beforehand?

  1. I’m running out of memory (172GB limit) even on one slice. The stack showed Hessian feature compute. Since the annotations are small (400x400 size), I was expecting it will not have issues but are some features like Hessian processing the full image?

  2. At the moment I am processing just one image i.e. only one slice. I have disabled all features except min,max,median,variance. Yet the script seems to hang for a long time after emitting this line:
    Updating features of slice number 1…
    It eventually finished with this output:
    Feature stack array is now updated (1 slice(s) with 29 features(s), took 799528ms).
    I’m curious as to how it got 29 features since I’ve disabled except for 5.

  3. What is a featurestack - is it rows of feature vectors (that is Instances right)? It has a Show method so I was confused if it is some kind of image or just rows of computed features.

Thank you,
Darshat Shah

Additional question - is it possible to specify non-contiguous class ids? For example I have total 16 classes but at the moment I’m interested only in classification for some of the classes. So in any particular training run, depending on the images included, annotations may only have some of the class ids - e.g. 0,3,4,8. I can set the class label for those ids using segmentator.setClassLabel(annotation_id, annotation_name); but how to get the segmentator to skip class id 1,2,5,6,7? Total classes are 4 in this run.

Hi @iarganda - could you give some insights?