Exporting measurement data of multiple images to one csv or excel file

884 views
Skip to first unread message

namhi...@gmail.com

unread,
Feb 28, 2017, 12:32:49 AM2/28/17
to QuPath users

Hi,

 

Thank you for making this excellent software and sharing with us.

I believe QuPath is ideal software to analyze virtual slide images.

 

I would like to export the items in “measurement annotation” of multiple images in the same project to one csv or excel file, automatically with script. If it is possible to conduct this, could you possibly tell me the script?

For example, I would like to get the table as shown below,

Image File Name

Name

Class

ROI

Centroid X µm

Centroid Y µm

Num Tumor: 1+

Num Tumor: 2+

Num Tumor: 3+

Num Tumor: Negative

Num Stroma

Num Tumor

Tumor: Positive %

Tumor: H-score

Tumor: Allred proportion

Tumor: Allred intensity

Tumor: Allred score

Area µm^2

Perimeter µm

Max length µm

Image A

Vehicle


Polygon

4667.9

2363.6

3098

845

10824

29105

13445

43872

33.66

84.93

4

3

7

8887229.6

11123.2

4131.8

Image A

Treat


Polygon

2367.3

4954.3

2275

415

6265

15607

4048

24562

36.46

89.16

4

3

7

4408620.2

8109.1

3109.7

Image B

Vehicle


Polygon

3894.5

4438.9

4549

2580

11827

16686

2236

35642

53.18

126.79

4

3

7

4588113.6

7945.9

2772.5

Image B

Treat


Polygon

4364.1

2141.8

1984

1320

5462

7487

1069

16253

53.93

129.27

4

3

7

2057527

5718.7

2199.1

 

Unfortunately, I am unfamiliar to write programs.

It is quite helpful if you could give me your kind support.

Best,

Tadahiro Nambu

micros...@gmail.com

unread,
Feb 28, 2017, 4:57:18 PM2/28/17
to QuPath users
Afraid I do not have much useful here.  For this sort of thing I usually export all of the files individually as a simple saveAnnotationMeasurements() script across the whole project, followed by merging the files using R or Python.

namhi...@gmail.com

unread,
Mar 1, 2017, 2:46:03 PM3/1/17
to QuPath users

Thank you for your suggestion.

I will use saveAnnotationMeasurements() script.

Pete

unread,
Mar 2, 2017, 5:23:28 PM3/2/17
to QuPath users
Hi, thanks very much for your comments about QuPath.

I'm afraid I also do not have a clear answer about how best to export the annotation measurements at this point... this is something that I think is harder to do in QuPath than it should be.

Hopefully the saveAnnotationMeasurements() script command can help for now, even though you likely still need to work a bit to rearrange the output into the form you need after running it.  You also need to be extra-careful about how to enter the path in the script to make sure the results end up in the right place.  There is some information about this at the end of the discussion at https://github.com/qupath/qupath/issues/25

I don't think it's really ideal though.  I will think some more about it, and see if I can come up with a better way to do export annotation measurements across multiple images.

micros...@gmail.com

unread,
Mar 3, 2017, 4:09:41 PM3/3/17
to QuPath users
One of the problems I have run into when doing this is that QuPath doesn't, by default, "know" which columns are going to be in each data set.  For example, if one of his samples (one image) was a negative control, and simply had zero positive cells, there would be no column for positive cells at all, as opposed to a column with a zero in it.  I'm sure it isn't impossible, but I don't think there is a simple way to handle this since we can create a multitude of classes, subclasses, subcellular detections etc.  The flexibility is one of the strengths of the program, but it does require a bit of care organizing the data at the end!  
Also, creating many empty columns in some samples might not be what others would be looking for in their own projects.  I could see the desire for a unified set of output columns going either way (though I imagine it would be helpful for most).

namhi...@gmail.com

unread,
Mar 6, 2017, 2:32:32 PM3/6/17
to QuPath users
Thanks, Pete,

saveAnnotationMeasurements() s with double backslashs worked well, although it made multiple files.

Thank you very much for your advice!
Tadahiro

Adit Sanghvi

unread,
Aug 10, 2017, 2:10:29 PM8/10/17
to QuPath users
Have you come up with a better way to export annotations? I'm trying to do the exact same thing through groovy scripting.

If there's an easy way to export to a csv instead of txt I think that'll be great too

Pete

unread,
Aug 10, 2017, 9:20:55 PM8/10/17
to QuPath users
I don't have a better way... I rely a lot on Groovy scripts myself, since it allows me to be much more specific on what I want to export.  This then would also make it possible to switch to csv.

I think it is worth persisting to learn both the Groovy tricks and QuPath tricks that can help make the job easier.  If there is anything proving particularly awkward to export, then you could describe here what is needed.

As an aside, QuPath uses tab-delimited files as its default in an effort to reduce potential troubles in formatting numbers in different locations.  I don't know that it is necessarily the best way to handle this, but https://github.com/qupath/qupath/issues/29 describes some of the pain encountered in that area.

(Actually from the Wikipedia article https://en.wikipedia.org/wiki/Comma-separated_values I see that the .csv extension might still be used with tab-delimiters for this reason... so maybe just changing the extension alone helps.)

anton...@univr.it

unread,
Feb 16, 2022, 12:42:53 PM2/16/22
to QuPath users
Hi is possible to export, via scripting, each image to its .csv file maintaining the name of the image (for a project with a lot of images). Thank you very much

Pete

unread,
Feb 16, 2022, 3:52:44 PM2/16/22
to QuPath users
Hi, this Google Group is no longer maintained. The forum is now at https://forum.image.sc/tag/qupath 
Reply all
Reply to author
Forward
0 new messages