Close(); function interacting with ROI manager

roi-manager
imagej

#1

Hi All,

image

My script now closes the ROI manager when using the close(); function with a variable inside the parentheses. Minimal example:

run("Blobs (25K)");
imageName = getTitle();
makeLine(50,124,180,126);
roiManager("add");
close(imageName);

And then the following code will work:

run("Blobs (25K)");
imageName = getTitle();
makeLine(50,124,180,126);
roiManager("add");
close();

Odd…

My work around is to use selectWindow(); and run("Close");, but I have no idea why it has just changed.

@Wayne

Best,

Rob


#2

Super weird @7rebor !!!

Same issue with the following code too:

run("Blobs (25K)");
image = getImageID();
makeLine(50,124,180,126);
roiManager("add");
close(image);

So it’s not just the getTitle(); call… perhaps something’s up with that close(*Pattern*); call.

Copied from the Build-in Macro Functions page:

close()
Closes the active image. This function has the advantage of not closing the “Log” or “Results” window when you meant to close the active image. Use run(“Close”) to close non-image windows.

close(pattern)
Closes all image windows whose title matches pattern. Pattern may contain the wildcard characters “" (matches any character sequence) or “?” (matches any single character). For example, close("Histo”) could be used to dispose all histogram windows. The front image remains in front if it still exists. Pattern is not case sensitive. Use close("\Others") to close all except the front image.

eta


#3

Just for the record:

Version 1.51u 13 February 2018 (upgrade)

 1.51u 13 February 2018

Thanks to Norbert Vischer, the close(pattern) macro function closes windows whose title matches ‘pattern’. Non-image windows, like “Roi Manager” have to be specified without wildcards. For text windows, wildcards are allowed if ‘pattern’ ends with “.txt”, “.ijm” etc. Use close(pattern, “keep”) to close only unchanged windows.

Regards

Herbie

EDIT:
https://imagej.nih.gov/ij/notes.html


#5

Thanks Herbie, I thought I’d find it in the update notes, but couldn’t find where the update notes are archived. Could you link to them?

Cheers,

Rob

EDIT: @Herbie + @etarena - sorry, but I don’t understand the last bit of the new description? Do either of you know what it means here by “unchanged windows”. I’ve messed around with it, but can’t figure out what “keep” actually does.

Use close(pattern, “keep”) to close only unchanged windows.


#6

I guess that with “keep” only those images are closed that need not be saved because they were not changed.

HTH

Herbie


#7

This 1.51u regression is fixed in the latest ImageJ daily build (1.51v1).

The close(pattern) macro function was extended in ImageJ 1.51u.

close(pattern)
Closes windows whose title matches ‘pattern’, which
can contain wildcard characters. Non-image
windows like “ROI Manager” have to be specified
without wildcards. For text windows, wildcards
are allowed if pattern ends with “.txt”, “.ijm”, “.js” etc.
Use close(pattern, “keep”) to not close text or
image windows that have changes. The most
recent macro window is never closed.


#8

I just found out that close("\Others") does not work anymore. It does not close any windows. I am using Fiji with Imagej 1.51u, 64-bit.


#9

This bug with the close("\\Others") macro function is fixed in the current version of ImageJ (1.51w). Use the Help>Update ImageJ command to update.


#10

Thanks, Wayne. The update solved the problem.