|
Is there any way to do the following?
setBatchMode(true);
// Get ROI's
roiManager("Open", dirColocalizedNuclei + wellName + ".zip");
// Delete all the ROI's that we are not interested in
for(k = dapiCount - 1; k >= 0; k--)
{
if(k != j)
{
roiManager("Select", k);
roiManager("Delete");
}
}
setBatchMode("exit & display");
roiManager("Select", 0);
The problem is that I need to run this chunk of code in batch mode and then get out of batch mode, so I can run the hack that Wayne gave in an earlier post on imageJ. Sounds feasible, right?
The problem is that taking the roiManager out of batch mode apparently deletes all of the ROI's in the roiManager or creates a separate instance. In other words, the above code will work fine if the whole thing is run out of batch mode, but then gives an index out of range error when I try to run it in batch mode.
Wayne's hack:
script =
"manager = RoiManager.getInstance();\n" +
"rois = manager.getRoisAsArray();\n" +
"roi1 = new ShapeRoi(rois[" + 0 + "]);\n" +
"roi2 = new ShapeRoi(rois[" + k + "]);\n" +
"combined = roi1.and(roi2);\n" +
"if (combined.getLength() != 0)\n" +
"manager.addRoi(combined);\n";
eval("script", script);
|