Posted by
ctrueden on
Jul 22, 2016; 8:14pm
URL: http://imagej.273.s1.nabble.com/Hard-Code-Folder-Reference-in-Command-Line-tp5016919p5016930.html
Hi,
Yes, you can pass parameter values to scripts using ImageJ2's headless/CLI
scripting mechanism.
See this page for details:
http://imagej.net/Scripting_HeadlessHere is an example parameterized macro:
--snip--
// @File(label="Input directory") input
// @File(label="Output directory") output
// @String(label="File suffix", value=".tif") suffix
processFolder(input);
function processFolder(input) {
list = getFileList(input);
for (i = 0; i < list.length; i++) {
if(File.isDirectory(input + list[i]))
processFolder("" + input + list[i]);
if(endsWith(list[i], suffix))
processFile(input, output, list[i]);
}
}
function processFile(input, output, file) {
// do the processing here by replacing
// the following two lines by your own code
print("Processing: " + input + "/" + file);
print("Saving to: " + output);
}
--snap--
And example invocation from the CLI:
--snip--
/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --ij2 --headless --run
/Users/curtis/Desktop/Process_Folder.ijm
"input='/Users/curtis/data',output='/Users/curtis/outDir',suffix='.tif'"
--snap--
Regards,
Curtis
--
Curtis Rueden
LOCI software architect -
http://loci.wisc.edu/softwareImageJ2 lead, Fiji maintainer -
http://imagej.net/User:RuedenDid you know ImageJ has a forum?
http://forum.imagej.net/On Thu, Jul 21, 2016 at 12:41 PM, burt46 <
[hidden email]> wrote:
> Hi
>
> I have a IJ macro that when it opens it asks me to select the source folder
> where i have a bunch of images that the macro cycles through and processes.
>
> Is there a way to select this folder directly in the command line, such as
> change:
>
> start "C:\Program Files\ImageJ" imagej.exe -macro folderprocess.txt
>
> to something like.
>
> start "C:\Program Files\ImageJ" imagej.exe -macro folderprocess.txt
> "C:\Test1"
>
> I know i can add the folder reference into the macro itself, but this means
> i have to change the macro each time if i change the folder destination.
> Basically, i am trying to automate the call function to the macro via
> commandline as i can dynamically create the "C:\Test1" location reference.
> I
> cant do this within an IJ macro.
>
> Any advice greatly appreciated.
>
>
>
> --
> View this message in context:
>
http://imagej.1557.x6.nabble.com/Hard-Code-Folder-Reference-in-Command-Line-tp5016919.html> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html