Posted by
Jacqueline Ross on
Oct 31, 2013; 3:25am
URL: http://imagej.273.s1.nabble.com/Macros-for-Colour-Deconvolution-plugin-saving-multiple-files-tp5005383p5005397.html
Hi All,
Sorry that my macros look a bit difficult to view.
I have attached the two macro files this time. Hope they get through.
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 Jacqui Ross
Sent: Thursday, 31 October 2013 4:21 p.m.
To:
[hidden email]
Subject: Re: Macros for Colour Deconvolution plugin - saving multiple files
Hi Andrew,
The macro below works for us to save the individual images we want from the Colour Deconvolution process. It's customised to our vectors but you can just replace the line for the vectors that we use ("vectors=[User values] show [r1]=60.27969 [g1]=15.12007 [b1]=14.169498 [r2]=53.738953 [g2]=114.16744 [b2]=106.36251 [r3]=1.4947393 [g3]=7.050659 [b3]=12.738025");) with your own choice.
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]); imgName=getTitle(); run("Colour Deconvolution", "vectors=[User values] show [r1]=60.27969 [g1]=15.12007 [b1]=14.169498 [r2]=53.738953 [g2]=114.16744 [b2]=106.36251 [r3]=1.4947393 [g3]=7.050659 [b3]=12.738025"); //close windows we don't need selectWindow(imgName + "-(Colour_3)"); close(); selectWindow(imgName +"-(Colour_1)"); title = getTitle(); saveAs("TIFF", dir2 + title); close(); selectWindow(imgName + "-(Colour_2)"); title = getTitle(); saveAs("TIFF", dir2 + title); close(); }
If you have a previous version of ImageJ and your decon image names have the square brackets, then the macro below should work.
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]); imgName=getTitle(); run("Colour Deconvolution", "vectors=[User values] show [r1]=60.27969 [g1]=15.12007 [b1]=14.169498 [r2]=53.738953 [g2]=114.16744 [b2]=106.36251 [r3]=1.4947393 [g3]=7.050659 [b3]=12.738025"); //close windows we don't need selectWindow(imgName + " (Colour[3])"); close(); selectWindow(imgName +" (Colour[1])"); title = getTitle(); saveAs("TIFF", dir2 + title); close(); selectWindow(imgName + " (Colour[2])"); title = getTitle(); saveAs("TIFF", dir2 + title); close(); }
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 Schneider, David A.
Sent: Thursday, 31 October 2013 5:44 a.m.
To:
[hidden email]
Subject: Re: Macros for Colour Deconvolution plugin - saving multiple files
Andrew,
I'm working on similar analysis work flow and so will be interested to see responses to your post. However, regarding your last question, check to see if the window title in fact includes the file extension. If so, the selectWindow needs the full file name. So maybe your example needs to be more like this:
selectWindow(imgName + " (Colour[3]).tif");
Hope that helps,
Dave
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of drew_c
Sent: Wednesday, October 30, 2013 9:17 AM
To:
[hidden email]
Subject: Macros for Colour Deconvolution plugin - saving multiple files
Hi All,
I'm new to writing macros for image j so please bare with me. I'm trying to process a batch of images with multiple savepoints and with the colour deconvolution plugin. Any help with this is greatly appreciated.
The workflow that I would like to do is as follows:
1. select the input directory
2. select the output directory
3. run("Subtract Background...", "rolling=50 light"); 4. run("Colour Deconvolution", "vectors=[H DAB]");
At this point I would like to save colour1 as ''original image name_colour1'', and colour2 as ''original image name_colour2''. I do not need colour3.
Now don't mind ending the macro here and starting up a new macro becuase as
colour1 and colour2 images need to be treated differently in terms of thresholding and particle analysis so it might get complicated within the same macro. What I do need to next do is:
(5. select the input directory)
(6. select the output directory)
7. setAutoThreshold("Default");
8. //run("Threshold...");
9. setThreshold(0, 146);
10. run("Convert to Mask");
11. run("Fill Holes");
12. run("Convert to Mask");
13. run("Watershed");
14. run("Set Scale...", "distance=63 known=10 pixel=1 unit=um"); 15. run("Analyze Particles...", "size=30.00-300.00 circularity=0.00-1.00 show=Outlines display exclude summarize");
Here again I would like to save 2 images: The modified (thresholded, holed, masked, and watershedded) image as ''original image name_colour1_modified''
and the new outline image as ''original image name_outline''
I would really appreciate any help I can get - I've tried all sorts of things such as:
selectWindow(imgName + " (Colour[3])"); close();
But I get errors saying that there is no such window, and the closest that I'm getting to is being able to save 1 random window only.
Hope there is someone there who can spare some time!
BW
Andrew
--
View this message in context:
http://imagej.1557.x6.nabble.com/Macros-for-Colour-Deconvolution-plugin-saving-multiple-files-tp5005383.htmlSent from the ImageJ mailing list archive at Nabble.com.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html