Error in Training Step Using Trainable Weka Segmentation for TEM Image


I am new to Imagej and am looking to analyze ~ 20 .tif TEM images to quantify mitochondria morphology (length, area, number of mitochondria per image).

From what I’ve read, the TWS plugin is appropriate for the type of analysis I’m wanting to carry out but I keep running into issues during the training step.

Any assistance would be greatly appreciated!

These are the errors:

Warning: at least one dimension of the image is larger than 1024 pixels.
Feature stack creation and classifier training might take some time depending on your computer.

Creating feature stack…
Updating features of slice number 1…
Error when updating feature stack.
Feature stack was not updated.
The traning did not finish.

[INFO] Reading available sites from
WARNING: core mtj jar files are not available as resources to this classloader (sun.misc.Launcher$AppClassLoader@764c12b6)
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space

at java.util.concurrent.FutureTask.get(
at trainableSegmentation.FeatureStack.updateFeaturesMT(
at trainableSegmentation.FeatureStack.updateFeaturesMT(
at trainableSegmentation.FeatureStackArray.updateFeaturesMT(
at trainableSegmentation.WekaSegmentation.trainClassifier(
at trainableSegmentation.Weka_Segmentation$

Caused by: java.lang.OutOfMemoryError: Java heap space
at ij.process.FloatProcessor.(
at trainableSegmentation.FeatureStack.calculateHessianOnChannel(
at trainableSegmentation.FeatureStack.calculateHessian(
at trainableSegmentation.FeatureStack.access$2(
at trainableSegmentation.FeatureStack$
at trainableSegmentation.FeatureStack$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

NGLY1_Cell10_image10_19kx.tif (8.7 MB)

Hi @kkwolfe and welcome to the forum!

This means that you are running out of memory.
Fiji has a certain amount of RAM memory that it is allowed to use which may be less than what your computer can provide. Have you already increased that value? If not, click on this menu:
Edit > Options > Memory & Threads. A dialog like this should appear:
Set the “Maximum Memory” to a higher value - for example 80% of your RAM memory.

If that doesn’t solve your issue I’d suggest to have a look at Ilastik. It’s a great standalone tool for image segmentation + intuitive to use. The algorithm method itself (Random Forest) is very similar to Trainable Weka. I have the feeling (but didn’t dig very deep) that it can handle large images better because it does computations lazily.

1 Like

Hi Thank you I will give it a go!