passing arguments to Image Sequence

Posted by Glen MacDonald on
URL: http://imagej.273.s1.nabble.com/passing-arguments-to-Image-Sequence-tp3702558.html

Hello,
I'm having difficulty passing arguments to open a series of TIFF images with the Import/Image
Sequence dialog.  I have OIF formatted files from the Olympus confocal. Multi-channel z-series
images are exported as a series of 16-bit TIFFs for each channel.  Also, a LUT for each channel and a
bunch of nuisance files with metadata are created.  The following should look at a user selected
directory, determine how many channels are present by the number of LUT files, then calculate the
location of first TIFF in the directory array.  The name of this tiff, number of TIFFs  and a bit of text
identifying which channel of TIFFs to import (file=C00n) should be passed to the command.

The commented out Image Sequence command at the bottom is the result of recording the macro.  
The values in the macro command are the last of the many permutations I've tried.  

thanks,
Glen

//number of channels = number of .lut files
//TIFF images per channel = TIFF files/lut

macro "File Array [F]"
{
        dir = getDirectory("Choose a Directory ");
        listFiles(dir);
        function listFiles(dir)
{
        list = getFileList(dir);
        for (i=0; i<list.length; i++)
    if (endsWith(list[i], ".lut"))  
      lut=lut+1;
        for  (i=0; i<list.length; i++)
        {
        if (endsWith(list[i], ".tif"))  {
                tiffnum=tiffnum+1;
                numtiffch=(tiffnum/lut);
                lastTiff=i;     }
        }
print("Number of channels: " +lut);
print("Number of TIFFs: "+tiffnum);
print("TIFFs per channel: "+ numtiffch);
offset=(lastTiff-(tiffnum*2)+2);//calculate the first tiff file in the directory array
filestart=dir+list[offset]; ///get that file name
firsttiff=File.getAbsolutePath(filestart);//make darn sure this is a string
run("Image Sequence...", "open= +firsttiff number= tiffnum starting=1 increment=1 scale=100
file=C001");
//run("Image Sequence...", "open=[/Volumes/UWCCR 2 GB/Image0002.oif.files/
Image0002_C001Z001.tif] number=126 starting=1 increment=1 scale=100 file=C001");
}
}