0

Finally got my code working except for one if statement that I cannot fix. I am selecting ROIs 3 and 4 in the first step, and then if the "if" statement is satisfied I want to select just the 4th ROI and delete that. For whatever reason it skips the selection of ROI 4 and deletes the already selected 3 and 4. I've tried selectWindow("ROI Manager"); before with no luck. Not really sure what the issue is or how to fix. Thanks!

roiManager("Select", newArray(3,4));
roiManager("Measure");
tempX1=getResult("X", 0);
tempY1=getResult("Y", 0);
tempX2=getResult("X", 1);
tempY2=getResult("Y", 1);
selectWindow("Results");
run("Close");

if (tempX1>(tempX2-2) && tempX1<(tempX2+2) && tempY1>(tempY2-2) && tempY1<(tempY2+2)) {
selectWindow("ROI Manager");
roiManager("Select", 4);
roiManager("Delete");
} 
user3470496
  • 141
  • 7
  • 33
  • Still not sure the issue, but fixed by inserting roiManager("Deselect"); before roiManager("Select", 4); roiManager("Delete"); – user3470496 Oct 08 '15 at 21:27

1 Answers1

0

The roiManager("select", index); command is additive. Since you have already selected indices 3 and 4, selecting 4 again has no effect. Calling roiManager("Deselect"); before roiManager("select", 4); is indeed the correct course of action to get the behavior your desire.

See the roiManager function documentation for further details.

ctrueden
  • 6,751
  • 3
  • 37
  • 69