Hi all, I'm new to the ImageJ program and am trying to write a macro that
counts cells on a membrane that I have a .jpg for. I have a macro so far that looks like this: dir = getDirectory("Choose a Directory "); list = getFileList(dir); setBatchMode(true); for (i=0; i<list.length; i++) { path = dir+list[i]; open(path); run("Make Binary"); run("Analyze Particles...", "size=35-Infinity circularity=0.7-1.00 show=Outlines display clear"); saveAs("Results", dir+i+"data.xls"); }} Now, what this gives me is a ton of .xls files with every single spot it has measured. What I would love it to do is tell me only how many spots it measured in all of the files listed by name. I assume it is possible to somehow, i dont know parse the results page to show me the last line and output it in one large excel spreadsheet? Thanks for any insight anyone can provide! -- Brian |
Dear Brian,
If you put the saveAs outside your for-loop it will save only at the end the table. However, you have to make some addition changes as you seem to want a summary table and not a results table so: dir = getDirectory("Choose a Directory ");{ list = getFileList(dir); setBatchMode(true); run("Set Measurements...", " display redirect=None decimal=5"); for (i=0; i<list.length; i++) { path = dir+list[i]; open(path); run("Make Binary"); run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Nothing summarize"); close(); } saveAs("txt", dir+i+"data.xls"); } Hope this helps Kees -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Brian Lin Sent: 01 April 2011 21:03 To: [hidden email] Subject: Extracting data from results window Hi all, I'm new to the ImageJ program and am trying to write a macro that counts cells on a membrane that I have a .jpg for. I have a macro so far that looks like this: dir = getDirectory("Choose a Directory "); list = getFileList(dir); setBatchMode(true); for (i=0; i<list.length; i++) { path = dir+list[i]; open(path); run("Make Binary"); run("Analyze Particles...", "size=35-Infinity circularity=0.7-1.00 show=Outlines display clear"); saveAs("Results", dir+i+"data.xls"); }} Now, what this gives me is a ton of .xls files with every single spot it has measured. What I would love it to do is tell me only how many spots it measured in all of the files listed by name. I assume it is possible to somehow, i dont know parse the results page to show me the last line and output it in one large excel spreadsheet? Thanks for any insight anyone can provide! -- Brian |
Thanks to all of you for your assistance! They were very helpful and
definitely cut out several days of counting. To be honest, I followed it up until Dr Straatman's suggestion. I have absolutely no idea how it was able to summarize it all in one excel doc. I'll try to puzzle it out myself with a bit of time. Thanks again for all the help Brian -- Brian Lin [hidden email] [hidden email] On Mon, Apr 4, 2011 at 5:10 AM, Straatman, Kees R. (Dr.) < [hidden email]> wrote: > Dear Brian, > > If you put the saveAs outside your for-loop it will save only at the end > the table. > > However, you have to make some addition changes as you seem to want a > summary table and not a results table so: > > dir = getDirectory("Choose a Directory ");{ > list = getFileList(dir); > setBatchMode(true); > run("Set Measurements...", " display redirect=None decimal=5"); > for (i=0; i<list.length; i++) { > path = dir+list[i]; > open(path); > run("Make Binary"); > run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 > show=Nothing summarize"); > close(); > } > saveAs("txt", dir+i+"data.xls"); > } > > Hope this helps > > Kees > > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > Brian Lin > Sent: 01 April 2011 21:03 > To: [hidden email] > Subject: Extracting data from results window > > Hi all, I'm new to the ImageJ program and am trying to write a macro that > counts cells on a membrane that I have a .jpg for. > I have a macro so far that looks like this: > > dir = getDirectory("Choose a Directory "); > list = getFileList(dir); > setBatchMode(true); > for (i=0; i<list.length; i++) { > path = dir+list[i]; > open(path); > run("Make Binary"); > run("Analyze Particles...", "size=35-Infinity circularity=0.7-1.00 > show=Outlines display clear"); > saveAs("Results", dir+i+"data.xls"); > }} > > > Now, what this gives me is a ton of .xls files with every single spot it > has > measured. > What I would love it to do is tell me only how many spots it measured in > all > of the files listed by name. I assume it is possible to somehow, i dont > know > parse the results page to show me the last line and output it in one large > excel spreadsheet? > > Thanks for any insight anyone can provide! > > -- > Brian > |
Free forum by Nabble | Edit this page |