yhygao / CBIM-Medical-Image-Segmentation

A PyTorch framework for medical image segmentation
Apache License 2.0
260 stars 46 forks source link

代码中求均值和标准差的方式 #5

Closed 675492062 closed 2 years ago

675492062 commented 2 years ago
with open('exp/exp_%s/%s.txt' % (args.dataset, args.unique_name), 'w') as f:
    f.write('Dice     HD    ASD\n')
    for i in range(args.k_fold):
        f.write(str(Dice_list[i]) + str(HD_list[i]) + str(ASD_list[i]) + '\n')

    total_Dice = np.vstack(Dice_list)
    total_HD = np.vstack(HD_list)
    total_ASD = np.vstack(ASD_list)

    **f.write('avg Dice:' + str(np.mean(total_Dice, axis=0)) + ' std Dice:' + str(
        np.std(total_Dice, axis=0)) + ' mean:' + str(total_Dice.mean()) + ' std:' + str(
        np.mean(total_Dice, axis=1).std()) + '\n')
    f.write(
        'avg HD:' + str(np.mean(total_HD, axis=0)) + ' std HD:' + str(np.std(total_HD, axis=0)) + ' mean:' + str(
            total_HD.mean()) + ' std:' + str(np.mean(total_HD, axis=1).std()) + '\n')
    f.write('avg ASD:' + str(np.mean(total_ASD, axis=0)) + ' std ASD:' + str(
        np.std(total_ASD, axis=0)) + ' mean:' + str(total_ASD.mean()) + ' std:' + str(
        np.mean(total_ASD, axis=1).std()) + '\n')**

---------------------------------one result-(ACDC, 3 classes, 5-fold cross validation)------------------------------------- Dice HD ASD [0.8989825 0.88934495 0.95528512][7.37562663 1.95534587 2.56416565][0.38804081 0.15725263 0.15678071] [0.87789556 0.88299032 0.93068331][8.3865384 3.03664405 3.89976089][0.39955415 0.18514004 0.20012759] [0.88114764 0.88519078 0.94220278][12.51135491 3.11411521 2.81922055][0.32309491 0.18445619 0.15274397] [0.89216353 0.87782188 0.93736269][5.82227898 3.32463123 4.68759254][0.38424565 0.19442972 0.16922716] [0.85803481 0.8611997 0.9060287 ][8.70519859 7.42175177 8.22716422][0.46205606 0.29103419 0.32277852] avg Dice:[0.88164481 0.87930952 0.93431252] std Dice:[0.01402123 0.00978801 0.01627609] mean:0.898422283778588 std:0.012973181725322086 avg HD:[8.5601995 3.77049763 4.43958077] std HD:[2.21640401 1.88651046 2.04163919] mean:5.590092632207561 std:1.4514267131357348 avg ASD:[0.39139831 0.20246255 0.20033159] std ASD:[0.04424211 0.04599499 0.06343822] mean:0.2647308186074508 std:0.04898671094632212 这里的均值应该没有问题,可以分步,但是标准差不是这样求的吧,你这里求的是5个子集均值之后的标准差,真实的标准差应该保持每个验证样本的性能指标,然后才能统计出真实的标准差。不知道我理解是否有误?

yhygao commented 2 years ago

你说的有一定道理,我这里的方法是求五折之间的标准差,是以每折为单位算的。你的算法是以每个case为单位算的,我后面考虑改成以每个case算。

675492062 commented 2 years ago

感谢作者的回复