Dear Sonia,
Here's one way that may serve for your purpose. It's ugly but works.
Best,
George
print("\\Clear");
imagetoopen=File.openDialog("Pick your stack");
setBatchMode(true);
startTime=getTime()
open(imagetoopen);
OriginalName=File.nameWithoutExtension;
StackName=getInfo("image.filename");
dir0 = File.directory;
File.makeDirectory(dir0+OriginalName+"TiffFiles");
FileSep=File.separator();
TiffFiles=FileSep+OriginalName+"TiffFiles"+FileSep;
dir1=dir0+TiffFiles;
selectWindow(StackName);
getDimensions(width, height, channels, slices, frames);
NumSlices=d2s(nSlices,0);
padValue=lengthOf(NumSlices);
setSlice(1);
for (i=0; i<nSlices; i++) {
j = i+1;
selectWindow(StackName);
run("Make Substack...", "slices="+j);
paddedSlice=IJ.pad(i,padValue);//IJ.pad requires version 1.45d or later
newImageName=OriginalName+paddedSlice;
saveAs("Tiff", dir1+newImageName);
close();
}
selectWindow(StackName);
close();
setBatchMode(true);
stopTime=getTime();
itTook=stopTime-startTime;
print(itTook+" msec");
On Sep 26, 2012, at 9:30 AM, Sonia Aguera wrote:
> Hi,
>
> I would like to export z stack files (.lif) into separate images, one
> per step (as a .tiff file). I need to keep the original name and the
> number of the slice.
>
> I made a small macro to do this, but it does not work. I will very much
> appreciate your expert advice.
>
> Thank you very much
>
> This is my macro:
> ---
> run("Stack to Images");
> saveAs("Tiff",
> "/Users/saguera/Desktop/sa20120925.forAcapella/getTitle().getSliceNumber().tif");
> -----
>
> Can this be done in a batch?
>
> Cheers
>
> --
>
> Sonia Aguera-Gonzalez, PhD
> Unité de Biologie Cellulaire des Lymphocytes
> Institut Pasteur
> 28, rue du Dr Roux
> 75724 Paris Cedex 15
> France
> Tel : 33 1 40 61 3559
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.htmlGeorge H. Patterson
Building 13 3E33
13 South Drive
Biophotonics Section
National Institute of Biomedical Imaging and Bioengineering
National Institutes of Health
Bethesda, MD 20892
Office: 301-443-0241
Fax: 301-496-6608
[hidden email]
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html