Weka classifier java.lang.NegativeArraySizeException

weka
imagej
trainable-weka

#1

Hi there,

I used Weka trainable 3D segmentation to classify whole body computed tomography images.
I made a classifier to segment 5 different tissue in the images and then give this classifier to other user who will just have to apply it to get the final result.

However for a dataset of images I got this error multiple time :

java.lang.NegativeArraySizeException
	ij.process.StackProcessor.createKernelEllipsoid(StackProcessor.java:224)
	ij.process.StackProcessor.filter3D(StackProcessor.java:277)
	ij.plugin.Filters3D$1.run(Filters3D.java:109)
	at ij.process.StackProcessor.createKernelEllipsoid(StackProcessor.java:224)
	at ij.process.StackProcessor.filter3D(StackProcessor.java:277)
	at ij.plugin.Filters3D$1.run(Filters3D.java:109)

And at the end I got a stack result with no segmentation at all (all voxel value = 79255130).

I do not see what is different with this image compared to working images. CT are 16 bit image with value from -1024 to +1024.

To reproduce the problem here a link to the files (classifier and Dicom CT) : https://we.tl/3A9QZxXryf
(The CT stack is huge, I split it to small stacks of 10 images before calculation to not run out memory)

Maybe it is a bug in Weka plugin?

Thanks for your help and thanks to Weka team for their amazing job.

Best regards,

Salim.


#2

Hello @Salim_Kanoun,

Could it be that you selected a 2D image after clicking in the Apply classifier button? That would explain the error.

I will try to prevent that error with a message if the plugin is working in 3D and the user selects a 2D image. Sorry about that!

ignacio


#3

Dear @iarganda,

No I give it a real stack not a single image.
It give me a stack result of the segmentation which contain the same stack length but with an unique voxel value


#4

That’s strange because it works for me using your classifier and image, but I get your same exception if I select a 2D slice only. Can you please tell me step by step what you did?


#5

Dear @iarganda,

Thanks for your help I think I started to have an idea about what is going on.

Until now I always use the “Read From CD” plugin coming for the PET/CT update site (http://petctviewer.org)

When I open the image manually by drag and drop I do not have any bugs.
The bug occurs when I load the dicom using Read From CD.

I looked at the stack proprieties and found this difference :

When loaded manually :
Width: 700.0003 mm (512)
Height: 700.0003 mm (512)
Depth: 1882.5543 mm (737)

When loaded from Read From CD :
Width: 700.0003 mm (512)
Height: 700.0003 mm (512)
Depth: -1842.5 mm (737)

This negative value in depth could be the origin of the problem in weka trainable segmentation ?

Best regards,

Salim


#6

Yes, that could be the problem because the spatial resolution is taken into account for the filter shapes. Can you try by manually fixing that value?


#7

Dear @iarganda,

I corrected the image property where I found a negative voxel depth and then it worked with trainable segmentation.

I’m sorry to make you loose time on this bug that was on my side but you really did help me to identify the problem.

By the way, I think you are one of the Weka maintainer, you might be interessted to add our publication in your list, in this paper we used Weka Trainable segmentation to identify bone component in CT : https://www.ncbi.nlm.nih.gov/pubmed/29790867 / https://insights.ovid.com/pubmed?pmid=29790867

I shipped your segmentation tool in a dead-easy GUI to help physicians to reproduce our result and benefit for your tool and our classifier in one click call : https://github.com/salimkanoun/CT_Segmentation/blob/master/Segmentation%20Manual2.pdf

Best regards,

Salim