1
votes

I have the following code, which works fine except that when I try to close the ROI Manager and montage at the end I get the error:

There are no images open

I started without specifying the windows, then tried specifying the windows, have tried run("Close"); and just close();. Both the ROI Manager and the montage do close with the current macro, but the message pops up after. What am I doing wrong here?

macro "draw rois [v]"{
  var list="/Volumes/bkonk7/old_OCT/ROI_list.txt";
  pathroot="/Volumes/bkonk7/old_OCT/";
  var pathlist=File.openAsString(list);
  var pathsplit=split(pathlist, "\n");

  for(i=0;i<pathsplit.length;i++){

    var roilist=split(pathsplit[i], ".");
    run("Image Sequence...", "open="+pathroot+roilist[i]+" sort");
    run("Rotate 90 Degrees Right");
    run("RGB Color");
    roiManager("Open", pathroot+pathsplit[i]);
    roicount=roiManager("count");

    for(j=0;j<roicount;j++){
      roiManager("Select", j);
      run("Draw", "slice");
    }

    saveAs("Tiff", pathroot+roilist[i]+"_edit.tif");
    run("Image Sequence...", "open="+pathroot+roilist[i]+" sort");
    run("Rotate 90 Degrees Right");
    run("RGB Color");
    splitname=split(roilist[i],"/");
    run("Combine...", "stack1="+splitname[2]+"_edit.tif stack2="+splitname[2]);
    saveAs("Tiff", pathroot+roilist[i]+"_edit.tif");
    selectWindow("ROI Manager");
    run("Close");
    selectWindow(splitname[2]+"_edit.tif");
    close();
  }    
}
1

1 Answers

0
votes

You can use:

list = getList("image.titles");
if (list.length != 0) {
    close();
}

or the close(pattern) macro function.