Login  Register

Re: Loci plugin and macro file conversion Questions

Posted by Melissa Linkert-2 on Jul 12, 2013; 12:02am
URL: http://imagej.273.s1.nabble.com/Loci-plugin-and-macro-file-conversion-Questions-tp5003928p5003936.html

Hi Rob,

> I wrote a short macro to convert a set of images from Zeiss .zvi to
> .tiff format (code below).  The macro works, but I have two minor
> issues I can not overcome.  If prior to running my macro, I load an
> image with Loci Bioformats plutgin and uncheck show metadata and
> then load a second image with the windowless format turned on, I can
> process my whole directory of images without manual intervention.
> However, I can not figure out how to set these defaults within the
> context of the macro.  Can anyone point me to the proper way to set
> defaults for the Loci plugins?

Probably the easiest thing to do is to use the macro recorder to open a
file with the desired options set, and then paste the output into your
macro in place of the 'open(...)' command.  Something like this:

run("Bio-Formats Importer", "open=["+dir1+list[i]+"]");

may be sufficient.

> The second issue is that if I choose to let the metadata show in
> windows as the conversion goes on, I can't figure out how to close
> the files.  Is there way to close these files other than one by one?
> close and closeAll  seem to only work with image windows.

Have you tried:

run("Close");

instead?  That should allow you to close any non-image windows.

Regards,
-Melissa

On Thu, Jul 11, 2013 at 02:27:03PM -0500, Robert Baer wrote:

> I wrote a short macro to convert a set of images from Zeiss .zvi to
> .tiff format (code below).  The macro works, but I have two minor
> issues I can not overcome.  If prior to running my macro, I load an
> image with Loci Bioformats plutgin and uncheck show metadata and
> then load a second image with the windowless format turned on, I can
> process my whole directory of images without manual intervention.
> However, I can not figure out how to set these defaults within the
> context of the macro.  Can anyone point me to the proper way to set
> defaults for the Loci plugins?
>
> The second issue is that if I choose to let the metadata show in
> windows as the conversion goes on, I can't figure out how to close
> the files.  Is there way to close these files other than one by one?
> close and closeAll  seem to only work with image windows.
>
> Thanks for any pointers,
>
> Rob
>
> // The macro code
> //
>
> macro "Batch Convert .zvi to .tif"{
>     requires("1.33s");
>     dir1 = getDirectory("Choose Source Directory ");
>     dir2 = getDirectory("Choose Destination Directory ");
>      print(dir1 + " -> " + dir2);
>     list = getFileList(dir1);
>     setBatchMode(true);
>
>     for (i=0; i < list.length; i++) {
>         showProgress(i + 1, list.length);
>         print(dir1 + list[i]);
>         if (endsWith(toLowerCase(list[i]), ".zvi")){
>             open(dir1 + list[i]);
>             dotIndex = lastIndexOf(list[i], ".");
>               if (dotIndex!=-1){
>                 list[i] = substring(list[i], 0, dotIndex); // remove .zvi
>                 saveAs ("Tiff", dir2 + list[i]+'.tif');
>             }
>         }
>         close();
>     }
> }
>
>
> --
>
> Robert W. Baer, Ph.D.
> Professor of Physiology
> Kirksille College of Osteopathic Medicine
> A. T. Still University of Health Sciences
> Kirksville, MO 63501 USA
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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