Newer
Older
//Batch macro to export avi files from supplied tiff stacks.
// Also prints scale bar and time stamp onto the video.
// Arguments string should be a list of absolute file paths to process.
//This macro can be called in Fiji's headless mode e.g.
// imagej --headless -macro /path-to-macro.ijm /path-to-file.tif
// or by runMacro(macro, arg)
outExtension = ".avi";
barWidth = 2; //µm
barHeight = 4; //px
tUnit = "";
tInterval = 1;
fileList = split(getArgument());
for (i = 0; i < fileList.length; i++) {
//parse file name
dotIndex = lastIndexOf(fileList[i], ".");
if (dotIndex >= 0) {
baseName = substring(fileList[i], 0, dotIndex);
}
outFile = baseName+outExtension;
// escape spaces in path with \ and "" // does not work!
//outFile = "\"" + outFile + "\"";
//outFile = replace(outFile, " ", "\\\\\\\\ ");
if ( indexOf(outFile," ") >= 0 ) {
exit("Input path must no contain whitespace!");
}
//print("will export to "+outFile);
open(fileList[i]);
//processing steps
//frameRate = Stack.getFrameRate();
Stack.getUnits(xUnit, yUnit, zUnit, tUnit, vUnit);
tInterval = Stack.getFrameInterval();
print("frame= "+tInterval+" "+tUnit);
getVoxelSize(x, y, z, u); print("vx size= "+x+"x"+y+"x"+z+" "+u);
run("Scale Bar...", "width="+barWidth+" height="+barHeight+" font=12 color=White background=None location=[Lower Right] bold label");
if (tInterval > 0) {
run("Time Stamper", "starting=0 interval="+tInterval+" x=2 y=15 font=12 decimal=0 anti-aliased or="+tUnit);
print("muh");
}
run("AVI... ", "compression=JPEG frame="+frameRate+" save="+outFile);
close();
}