These are chat archives for fiji/fiji

21st
Feb 2017
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 13:46
@iarganda I trained a random forest classifier with the weka segmentation plugin. Is there a way of applying the classifier to a whole series of images without loading them into memory all at once? Also, how much effort would it be to port the feature calculation into the imglib2 realm? I have an InstanceView that extends AbstractConvertedRandomAccessible< RealComposite< R >, Instance > and a CompositeInstance that wraps around RealComposite that I can use for predictions using an existing classifier. I do not know, however, how to fill the RandomAccessibleInterval< R > with features that are required for an existing classifier before passing it to my InstanceView.
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:01

@iarganda I am trying to load a trained classifier, what am I doing wrong? Minimum working (or failing) example:

final WekaSegmentation seg = new WekaSegmentation();
final String cp = "/data/hanslovskyp/hk-test/ds-8/2017-02-21-7_40.model";
seg.loadClassifier( cp );

Output (stdout & error):

Field of view: max sigma = 16.0, min sigma = 0.0
Membrane thickness: 1, patch size: 19
Read class name: class 1
Read class name: class 2
Error while adjusting data!
java.lang.NullPointerException
    trainableSegmentation.WekaSegmentation.adjustSegmentationStateToData(WekaSegmentation.java:4141)
    trainableSegmentation.WekaSegmentation.loadClassifier(WekaSegmentation.java:712)
    de.hanslovsky.zspacing.spark.experiments.mask.weka.Dummy.main(Dummy.java:12)

    at trainableSegmentation.WekaSegmentation.adjustSegmentationStateToData(WekaSegmentation.java:4141)
    at trainableSegmentation.WekaSegmentation.loadClassifier(WekaSegmentation.java:712)
    at de.hanslovsky.zspacing.spark.experiments.mask.weka.Dummy.main(Dummy.java:12)
Stefan Helfrich
@stelfrich
Feb 21 2017 15:04
@hanslovsky 3D data?
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:04
No, 2D
Stefan Helfrich
@stelfrich
Feb 21 2017 15:06
Model as well as image to which you want to apply it?
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:08
Yes. I trained the model using the Trainable Weka Segmentation plugin
So that should be 2D, right?
The images to which I want to apply the classifier are 2D as well.
But loading fails already when loading the classifier with the example above.
The exception happens in this.featureStackArray.getEnabledFeatures() and this.featureStackArray is null.
at WekaSegmentation.java:4141
Stefan Helfrich
@stelfrich
Feb 21 2017 15:12
WekaSegmentation() doesn't initialize featureStackArray
Stumbled over that before but never reported that behavior ( :-1: for me)
I switched to using the WekaSegmentation(ImagePlus) constructor
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:16
Cool, thanks for the hint! Will that calculate features that I potentially might not need?
Stefan Helfrich
@stelfrich
Feb 21 2017 15:19
That's actually a good question..
Curtis Rueden
@ctrueden
Feb 21 2017 15:20
@hanslovsky FYI, I haven't really noticed @iarganda very active in Gitter. He is very active on the ImageJ forum though.
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:20
I will use your trick for the short term. Right now I do not care too much about wasted feature computation. I will start a github issue.
Ok,thanks for the hint
Stefan Helfrich
@stelfrich
Feb 21 2017 15:23
@hanslovsky Sounds good! Also a small remark on feature computations: there is some work in Ops happening. Maybe you could ask over in the imagej-ops channel and ping @dietzc
that's dietzc ...
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:23
Great, I'll contact him.
Curtis Rueden
@ctrueden
Feb 21 2017 15:24
@hanslovsky ...on the forum. :wink:
Or GitHub issue, I suppose. But public.
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:24
Yes, will do.
Curtis Rueden
@ctrueden
Feb 21 2017 15:24
Thanks.
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:24
:plus1:
Jan Eglinger
@imagejan
Feb 21 2017 15:26
(@stelfrich do you know you can edit your gitter posts within a short time after posting to fix small errors, like mentioning the wrong person?)
Stefan Helfrich
@stelfrich
Feb 21 2017 15:31
(I know @imagejan. Seems like my fingers were way faster than my brain though)
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:31
I just opened the issue:
fiji/Trainable_Segmentation#35
Ignacio Arganda-Carreras
@iarganda
Feb 21 2017 15:42
Sorry to jump late into the conversation, but yes, the empty constructor needs the training image to be set in order for the rest of methods to work.
@hanslovsky I will check if I can implement a workaround
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:46
@iarganda Cool, thank you. So if I use the ImagePlus constructor or setTrainingImage, will WekaSegmentation compute any features or does this happen only when I call applyClassifier? I would like to avoid redundant or unncessary feature comptuations.
Ignacio Arganda-Carreras
@iarganda
Feb 21 2017 15:47
@hanslovsky only if you call applyClassifier, no worries!
Philipp Hanslovsky
@hanslovsky
Feb 21 2017 15:47
Cool. I will add this part of the question to the github issue so other people can see it as well.
Ignacio Arganda-Carreras
@iarganda
Feb 21 2017 15:49
great, thanks!