Posted by
Lachlan Whitehead on
Nov 06, 2013; 5:16am
URL: http://imagej.273.s1.nabble.com/image-name-as-a-variable-tp5005464p5005467.html
Hi Ken,
When using the open command you can use the getInfo("image.filename") command to get the file name into a variable.
So something like:
temp = getInfo("image.filename");
/*...
do all your processing
...*/
temp2 = getTitle(); //Assuming your final result is the active window at this point
then you can run the Merge Channels:
run("Merge Channels...", "c1=["+temp2+"] c4=["+temp+"] create keep");
I believe (and I'm happy to be corrected if I've got this wrong) that the significance of the square brackets is to allow there to be whitespace in the filenames. When calling pretty much any operation in imagej the settings are passed using a long text string. Spaces within the string tell the operation to look for the next setting, square brackets prevent that until it has actually reached the end of the current setting.
Hope that makes sense,
-Lachie
----- Original Message -----
From: "Ken George" <
[hidden email]>
To:
[hidden email]
Sent: Wednesday, 6 November, 2013 3:21:06 PM
Subject: image name as a variable
Dear group,
I am calling file using a file open statement. I would like to merge the final result of this file after analysis as an overlay with an 8-bit version of the original.
Because the image name changes with the file that is called, how do I program the merge statement as opposed to the fixed file name that is given when using the macro recorder?
I have tried variable names:
temp=getImageID();
temp2=getImageID();
run("Merge Channels...", "c1=[temp2] c4=temp create keep");
or printing the outputs of these variables to the screen and coding them directly:
run("Merge Channels...", "c1=[-221] c4=-227 create keep");
I looked deeper into this and believe concatenation or something like may be required.
Lastly, what is the significance of the square brackets in the Merge Channels line? I have seen this in other statements.
Thanks in advance.
Ken
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html______________________________________________________________________
The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.
______________________________________________________________________
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html