CaraNet icon indicating copy to clipboard operation
CaraNet copied to clipboard

dice_average.m and compute size of polyp

Open hybdxxw opened this issue 3 years ago • 6 comments

Hi, I wonder to know how can I use the dice_average.m to compute the relationship between dice and the size of polyps. I'm not familiar with matalab , but dice_average.m seems only has a defined function ,I try to call this function in main.m files, but failed. Besides, I also curious about how did you compute the ratio of polyps , does the x axis 0,1,2,3,4,5,6 means the relative size ?

hybdxxw avatar Nov 09 '21 02:11 hybdxxw

Hi! How did you use the function, and what errors have you got? Please carefully read the annotations in the code. Note: the arrays AreaR and Dice should have the same length. For i-th case, AreaR(i) is the area ratio (see code comments for its computation) of objects in the image of i-th segmented ground truth (the binary label), Dice(i) is the Dice coefficient computed by using the i-th predicted segmentation result and its ground truth. bin_width depends on the distribution of AreaR.

To your second question, yes, the x-axis means the relative size = # of pixels of polyp / # of total pixels of the image.

ShuyueG avatar Nov 09 '21 04:11 ShuyueG

Thanks for the reply. I add these code into main.m , there are no errors, but the generated pic is just one straight line [AreaR]=deal(zeros(1,imgNUM)); [r,c] = size(resmap); AreaR(i) = sum(resmap(:))/(r*c); dice_average(AreaR,threshold_Dic,0.05)

I also input just AreaR,threshold_Dic in the function for a test ,but the results is the same.

hybdxxw avatar Nov 09 '21 07:11 hybdxxw

Hi, you don't need to add those code into main.m, because they are for different purposes. The matlab codes in fold eval are used to evaluate the segmentation results by 6 different measurement metrics. The dice_average are used to analyze the relationship between object size and dice accuracy.

AngeLouCN avatar Nov 09 '21 20:11 AngeLouCN

Thanks for the reply. But how can I input data and run dice_average ? For example, if I want to analyze the relationship between object size and dice accuracy in CVC-ClinicDB, does it means I need to get the dice for every picture in test dataset ,area ratio of objects in images one by one and Width of bins for taking average(bin_width depends on the distribution of AreaR, what does this means?Do I need compute or just input 0.05) ,and put them in arrays, then run dice_average in command window? Thank you very much for giving me your valuable time for these questions!

hybdxxw avatar Nov 10 '21 02:11 hybdxxw

Thanks for the reply. But how can I input data and run dice_average ? For example, if I want to analyze the relationship between object size and dice accuracy in CVC-ClinicDB, does it means I need to get the dice for every picture in test dataset ,area ratio of objects in images one by one and Width of bins for taking average --Yes, you're right.

(bin_width depends on the distribution of AreaR, what does this means?Do I need compute or just input 0.05) -- no need to compute, just try 0.05 or other values. It depends on the range or density of the AreaRatio. The bin_width plays a role like the bin width when you draw a Histogram of the AreaRatio. It groups similar area ratios together and calculates their means.

,and put them in arrays, then run dice_average in command window? -- Yes, or put it in your codes; just like other Matlab functions.

ShuyueG avatar Nov 10 '21 04:11 ShuyueG

dice average (mDice), please refer to the code from segmentation. it sums the area of intersect and union, prediction (input), label(target) in all test images. and then calculate (2 * total_intersection ) / (total_input + total_target)

https://github.com/open-mmlab/mmsegmentation/blob/master/mmseg/core/evaluation/metrics.py

#1

MELSunny avatar Feb 07 '22 19:02 MELSunny