Re: split channels and all files in a directory

Posted by Veronica Labrador Cantarero on
URL: http://imagej.273.s1.nabble.com/split-channels-and-all-files-in-a-directory-tp3685101p3685111.html

 Hi Ramon:

 These are the instructions we use to process all the files in a
 directory:

 ******
 origen = getDirectory("Images to process");
 destino = getDirectory("Results");
 lista = getFileList(origen);
 setBatchMode(true);
 for (i=0; i<lista.length; i++) {
  showProgress(i+1, lista.length);
  open(origen+lista[i]);
  nombre = lista[i];
          (MACRO FUNCTIONS/INSTRUCTIONS HERE)
  saveAs(".tiff", destino + nombre);
  close();
  }
 ******

 "Origen" and "destino" are just the names we have given to the
 variables (the path to the Directory and folder where you have your
 images and where you want to save your results).

 "nombre" is another variable to save the result image with the same
 name as the original image.

 To select a window use this instruction: selectWindow("NAME OF THE
 WINDOW");

 An easy way to work with the 3 resultant images after splitting
 channels is to rename the original image:

 *******
          rename("A");
  run("Split Channels");
  selectWindow("C2-A");
 *******


 I hope you find this information useful.

 Kind regards,

 Veronica


 On Thu, 7 Apr 2011 16:14:38 +0200, Ramon Guirado <[hidden email]>
 wrote:

> In fact I don't know how to identify the new windows created as a
> result of
> the image calculation...
>
> On 7 April 2011 16:04, Ramon Guirado <[hidden email]> wrote:
>
>> Hi, I'm trying to write a macro able to open all the files in a
>> directory,
>> split the channels of the images and analyze particles in this
>> separated
>> channels as well as the composite between some of them (they will be
>> also
>> binarized, etc...). I have just done small macros using the macro
>> recorder,
>> so I don't know how to do it, I'm trying to get the identity of
>> every image
>> in a directory and then I guess after the image calculator, I will
>> have to
>> identify the new windows just created so they are processed as well,
>> and
>> then do that recursively, but I feel a little bit lost... which
>> would be the
>> easiest way to proceed? by know I'll try to understand the macro
>> posted
>> by Carnë Draug..
>>
>> Thanks,
>>
>>
>> ramon
>>