Posted by
Stein Rørvik on
URL: http://imagej.273.s1.nabble.com/Trailing-slash-in-path-is-sometimes-missing-with-imported-stacks-tp5021100.html
Thank you Wayne for the quick fix of the wrong image title with forward slashes issue!
Here is another issue related to the Image Sequence command:
There are two ways an image sequence folder can be imported in a macro;
either by specifying the path name or by specifying the path to the first file.
The resulting stack is the same.
However, the getDirectory function returns a path name without the trailing slash in the latter case.
getDirectory is also missing the trailing slash if the stack was opened from a path without it.
One would expect the getDirectory function to always include a trailing slash.
Then one can construct a fully qualified filepath using simply dir + name.
I am not sure of this is a Windows only issue or not since I only have Windows PCs.
This behaviour is the same with both real and virtual stacks, and with single forward or double backslashes.
It does not occur if the stack was imported via the GUI.
Here is a macro demonstrating this issue:
Case B is correct, while I think case A and C is incorrect.
print("\\Clear");
run("Close All");
dir = getDirectory("temp");
dir = replace(dir, "\\", "/"); //use forward slashes
//create a sample tiff virtual stack
run("T1 Head (2.4M, 16-bits)");
File.makeDirectory(dir + "t1-head/");
run("Image Sequence... ", "format=TIFF save="+ dir + "t1-head/");
close();
//import the same stack using three different valid syntaxes
print("A:");
run("Image Sequence...", "open=["+ dir + "t1-head] sort");
OutPath = getDirectory("image");
print("OutPath: " + OutPath);
//the path is now missing the trailing slash
print("B:");
run("Image Sequence...", "open=["+ dir + "t1-head/] sort");
OutPath = getDirectory("image");
print("OutPath: " + OutPath);
//the path now has a trailing slash
print("C:");
run("Image Sequence...", "open=["+ dir + "t1-head/t1-head0000.tif] sort");
OutPath = getDirectory("image");
print("OutPath: " + OutPath);
//the path is now missing the trailing slash
I am using daily build ImageJ 1.52f on Windows 7 64-bit.
Stein
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html