Login  Register

Re: virtual stack

Posted by Rasband, Wayne (NIH/NIMH) [E] on Mar 22, 2010; 6:26am
URL: http://imagej.273.s1.nabble.com/virtual-stack-tp3688745p3688746.html

On Mar 21, 2010, at 9:53 AM, David Knecht charter wrote:

> I am trying to add a time stamp to a stack that is too large to open in ImageJ.  I added the Time Stamper plugin to a virtual stack macro to try to get it to do the job, but I get back an error message that the file is not a stack.  How do you get around this?  Dave

You can time stamp a virtual stack by using the Process>Batch>Macro command and entering macro code something like this:

   setFont("SansSerif", 18, "antialiased");
   setColor("white");
   n=toString(i);
   while (lengthOf(n)<4) n="0"+n;
   drawString(n, 20, 30);

The Process>Batch>Macro command was added in ImageJ 1.43.

-wayne


> // Process Virtual Stack
> //
> // This macro demonstrates how to process the images in a
> // virtual stack, save the processed images in a folder, and
> // then open those images in another virtual stack. The virtual
> // stack can be opened using File>Import>Image Sequence,
> // File>Import>TIFF Virtual Stack or File>Import>Raw.
>
>  if (nSlices==1) exit("Stack required");
>  dir = getDirectory("Choose Destination Directory ");
>  setBatchMode(true);
>  id = getImageID;
>  for (i=1; i<= nSlices; i++) {
>      showProgress(i, nSlices);
>      selectImage(id);
>      setSlice(i);
>      name = getMetadata;
>      run("Duplicate...", "title=temp");
>      run("Time Stamper");
>      saveAs("tif", dir+pad(i-1));
>      close();
>  }
>  setBatchMode(false);
>  run("Image Sequence...", "open=["+dir+"00000.tif] use");
>
>  function pad(n) {
>      str = toString(n);
>      while (lengthOf(str)<5)
>          str = "0" + str;
>      return str;
>  }
>
> Dr. David Knecht    
> Department of Molecular and Cell Biology
> Co-head Flow Cytometry and Confocal Microscopy Facility
> U-3125
> 91 N. Eagleville Rd.
> University of Connecticut
> Storrs, CT 06269
> 860-486-2200
> 860-486-4331 (fax)