how do you implement in Jython the “Selection->Clear…” command?
I have a long list of ROIs in a quite big multiple z multiple times acquisition I want to clear inside each of the ROIs without showing the image in order to be faster.
By now I have implemented a simple:
rm = RoiManager.getInstance() imp.show() for i in range(0,rm.getCount()): rm.select(i) IJ.run(imp, "Clear", "slice"); rm.runCommand(imp,"Deselect");
It of course works but I cannot use it without imp.show() and that it’s really time consuming.
For this reason, I searched for the API of the Clear Function and I think that it is this one:
I implemented this code:
FIL = Filler(); for roi in rm.getRoisAsArray(): imp.setZ(roi.getZPosition()) imp.setC(roi.getCPosition()) imp.setT(roi.getTPosition()) imp.setRoi(roi) ip = imp.getProcessor(); FIL.clear(ip)
but that way it clears inside the bounding box of the roi and not inside the boundaries of the roi.
What is the correct implementation of Clear command in jython?