Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
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 |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
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 ... [show rest of quote] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Thanks so much Melissa. Both suggestions worked perfectly. The quoting
on the brackets in the open= argument makes perfect sense now that I see what you did, but I couldn't get there on my own when constructing a dynamic string from my static macro recording. Thanks for being so explicit! The run('Close') suggestion was completely off my radar. Is there basic documentation that I should have been reading prior to posting? Thanks again, Rob On 7/11/2013 7:02 PM, Melissa Linkert wrote: > 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 ... [show rest of quote] -- 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 |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi Rob,
> The run('Close') suggestion was completely off my radar. Is there > basic documentation that I should have been reading prior to posting? It is often very useful to open the macro recorder (Plugins > Macros > Record) and then attempt to perform the operation of interest. Usually it will log the command you need into the recorder -- in this case: run("Close"); You can also try Googling. I searched for "imagej close non-image window" and found some threads on Nabble which answer this same question. Regards, Curtis On Fri, Jul 12, 2013 at 10:37 AM, Robert Baer <[hidden email]> wrote: > Thanks so much Melissa. Both suggestions worked perfectly. The quoting > on the brackets in the open= argument makes perfect sense now that I see > what you did, but I couldn't get there on my own when constructing a > dynamic string from my static macro recording. Thanks for being so > explicit! > > The run('Close') suggestion was completely off my radar. Is there basic > documentation that I should have been reading prior to posting? > > Thanks again, > > Rob > > > On 7/11/2013 7:02 PM, Melissa Linkert wrote: > >> 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<http://imagej.nih.gov/ij/list.html> >>> >> > > -- > > 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<http://imagej.nih.gov/ij/list.html> > ... [show rest of quote] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Disable Popup Ads | Edit this page |