Hi All,
I'm helping one of our researchers with a macro to split Haematoxylin/DAB images into the 3 separate images and save Colour1 and Colour2 as separate files into a destination folder. What I can't seem to be able to do is just give the destination directory using Dir2 saveAs("TIFF", "dir2+list[i]" +title); so I am having to use a specified path. This is working but I'd like to be able to do it properly. I think it's something to do with the titles... Can anyone point me in the direction of my error? I'm having a mental block with this one! This is the macro; dir1 = getDirectory("Choose Source Directory "); dir2 = getDirectory("Choose Destination Directory "); list = getFileList(dir1); setBatchMode(true); for (i=0; i<list.length; i++) { showProgress(i+1, list.length); open(dir1+list[i]); makeRectangle(1386, 702, 2952, 2958); run("Crop"); run("Subtract Background...", "rolling=50 light"); imgName=getTitle(); run("Colour Deconvolution", "vectors=[H DAB]"); //close windows we don't need selectWindow(imgName + " (Colour[3])"); close(); selectWindow(imgName +" (Colour[1])"); title = getTitle(); print("title: " + title); saveAs("Tiff", "C:\\Users\\jros013\\Desktop\\Rachel_output\\"+title); close(); selectWindow(imgName + " (Colour[2])"); title = getTitle(); print("title: " + title); saveAs("Tiff", "C:\\Users\\jros013\\Desktop\\Rachel_output\\"+title); close(); saveAs("TIFF", "dir2+list[i]" +title); close(); } Thanks! Kind regards, Jacqui Jacqueline Ross Biomedical Imaging Microscopist Biomedical Imaging Research Unit School of Medical Sciences Faculty of Medical & Health Sciences The University of Auckland Private Bag 92019 Auckland 1142, NEW ZEALAND Tel: 64 9 923 7438 Fax: 64 9 373 7484 http://www.fmhs.auckland.ac.nz/sms/biru/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On 2012.10.08, at 18:49 , Jacqui Ross wrote:
> > What I can't seem to be able to do is just give the destination directory > saveAs("TIFF", "dir2+list[i]" +title); Hi Jacqui, I haven't read your macro, but if you quote "dir2+list[i]" then <<dir2>> and the item <<i>> in the array <<list>> are no longer variables, they simply become one string, containing no file name separators. You may just need to unquote them. Also, if <<title>> already includes the <<list[i]>> filename, you may want to just use: saveAs("TIFF", dir2 + title); This kind of frustrations are easily avoidable by using a text editor w/ syntax highlighting, such as the Fiji script editor. HTH, -tiago -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks Tiago and Wayne!
Your suggestions have solved the problem. I just needed to put; title = getTitle(); saveAs("TIFF", dir2 + title); Now, it's working fine. Just a bit puzzled by the loss of one of the square brackets in the file name... I have to admit that I haven't used the Fiji script editor as yet but will give it a try next time. I do use the "evaluate line" and debugging in the standard ImageJ. Kind regards, Jacqui Jacqueline Ross Biomedical Imaging Microscopist Biomedical Imaging Research UnitĀ School of Medical SciencesĀ Faculty of Medical & Health Sciences The University of Auckland Private Bag 92019 Auckland 1142, NEW ZEALAND Tel: 64 9 923 7438 Fax: 64 9 373 7484 http://www.fmhs.auckland.ac.nz/sms/biru/ -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Tiago Ferreira Sent: Tuesday, 9 October 2012 4:34 p.m. To: [hidden email] Subject: Re: Colour Deconvolution Macro - help with saving files On 2012.10.08, at 18:49 , Jacqui Ross wrote: > > What I can't seem to be able to do is just give the destination > directory saveAs("TIFF", "dir2+list[i]" +title); Hi Jacqui, I haven't read your macro, but if you quote "dir2+list[i]" then <<dir2>> and the item <<i>> in the array <<list>> are no longer variables, they simply become one string, containing no file name separators. You may just need to unquote them. Also, if <<title>> already includes the <<list[i]>> filename, you may want to just use: saveAs("TIFF", dir2 + title); This kind of frustrations are easily avoidable by using a text editor w/ syntax highlighting, such as the Fiji script editor. HTH, -tiago -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |