.ijm how to add string in a path

Dear all,

I am trying to do a batch processing using an ImageJ Macro (ijm).
Actually I don’t know how to add a float converted to a string into a path or as an argument of a function.
I used the BuiltIn Macro “toString(number)”.

I get the error : “Directory not found: C:\Users\KobeN\Desktop\Binarisation\128_225\1.0”

The third part of my path is not added, that why, the directory is not found.

That’s the code :

for (i = 1.0; i < 227.0; i++) {
	run("Image Sequence...", "open=C:/Users/KobeN/Desktop/Binarisation/128_225/"+toString(i)+"/Vessie_0.png sort");
	run("8-bit");
	run("Invert LUT");
	imageCalculator("Add create stack", toString(i),"f_sans_vessie.tif");
	selectWindow("Result of 1.0");
	saveAs("Tiff", "C:/Users/KobeN/Desktop/Binarisation/128_225/f_"+toString(i)+".tif");
} 

Any suggestions or ideas ?

Thanks for your help !

I think you running variable is interpreted as a file extension in the file path of the saveAs function (the period is often used to extract the filetype).
In the loop use an integer.

So instead1.0 use 1.

for (i = 1.0; i < 227.0; i++) {

to:

for (i = 1; i < 227; i++) {

Actually I find my mistakes.

In line 6 I didn’t increment the “Results of …”

This code works :

for (i = 1; i < 227; i++) {
	run("Image Sequence...", "open=C:/Users/KobeN/Desktop/Binarisation/128_225/"+toString(i,1)+"/Vessie_0.png sort");
	run("8-bit");
	run("Invert LUT");
	imageCalculator("Add create stack", toString(i,1),"f_sans_vessie.tif");
	selectWindow("Result of "+toString(i,1));
	saveAs("Tiff", "C:/Users/KobeN/Desktop/Binarisation/128_225/f_"+toString(i,1)+".tif");
}

Thank’s for your answer !