How to stop Level Set Plugin after x iterations

contours
level-sets
scripting
segmentation
fiji
Tags: #<Tag:0x00007fb8827e5080> #<Tag:0x00007fb8827e4ea0> #<Tag:0x00007fb8827e4c20> #<Tag:0x00007fb8827e4a18> #<Tag:0x00007fb8827e4860>

#1

I’m using Level Set to refine the ROIs I get from the other part of the code. Sometimes LevelSet fails to coverage and keeps executing for a long period of time. I want to identify the occurrence of such scenario midway. This would not only save a lot of execution time but also make the result much better.

        for (int i = 0; i < rm.getCount() ; i++) {
        rm.select(i);
        copy.setRoi(rm.getRoi(i));
        IJ.run(copy, "Level Sets", "method=[Active Contours] use_level_sets grey_value_threshold=1 distance_threshold=0.50 advection=1.0 propagation=1 curvature=1 grayscale=1 convergence=0.0050 region=outside");
    }