// This macro is only for use on the Macintosh. //* by Michael Cammer August 2004 for the AIF at AECOM http://www.aecom.yu.edu/aif/ cammer@aecom.yu.edu //* For DIAS 1.4.1 running on OSX //* //* Each folder may contain only one sequence of uncompressed 8 bit tif images. //* Images must be named FILNAME# where the number has no leading zeros. //* Files may not have an extension. In DOS, this may be fixed by: ren *.tif *. //* //********************************************************************* // This macro converts a multiple image timelapse file to a folder // full of individual tifs that have no extension (no ".tif") and that are // numbered without leading zeros so that DIAS may open them. // Instructions: // 1. In the Finder create a destination directory. // 2. Open a multiple image file. // 3. Run this macro (tpy F9 key) // 4. choose a directory to save files // 5. close the image // macro "Convert TIF stack to folder of TIFS [f9]"{ if (nImages() < 1) exit ('Must have a stack open.'); run("8-bit"); originalid = getImageID(); title = getTitle(); slices = nSlices(); if (endsWith(title,'.tif')) title = substring(title, 0, (lengthOf(title)-4)); if (endsWith(title,"0")) title = title + "_"; if (endsWith(title,"1")) title = title + "_"; if (endsWith(title,"2")) title = title + "_"; if (endsWith(title,"3")) title = title + "_"; if (endsWith(title,"4")) title = title + "_"; if (endsWith(title,"5")) title = title + "_"; if (endsWith(title,"6")) title = title + "_"; if (endsWith(title,"7")) title = title + "_"; if (endsWith(title,"8")) title = title + "_"; if (endsWith(title,"9")) title = title + "_"; width = getWidth; height = getHeight; run("New...", "name=temp type=8-bit fill=Ramp width="+width+" height="+height+" slices=1"); tempid = getImageID(); //root = getDirectory("image"); // could be used instead to save in same place // user chooses where to save files dumpfiles = getDirectory("Choose a directory for saving the files. "); setPasteMode("Copy"); for(a=1;a<=slices;a++){ selectImage(originalid); run("Set Slice...", "slice="+a); run("Select All"); run("Copy"); selectImage(tempid); run("Paste"); filename = dumpfiles+ title+ a + ""; print(filename); run("Tiff...", "save="+filename); } // for a selectImage(tempid); run("Close"); } // Convert TIF stack to folder of TIFS [f9]