hello
I run a loop for image analysis, at the end I get a table of results for each image, I want to keep this table (one per image) but I also want more, a table in excel that append the results of the image n+1 to those of the image n in the same worksheet, if I uncheck the box "clear results" in the window "analyze particles" that increments the number of objects counted I do not want to. can someone help me? -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi,
We may have a solution but we apologize it is not using open source materials… but I’m sure that open source solutions exist to do the same! On windows 7: # Start a command prompt # Get into the directory containing “.xls” file # Type : copy /b *.xls newFile.csv You will find more explanation within the “.jpg” enclosed Hope it helps, Romain and Olivier --------------------------------------------------------------- Dr. Romain Guiet Bioimaging and Optics Platform (PT-BIOP) Ecole Polytechnique Fédérale de Lausanne (EPFL) Faculty of Life Sciences Station 19, AI 0241 CH-1015 Lausanne Phone: [+4121 69] 39629 http://biop.epfl.ch/ --------------------------------------------------------------- ________________________________________ De : ImageJ Interest Group [[hidden email]] de la part de annie Venien [[hidden email]] Date d'envoi : mardi 12 mars 2013 15:00 À : [hidden email] Objet : how to append results in excel file hello I run a loop for image analysis, at the end I get a table of results for each image, I want to keep this table (one per image) but I also want more, a table in excel that append the results of the image n+1 to those of the image n in the same worksheet, if I uncheck the box "clear results" in the window "analyze particles" that increments the number of objects counted I do not want to. can someone help me? -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html W7_xls_concat.jpg (259K) Download Attachment W7_xls_import.jpg (327K) Download Attachment W7_xls_table.jpg (257K) Download Attachment |
In reply to this post by annie Venien
Hello everyone,
Since I stumbled over this older post while looking for a solution for the same problem, I thought I post the solution I figured out ... Martin --------------------------------------------------------------------------------- //deselect Results>Options>Results Table Options>Copy Column Headers //in order to avoid multiple header lines in the combined Results table run("Blobs (25K)"); run("Invert"); setAutoThreshold("Default dark"); setOption("BlackBackground", true); run("Convert to Mask"); table="[Combined Results]"; run("Table...", "name="+table+" width=450 height=500"); results_merge=""; //variable that will be filled with all results for (i=0; i<3; i++) { run("Analyze Particles...", "size=2-infinity display exclude clear"); String.copyResults; resultati=String.paste; results_merge=results_merge+resultati; selectWindow("Results"); //to save the Results of each individual run //saveAs("Text",.........."); } print(table,String.getResultsHeadings); print(table,results_merge); //this table contains all results --------------------------------------------------------------------------------------- |
Is it possible to copy results from the "Summary" table instead?
|
Hi Mr Sanchez,
Could you figure out how to append /copy the text Summary window? We are running large amounts of images, each summarized in 1 line. It is nice to save the line as a text file (or CSV), but nicer would be to append the line from each image's summary window to an already existing file. So far, I could not figure out how. Greetings, Dimitri |
Dear Dimitri,
To append to a file within a macro it is the instruction "File.append(string, path)" which details can be found under: http://rsb.info.nih.gov/ij/developer/macro/functions.html My best regards, Philippe Philippe CARL Laboratoire de Biophotonique et Pharmacologie UMR 7213 CNRS - Université de Strasbourg Faculté de Pharmacie 74 route du Rhin 67401 ILLKIRCH Tel : +33(0)3 68 85 41 84 -----Message d'origine----- De : ImageJ Interest Group [mailto:[hidden email]] De la part de Dimitri Vanhecke Envoyé : mercredi 9 mars 2016 15:24 À : [hidden email] Objet : Re: how to append results in excel file Hi Mr Sanchez, Could you figure out how to append /copy the text Summary window? We are running large amounts of images, each summarized in 1 line. It is nice to save the line as a text file (or CSV), but nicer would be to append the line from each image's summary window to an already existing file. So far, I could not figure out how. Greetings, Dimitri -- View this message in context: http://imagej.1557.x6.nabble.com/how-to-append-results-in-excel-file-tp50021 26p5015834.html Sent 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 |
In reply to this post by annie Venien
I am trying to do exactly what Annie Venien described in the original post using ImageJ macro language i.e. save analysis data from images into individual files AND also combine them into a single csv file. Tried all sorts of things involving strings, File.append, etc., to combine them into a single csv file, but can't crack it. A lot of people have requested advice for the same thing in various forums. The "Read and Write Excel" plugin adds data side-by-side, instead of appending it in columns. Has anyone come up with a plugin or other method to achieve this, either as you go during analysis of multiple files, or post-analysis to concatenate csv data files vertically?
|
Depends how you're doing your analysis.
If you're looping through pictures in a folder then you should create a results table and print to that in every iteration. I typically save the results table to a file every loop too in case of problems. You can just overwrite this every iteration rather than append (writing a csv file is not that time consuming unless the file is huge). If you're doing something else... you'll have to spell that out and help us help you (and others). How to make a custom results table and record to it: http://imagej.1557.x6.nabble.com/How-to-create-a-customised-results-table-and-add-data-to-it-within-a-macro-td5000701.html Save that file out as csv (txt): http://imagej.1557.x6.nabble.com/save-results-table-as-csv-with-custom-name-td5003427.html Put that into a loop and you're golden. B On Tue, Aug 1, 2017 at 7:15 PM, Guy Lyons <[hidden email]> wrote: > I am trying to do exactly what Annie Venien described in the original post > using ImageJ macro language i.e. save analysis data from images into > individual files AND also combine them into a single csv file. Tried all > sorts of things involving strings, File.append, etc., to combine them into > a > single csv file, but can't crack it. A lot of people have requested advice > for the same thing in various forums. The "Read and Write Excel" plugin > adds > data side-by-side, instead of appending it in columns. Has anyone come up > with a plugin or other method to achieve this, either as you go during > analysis of multiple files, or post-analysis to concatenate csv data files > vertically? > > > > -- > View this message in context: http://imagej.1557.x6.nabble. > com/how-to-append-results-in-excel-file-tp5002126p5019149.html > Sent 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 |
Thanks for the rapid reply, Brandon. I'm using Mac OsX 10.10.5, ImageJ 2.0.0-rc-43/1.51p. The macro as it stands has over 100 lines, so I'm not sure if it would be helpful to include it here. The macro currently is designed to analyse the output from a Cytation 3, which takes images of cell cultures in 3 channels from multiple areas of a culture vessel. There is a DAPI channel and 2 nuclear antigen-specific channels, and the Cytation software saves each channel in a separate file. Typically, 64 images are obtained per channel for each sample. The macro first uses the DAPI channel to create a mask to identify the nuclei and then uses a for loop to measure the area and the integrated density for each channel of each nucleus, writing the data for the area and each channel to a separate array, and then finally combining the arrays using Array.show and saving it as a csv. The macro does this for all of the Cytation 3 images in a folder. It does this successfully and reasonably quickly, writing the data to a csv file for each image. We (i.e. my student) then manually combine the data from the 64 csv files by copying and pasting within Excel – a tedious task that includes the possibility of making mistakes.
The strategies that I have tried in order to generate a single file (including some based on the links that you sent) by modifying the for loop run into the problem of having to write to the Results window but also having to "Clear Results" between analysis of channels (each channel being recorded in a separate original file). The simplest solution for me would be a method that combines the data of multiple csv files into a single csv file with just one row of headers. Maybe someone out there can accept this as a challenge? I'm sure I'm not the only one who would find it useful. Guy.
|
Dear Guy,
It is possible to have more than one results table in case you want to save data from different channels in different files, although you have to rename them as there can be only one active Results table (not sure that is what you want as I am not sure why you use an Array instead of the Results table): IJ.renameResults(oldName,newName); If you select the correct Results table and don't "Clear Results" the results will be added to the existing table. If you select under "Set Measurements" the option "Display label" the name of each image will be included in the results table. Once all the images are analysed you can save these files and all the results per channel for all the images analysed are in a single file. Hope this is what you have in mind Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Guy Lyons Sent: 02 August 2017 04:52 To: [hidden email] Subject: Re: how to append results in excel file Thanks for the rapid reply, Brandon. I'm using Mac OsX 10.10.5, ImageJ 2.0.0-rc-43/1.51p. The macro as it stands has over 100 lines, so I'm not sure if it would be helpful to include it here. The macro currently is designed to analyse the output from a Cytation 3, which takes images of cell cultures in 3 channels from multiple areas of a culture vessel. There is a DAPI channel and 2 nuclear antigen-specific channels, and the Cytation software saves each channel in a separate file. Typically, 64 images are obtained per channel for each sample. The macro first uses the DAPI channel to create a mask to identify the nuclei and then uses a for loop to measure the area and the integrated density for each channel of each nucleus, writing the data for the area and each channel to a separate array, and then finally combining the arrays using Array.show and saving it as a csv. The macro does this for all of the Cytation 3 images in a folder. It does this successfully and reasonably quickly, writing the data to a csv file for each image. We (i.e. my student) then manually combine the data from the 64 csv files by copying and pasting within Excel – a tedious task that includes the possibility of making mistakes. The strategies that I have tried in order to generate a single file (including some based on the links that you sent) by modifying the for loop run into the problem of having to write to the Results window but also having to "Clear Results" between analysis of channels (each channel being recorded in a separate original file). The simplest solution for me would be a method that combines the data of multiple csv files into a single csv file with just one row of headers. Maybe someone out there can accept this as a challenge? I'm sure I'm not the only one who would find it useful. Guy. Brandon Hurr wrote > Depends how you're doing your analysis. > > If you're looping through pictures in a folder then you should create > a results table and print to that in every iteration. I typically save > the results table to a file every loop too in case of problems. You > can just overwrite this every iteration rather than append (writing a > csv file is not that time consuming unless the file is huge). > > If you're doing something else... you'll have to spell that out and > help us help you (and others). > > How to make a custom results table and record to it: > http://imagej.1557.x6.nabble.com/How-to-create-a-customised-results-ta > ble-and-add-data-to-it-within-a-macro-td5000701.html > Save that file out as csv (txt): > http://imagej.1557.x6.nabble.com/save-results-table-as-csv-with-custom > -name-td5003427.html > > Put that into a loop and you're golden. > > B > > On Tue, Aug 1, 2017 at 7:15 PM, Guy Lyons < > guy.lyons@.edu > > wrote: > >> I am trying to do exactly what Annie Venien described in the original >> post using ImageJ macro language i.e. save analysis data from images >> into individual files AND also combine them into a single csv file. >> Tried all sorts of things involving strings, File.append, etc., to >> combine them into a single csv file, but can't crack it. A lot of >> people have requested advice for the same thing in various forums. >> The "Read and Write Excel" plugin adds data side-by-side, instead of >> appending it in columns. Has anyone come up with a plugin or other >> method to achieve this, either as you go during analysis of multiple >> files, or post-analysis to concatenate csv data files vertically? >> >> >> >> -- >> View this message in context: http://imagej.1557.x6.nabble. >> com/how-to-append-results-in-excel-file-tp5002126p5019149.html >> Sent 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 -- View this message in context: http://imagej.1557.x6.nabble.com/how-to-append-results-in-excel-file-tp5002126p5019151.html Sent 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 |
In reply to this post by Guy Lyons
Hi Guy,
instead of opening each single .csv file in Excel, copy & paste into one big sheet you could write a short macro to combine the .csv files into a single file. Something roughly like this: getFileList(directory) to get the list of files loop over all suitable files: str = File.openAsString(directory+filename); For the first file: File.saveString(str, path); For the subsequent files: lineOneEnd = indexOf(str, '\n'); str = substring(str, lineOneEnd+1); File.append(str, path); If you want to have a column for the name for the source file, you would have to split the string read from each file into lines lines = split(str,"\n") and for each line (except the header line), append filename + "," + line +"\n" to a String Buffer, then convert it to a string and save it once. https://imagej.nih.gov/ij/developer/macro/functions.html#String [If Excel on Windows does not like the unix-style "\n" line ending, use fromCharCode(13,10) instead] Michael ________________________________________________________________ On 02/08/2017 05:51, Guy Lyons wrote: > Thanks for the rapid reply, Brandon. I'm using Mac OsX 10.10.5, ImageJ > 2.0.0-rc-43/1.51p. The macro as it stands has over 100 lines, so I'm not > sure if it would be helpful to include it here. The macro currently is > designed to analyse the output from a Cytation 3, which takes images of cell > cultures in 3 channels from multiple areas of a culture vessel. There is a > DAPI channel and 2 nuclear antigen-specific channels, and the Cytation > software saves each channel in a separate file. Typically, 64 images are > obtained per channel for each sample. The macro first uses the DAPI channel > to create a mask to identify the nuclei and then uses a for loop to measure > the area and the integrated density for each channel of each nucleus, > writing the data for the area and each channel to a separate array, and then > finally combining the arrays using Array.show and saving it as a csv. The > macro does this for all of the Cytation 3 images in a folder. It does this > successfully and reasonably quickly, writing the data to a csv file for each > image. We (i.e. my student) then manually combine the data from the 64 csv > files by copying and pasting within Excel – a tedious task that includes the > possibility of making mistakes. > > The strategies that I have tried in order to generate a single file > (including some based on the links that you sent) by modifying the for loop > run into the problem of having to write to the Results window but also > having to "Clear Results" between analysis of channels (each channel being > recorded in a separate original file). The simplest solution for me would be > a method that combines the data of multiple csv files into a single csv file > with just one row of headers. Maybe someone out there can accept this as a > challenge? I'm sure I'm not the only one who would find it useful. > > Guy. > > > Brandon Hurr wrote >> Depends how you're doing your analysis. >> >> If you're looping through pictures in a folder then you should create a >> results table and print to that in every iteration. I typically save the >> results table to a file every loop too in case of problems. You can just >> overwrite this every iteration rather than append (writing a csv file is >> not that time consuming unless the file is huge). >> >> If you're doing something else... you'll have to spell that out and help >> us >> help you (and others). >> >> How to make a custom results table and record to it: >> http://imagej.1557.x6.nabble.com/How-to-create-a-customised-results-table-and-add-data-to-it-within-a-macro-td5000701.html >> Save that file out as csv (txt): >> http://imagej.1557.x6.nabble.com/save-results-table-as-csv-with-custom-name-td5003427.html >> >> Put that into a loop and you're golden. >> >> B >> >> On Tue, Aug 1, 2017 at 7:15 PM, Guy Lyons < > >> guy.lyons@.edu > >> > wrote: >> >>> I am trying to do exactly what Annie Venien described in the original >>> post >>> using ImageJ macro language i.e. save analysis data from images into >>> individual files AND also combine them into a single csv file. Tried all >>> sorts of things involving strings, File.append, etc., to combine them >>> into >>> a >>> single csv file, but can't crack it. A lot of people have requested >>> advice >>> for the same thing in various forums. The "Read and Write Excel" plugin >>> adds >>> data side-by-side, instead of appending it in columns. Has anyone come up >>> with a plugin or other method to achieve this, either as you go during >>> analysis of multiple files, or post-analysis to concatenate csv data >>> files >>> vertically? >>> >>> >>> >>> -- >>> View this message in context: http://imagej.1557.x6.nabble. >>> com/how-to-append-results-in-excel-file-tp5002126p5019149.html >>> Sent 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 > > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/how-to-append-results-in-excel-file-tp5002126p5019151.html > Sent 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 |
Thanks for the suggestions, Kees and Michael. I'll give them a go.
|
In reply to this post by Michael Schmid
Hi Michael,
Thank you so much for your suggestions. I finally got back to this and here is what I came up with: a macro (csv_Combiner1) that simply combines cvs files, and another (csv_Combiner2) that combines them and adds a column with the name of the file that
the row data were derived from. For the latter, I went with a strategy that uses "replace", rather than “split”. I don’t know if they are the most efficient scripts, but they work for me.
I can add them to the nabble thread, but can you suggest a curated repository that I can add them to, so that other ImageJ users might be able to find and access them easily by browsing or searching?
Best regards,
Guy
__________________________________________________________________
J. Guy Lyons, PhD
Senior Hospital Scientist, Cancer Services, ROYAL PRINCE ALFRED HOSPITAL
Assoc. Professor, Dermatology, Sydney Medical School, UNIVERSITY OF SYDNEY
Visiting Researcher, Immune Imaging, CENTENARY INSTITUTE
Building 93, RPA Hospital, Missenden Rd, Camperdown, NSW 2050 Australia
Tel +61 2 9565 6127 | Mob +61 4
3766 0395
E-mail: [hidden email]
__________________________________________________________________
From: "Michael Schmid-3 [via ImageJ]" <[hidden email]>
Date: Wednesday, 2 August 2017 6:33 pm To: Guy Lyons <[hidden email]> Subject: Re: how to append results in excel file Hi Guy,
instead of opening each single .csv file in Excel, copy & paste into one big sheet you could write a short macro to combine the .csv files into a single file. Something roughly like this: getFileList(directory) to get the list of files loop over all suitable files: str = File.openAsString(directory+filename); For the first file: File.saveString(str, path); For the subsequent files: lineOneEnd = indexOf(str, '\n'); str = substring(str, lineOneEnd+1); File.append(str, path); If you want to have a column for the name for the source file, you would have to split the string read from each file into lines lines = split(str,"\n") and for each line (except the header line), append filename + "," + line +"\n" to a String Buffer, then convert it to a string and save it once. https://imagej.nih.gov/ij/developer/macro/functions.html#String [If Excel on Windows does not like the unix-style "\n" line ending, use fromCharCode(13,10) instead] Michael ________________________________________________________________ On 02/08/2017 05:51, Guy Lyons wrote: > Thanks for the rapid reply, Brandon. I'm using Mac OsX 10.10.5, ImageJ > 2.0.0-rc-43/1.51p. The macro as it stands has over 100 lines, so I'm not > sure if it would be helpful to include it here. The macro currently is > designed to analyse the output from a Cytation 3, which takes images of cell > cultures in 3 channels from multiple areas of a culture vessel. There is a > DAPI channel and 2 nuclear antigen-specific channels, and the Cytation > software saves each channel in a separate file. Typically, 64 images are > obtained per channel for each sample. The macro first uses the DAPI channel > to create a mask to identify the nuclei and then uses a for loop to measure > the area and the integrated density for each channel of each nucleus, > writing the data for the area and each channel to a separate array, and then > finally combining the arrays using Array.show and saving it as a csv. The > macro does this for all of the Cytation 3 images in a folder. It does this > successfully and reasonably quickly, writing the data to a csv file for each > image. We (i.e. my student) then manually combine the data from the 64 csv > files by copying and pasting within Excel – a tedious task that includes the > possibility of making mistakes. > > The strategies that I have tried in order to generate a single file > (including some based on the links that you sent) by modifying the for loop > run into the problem of having to write to the Results window but also > having to "Clear Results" between analysis of channels (each channel being > recorded in a separate original file). The simplest solution for me would be > a method that combines the data of multiple csv files into a single csv file > with just one row of headers. Maybe someone out there can accept this as a > challenge? I'm sure I'm not the only one who would find it useful. > > Guy. > > > Brandon Hurr wrote >> Depends how you're doing your analysis. >> >> If you're looping through pictures in a folder then you should create a >> results table and print to that in every iteration. I typically save the >> results table to a file every loop too in case of problems. You can just >> overwrite this every iteration rather than append (writing a csv file is >> not that time consuming unless the file is huge). >> >> If you're doing something else... you'll have to spell that out and help >> us >> help you (and others). >> >> How to make a custom results table and record to it: >> http://imagej.1557.x6.nabble.com/How-to-create-a-customised-results-table-and-add-data-to-it-within-a-macro-td5000701.html >> Save that file out as csv (txt): >> http://imagej.1557.x6.nabble.com/save-results-table-as-csv-with-custom-name-td5003427.html >> >> Put that into a loop and you're golden. >> >> B >> >> On Tue, Aug 1, 2017 at 7:15 PM, Guy Lyons < > >> guy.lyons@.edu > >> > wrote: >> >>> I am trying to do exactly what Annie Venien described in the original >>> post >>> using ImageJ macro language i.e. save analysis data from images into >>> individual files AND also combine them into a single csv file. Tried all >>> sorts of things involving strings, File.append, etc., to combine them >>> into >>> a >>> single csv file, but can't crack it. A lot of people have requested >>> advice >>> for the same thing in various forums. The "Read and Write Excel" plugin >>> adds >>> data side-by-side, instead of appending it in columns. Has anyone come up >>> with a plugin or other method to achieve this, either as you go during >>> analysis of multiple files, or post-analysis to concatenate csv data >>> files >>> vertically? >>> >>> >>> >>> -- >>> View this message in context: http://imagej.1557.x6.nabble. >>> com/how-to-append-results-in-excel-file-tp5002126p5019149.html >>> Sent 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 > > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/how-to-append-results-in-excel-file-tp5002126p5019151.html > Sent 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 If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/how-to-append-results-in-excel-file-tp5002126p5019153.html |
Free forum by Nabble | Edit this page |