Login  Register

Re: Natural Sort of File List Array

Posted by Rasband, Wayne (NIH/NIMH) [E] on Feb 26, 2015; 5:14pm
URL: http://imagej.273.s1.nabble.com/Natural-Sort-of-File-List-Array-tp5011777p5011789.html

On Feb 25, 2015, at 6:18 PM, Cameron Nowell <[hidden email]> wrote:

>
> Hi List,
>
> I am batch processing a time series captured on a GE INCell imager. The
> files have names like C - 9(fld 1 wv CFP - CFP- time 1 - 0 ms). The issue is
> the Time 1 part. In windows explorer or mac finder they are ordered as time
> 1, time2, time 3, time 4, time 5......etc. If I load them into a stack using
> the load image sequence command they load in the right order. But if I use a
> macro to select a directory and build a file list it loads them in the order
> time 1, time 10, time 11, time 12.......time 19, time 2, time 20, time
> 21...... etc.
>
> Is there any way to get the file list array to sort in a different order so
> the timepoints don't get messed up?

The macro could use Import>Image Sequence… to open the time series as a virtual stack and then process and save each of the images. I attached an example.

-wayne

  dir1 = getDirectory("Choose Input Directory");
  dir2 = getDirectory("Choose Output Directory");
  setBatchMode(true);
  run("Image Sequence...", "open=&dir1 sort use");
  stack = getImageID;
  for (i=1; i<=nSlices; i++) {
     showProgress(i, nSlices);
     selectImage(stack);
     setSlice(i);
     title = getMetadata("Label");
     run("Duplicate...", " ");
     run("Gaussian Blur...", "sigma=5");
     saveAs("tiff", dir2+title);
     close;
  }
  showStatus("Done");



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html