Posted by
Knecht, David on
Mar 14, 2012; 2:21pm
URL: http://imagej.273.s1.nabble.com/Batch-splitting-of-stacks-and-saving-tp4578247p4578373.html
Hi Ash- I just did this with a different goal, but the same basic problem and I am also not a programmer. Attached is a macro I came up with after lots of help from the list. Paste it into your startup macros set and then modify. If you remove my "run" scale and label etc. commands with your tasks, the shell should be the same. I would use the recorder to find the commands you need to split the stack (I am guessing stack to hyperstack and then split channels from the hyperstack and put those in place of my run commands near the end. It asks you for a folder where the original are and then asks for a folder to put the processed files into. Dave
macro "batch process folder scale and make movie2"{
requires("1.33s");
dir = getDirectory("Choose a Directory ");
dir2 = getDirectory("Choose Destination Directory ");
setBatchMode(true);
count = 0;
countFiles(dir);
n = 0;
processFiles(dir, dir2);
//print(count+" files processed");
}
function countFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir, dir2) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
processFiles(""+dir+list[i], dir2);
else {
showProgress(n++, count);
path = dir+list[i];
processFile(path, dir2);
}
}
}
function processFile(path,dir2) {
if (endsWith(path, ".tif")) {
open(path);
title1=getTitle();
run("8-bit");
run("Properties...", " unit=pixel pixel_width=.64 pixel_height=.64 voxel_depth=1.0000 frame=[5 min] origin=0,0");
run("Scale...", "x=.7 y=.7 interpolation=Bilinear average process create");
run("Label...", "format=00:00 starting=0 interval=4 x=800 y=20 font=18 text=hr:min ");
run("QuickTime Movie...", "compression=MPEG-4 quality=Normal frame=20 save=[/dir2/test.mov]");
run("Close All");
call("java.lang.System.gc");
}
}
On Mar 14, 2012, at 1:43 PM, Ash Dunne wrote:
> Hi all,
>
> I'm struggling a bit with what I presume must be a fairly simple task.
>
> I have a load of images that have been acquired as stacks with the first
> slice being DAPI, and the second being 488.
>
> I want to find a way to split these into separate images and save them with
> file names that obviously relate to each other and to the original image. I
> can do this manually, but have hundreds of images that need this doing to
> them. There must be a way to batch it with a macro or plugin, but I'm not a
> programmer!
>
> Any help greatly appreciated.
>
> Kind regards,
>
> Ash
>
> --
> View this message in context:
http://imagej.1557.n6.nabble.com/Batch-splitting-of-stacks-and-saving-tp4578247p4578247.html> Sent from the ImageJ mailing list archive at Nabble.com.
Visiting Professor David Knecht
Beatson Institute for Cancer Research
University of Glasgow
Switchback Road, Bearsden
Glasgow Scotland G61 1BD
UK
Visiting Professor David Knecht
Beatson Institute for Cancer Research
University of Glasgow
Switchback Road, Bearsden
Glasgow Scotland G61 1BD
UK