Login  Register

Re: Natural Sort of File List Array

Posted by Cameron Nowell-2 on Feb 27, 2015; 3:01am
URL: http://imagej.273.s1.nabble.com/Natural-Sort-of-File-List-Array-tp5011777p5011795.html

Thanks Wayne, I was thinking that may be an option. I now just need to get
it to work with the logic of the rest of the code as we have multiple wells,
channels, fields etc all in there:)



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Rasband, Wayne (NIH/NIMH) [E]
Sent: Friday, 27 February 2015 4:14 AM
To: [hidden email]
Subject: Re: Natural Sort of File List Array

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

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