cwmok / C2FViT

This is the official Pytorch implementation of "Affine Medical Image Registration with Coarse-to-Fine Vision Transformer" (CVPR 2022), written by Tony C. W. Mok and Albert C. S. Chung.
MIT License
131 stars 3 forks source link

Evaluation data calculation #19

Open AArutoria opened 3 months ago

AArutoria commented 3 months ago

Dear author, it is a great honor to read your paper, and thank you very much for making your code public. I have some questions about the code problem, and I hope you can help me to answer them. I looked at the code for test, but found that it only had the function of saving images. May I ask how the value of the evaluation index in the paper is calculated? Is this done through external software?

cwmok commented 3 months ago

Hi @AArutoria ,

Thanks for your interest in our work. We didn't release the evaluation script. But the computation of Dice score is provided as follows:

def dice(im1, atlas):
    unique_class = np.unique(atlas)
    dice = 0
    num_count = 0
    for i in unique_class:
        if (i == 0) or ((im1 == i).sum() == 0) or ((atlas == i).sum() == 0):
            continue

        sub_dice = np.sum(atlas[im1 == i] == i) * 2.0 / (np.sum(im1 == i) + np.sum(atlas == i))
        dice += sub_dice
        num_count += 1
    return dice / num_count

The evaluation was done with Python script using numpy and pytorch.