# Proper way to calculate mean Dice coefficient on a dataset

I would like to ask a question about the proper way to calculate the Dice coefficient for an image dataset. We know that the Dice coefficient is calculated via the following equation:

$$Dice = \frac{TP +TP}{TP +TP +FP +FN}$$

However, how do we calculate the mean Dice coefficient for the entire dataset ? For example, suppose we have $$N$$ images, each having size $$(H, W)$$. There might be two ways:

• We calculate the Dice coefficient for each image, and then take the average for all images

• We flatten all of them into an array of size $$N \times H \times W$$, then calculate the Dice coefficient for this array.

I do not know which way is usually used in medical image segmentation. I have tried to search for some papers, but they do not go into details about this. It would be great if someone could reference some paper about this.

• A more standard approach is first to average in each of the formula's terms. Nov 2, 2021 at 13:01
• @Alexis Yes that's right, I just grabbed a formula on the web. Nov 2, 2021 at 23:24
• Closely related: stats.stackexchange.com/questions/519508/… Nov 11, 2021 at 12:41