【深度学习】【文献阅读】医学图像分割中的loss函数选择-Loss odyssey in medical image segmentation loss

参考文献:Loss odyssey in medical image segmentation loss

文献对应的开源代码库 github-SegLoss

摘要

本文在四个典型的三维分割任务上对20个一般的损失函数进行了首次大规模的分析,涉及10多个医疗中心的六个公共数据集。结果显示,没有一个损失函数能在四个分割任务上持续取得最佳性能,但复合损失函数(如Dice with TopK loss, focal loss, Hausdorff distance loss,和 boundary loss)是最稳健的损失

正文


Recently, cross entropy and Dice loss have become the most commonly used loss functions in medical image segmentation tasks (Milletari et al., 2016). For example, in the proceedings of MICCAI 2018, 47 out of 77 CNN-based segmentation papers (Bertels et al., 2019) chose cross entropy loss as their target loss. Dice loss has been widely used in many top solutions of medical image segmentation challenges (Bernard et al., 2018; Bakas et al., 2018). In addition to cross entropy and Dice loss, more than 10 loss functions have been proposed for segmentation CNNs. Most of them are designed to address the class imbalance problem, which is one of the main challenges when the object to be segmented is small relative to the size of the image volume, for example the segmentation of tumors or small organs.

最近,交叉熵和Dice损失已经成为医学图像分割任务中最常用的损失函数(Milletari等人,2016)。例如,在MICCAI 2018的论文集中,77篇基于CNN的分割论文中,有47篇(Bertels等人,2019)选择交叉熵损失作为他们的目标损失。骰子损失已被广泛用于医学图像分割挑战的许多顶级解决方案中(Bernard等人,2018;Bakas等人,2018)。除了交叉熵和Dice损失外,还有10多个损失函数被提出用于分割CNN。其中大多数是为了解决类的不平衡问题,当需要分割的对象相对于图像体积的大小较小时,这是主要的挑战之一,例如肿瘤或小器官的分割。
在这里插入图片描述
In this paper, we focus on the plug-and-play loss functions that can be used in any segmentation tasks,
本文中,我们专注于可用于任何分割任务的即插即用的损失函数

一、基于分布的损失函数

旨在最小化两个分布之间的不相似性。这一类中最基本的函数是交叉熵;所有其他函数都是由交叉熵衍生出来的。
1、交叉熵 CE 在这里插入图片描述
加权的交叉熵 WCE 在这里插入图片描述

2、TopK loss
3、Focal los 在这里插入图片描述

调整了标准的交叉熵,减少分配给分类良好的例子的损失来关注困难的例子,这也可以处理前景与背景类不平衡的问题。
4、基于距离图罚项的交叉熵 DPCE 在这里插入图片描述

二、基于区域的损失函数

旨在最小化不匹配,或最大化真实标签G和预测分割S之间的重叠区域。
1、敏感度-特异性loss
通过提高特异性的权重来解决类不平衡的问题
2、Dice loss 在这里插入图片描述
与加权交叉熵不同,Dice损失不需要对不平衡的分割任务进行类别重新加权。
3、IoU (Jaccard) loss
基于交并比的损失,与Dice loss类似。
4、Lovász loss
5、Tversky loss
为了在精度和召回率之间实现更好的权衡,Tversky损失调整了Dice损失以强调假阴性。
6、广义Dice loss 在这里插入图片描述
广义Dice损失是Dice损失的多类扩展,其中每个类别的权重与标签频率成反比。
7、Focal Tversky loss
8、非对称相似性损失 Asymmetric similarity loss 在这里插入图片描述
引入一个加权参数β来更好地调整FPs和FNs的权重,并实现精度和召回率之间的更好平衡。
9、**Penalty loss
引入非负的惩罚系数k。**当k=0时,pGD等同于广义的Dice。当k>0时,pGD对假阳性和假阴性给予额外的权重。

三、基于边界的损失函数

1、边界损失 BD loss
有两种不同的框架来计算两个边界之间的距离。一个是差分框架,它将边界曲线上每一个点的运动计算为沿曲线的法线的速度。另一个是积分框架,通过计算两个边界不匹配区域的界面上的积分来近似计算距离。
2、Hausdorff距离(HD)损失
Hausdorff距离是一个基于边界的指标,被广泛用于评估分割方法。然而,在训练过程中直接最小化HD是难以实现的,并可能导致不稳定的训练。为了解决这个问题,HD可以通过距离变换来近似。距离变换计算的是每个像素与物体边界之间的最短距离。需要注意的是,边界损失和Hausdorff距离损失在被用于训练神经网络时,都应该与基于区域的损失(如Dice损失)相配合,以减少训练的不稳定性。

四、混合的损失函数

1、**Combo损失
在这里插入图片描述

交叉熵和Dice loss的总和**
2、指数对数损失(ELL) 在这里插入图片描述
为了解决目标大小极不平衡的问题,对Dice损失和交叉熵损失都进行指数和对数转换,迫使网络内在地更多地关注不太准确的预测结构。
3、Dice loss 结合 focal loss
在这里插入图片描述
缓解不平衡的器官分割问题,迫使模型更好地从分割不好的图片学习
4、Dice loss结合TopK loss 在这里插入图片描述
用于多发性硬化症的自动容积评估
5、超越即插即用的损失函数:量身定做的损失
除了上述可用于任何分割任务的即插即用的损失函数外,还有一些为特殊分割任务量身定做的损失函数。超出了本文的讨论范围。

五、训练说明

Data augmentation: To avoid overfitting, data augmentation methods are applied on the fly during training, including randomly mirroring along all axes, random cropping, scaling, rotation and deformation, and gamma transformation. In addition, oversampling of foreground regions is employed to eliminate the label imbalance. Specifically, 33% of the samples in a minibatch are guaranteed to contain at least one of the foreground classes.
数据扩增。为了避免过度拟合,在训练过程中采用了数据增强的方法,**包括沿所有轴线的随机镜像、随机裁剪、缩放、旋转和变形以及伽玛变换。此外,还采用了对前景区域的过度取样来消除标签的不平衡性。**具体来说,在一个mini batch中,33%的样本保证至少包含一个前景类别。

Optimization: All the losses are minimized by stochastic descent with the Adam optimizer (Kingma and Ba, 2015) (β1=0.9, β2=0.999) and a mini-batch size of 2. The training process takes up to 10 00 epochs, where one epoch is defined as the iteration over 250 training batches. Whenever the moving average of the training loss does not improve for 50 epochs, the learning rate is reduced by multiplying it with 0.2 until a minimum learning rate of 1e-6 has been reached.
优化。所有的损失都通过**Adam优化器(β1=0.9,β2=0.999)的随机下降法和mini batch进行最小化。**训练过程需要10 00个epochs,其中一个历时被定义为250个训练批的迭代。每当训练损失的移动平均数在50个历时中没有改善,学习率就会通过乘以0.2来降低,直到达到最小学习率1e-6。

在这里插入图片描述
此外,三个损失函数在训练期间需要额外的调度策略,包括Lov ́ asz损失、边界损失和Hausdorff距离损失。
对于Lov ́ asz损失建议先用交叉熵进行优化,然后用Lov ́ asz损失进行微调。
边界损失和Hausdorff距离损失应与Dice损失相结合,具体如下。L = αLDice + βL(-),其中α,β > 0是一个权重超参数,(-)表示边界损失或Hausdorff距离损失。
对于边界损失,建议使用Dice损失来主导初始训练,以便稳定训练过程,快速获得合理的初始分割结果。具体来说,最初设定权重β=1-α,α=1,在每个epoch后将α减少0.01,直到达到0.01的值。
对于Hausdorff距离损失,设定α为基于HD的损失项的平均值与DSC损失项的平均值之比,β=1。最近的一项实证研究表明,实施细节会导致对性能的明显影响。
在我们的实验中,首先用Dice损失来训练网络,然后用建议的调度策略对BD损失和HD损失进行微调,因为我们发现这种训练技巧可以获得稳健的训练过程,也可以得到最好的性能。
其他17个损失函数都可以以即插即用的方式使用,在训练过程中不需要任何特定的调度技巧。

六、实验效果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

轻度不平衡的任务:
在肝脏分割数据集上对它们进行了评估。大多数损失函数(17/20)获得了高度准确的结果,DSC高于0.90。DiceTopK损失获得了最好的DSC和NSD,而pGDice损失获得了最低的DSC,TopK损失在DSC和NSD上都获得了最低的性能。
进一步分析显示,pGDice损失和TopK损失往往会产生过度分割的结果。可能的原因是这两个损失函数是为高度不平衡的分割任务设计的,当它们被应用于更平衡的任务时,会导致对前景的偏见。

高度不平衡的任务:
DiceHD损失获得了最好的DSC,DiceBD损失和DiceHD损失获得了最好的NSD,而加权交叉熵获得的DSC和NSD较差。
需要注意的是,一些为高度不平衡问题设计的损失函数(如Dice loss、DiceFocal loss、Tversky loss和Asym loss)并没有取得最好的性能,但它们与表现最好的损失函数相比较,差距很小。然而,其他一些损失函数(如Focal loss、pGDice、SS loss、WCE)在这个任务上没有取得令人满意的性能。大多数损失函数的DSC值具有双峰分布,模式接近0.8和0.1。换句话说,分割结果是两极化的,有些肿瘤的分割结果相对较好,而有些则非常差。这是因为肿瘤的外观、位置、形状和大小各不相同。具有均匀外观的较大肿瘤的DSC达到了0.85,而小肿瘤只有一小部分被分割出来。

轻度和高度不平衡标签的多类分割:
在包含8个标签的多器官数据集上评估了这20个损失函数。一些器官,如肝脏和胃,占据了很大的体积,而其他一些器官,如胆囊和食道,则小得多。
DiceHD损失和DiceTopK损失获得了最好的NSD,而DiceFocal损失、DiceCE损失和DiceTopK损失获得了最好的DSC。GDice损失获得了最低的DSC和NSD,其变体pGDice损失也是如此。
一些损失函数(如Asym损失和FocalTversky损失)在二元分割任务中获得了与表现最好的损失函数相当的结果,差距很小,但在标签有各种不平衡的多器官分割中存在较大差距。DiceCE损失产生了相当准确的结果,而WCE的结果包括一些孤立的异常值。

Different variants of Dice loss
There are two different variants of Dice Loss (with and without squared terms in the denominator) as introduced in Section 2.2.2. Moreover, there are also two different implementations of Dice loss: sample Dice and batch Dice. Specifically, sample Dice computes the Dice loss for each sample in the minibatch independently and averages across the minibatch. Batch Dice treats the minibatch as a pseudo-volume and computes the Dice loss as if all voxels in the samples belonged to one training case (Isensee et al., 2021). Thus, there are in total four different Dice loss variants with the combination between w/wo squared terms and sample/batch Dice12 . We compare the four Dice loss variants on four segmentation tasks where only plain Dice losses are used (without cross entropy). Table 4 presents the quantitative results. Overall the default setting achieved the best average DSC and NSD. BatchSquareDice loss outperformed the default Dice loss in liver segmentation tasks, but the improvements were marginal. SampleSquareDice achieved slightly better NSD and DSC than the default Dice loss in liver tumor and pancreas segmentation tasks, respectively, while the average DSC and NSD were inferior than Dice loss.
Dice loss有两种不同的变体(分母中含有和不含有平方项)。
此外,也有两种不同的Dice loss实现方式:样本Dice和批量Dice。具体来说,样本Dice对mini batch中的每个样本独立计算Dice损失,并对mini batch进行平均。批量Dice将minibatch视为一个伪体积,并计算Dice损失,好像样本中的所有体素都属于一个训练案例(Isensee等人,2021)。因此,总共有四种不同的Dice损失变体,它们是w/wo平方项和样本/批次Dice12的组合。
我们在四个分割任务上比较了这四种Dice损失变体,**其中只使用了普通Dice损失(没有交叉熵)。总的来说,默认设置取得了最佳的平均DSC和NSD。**在肝脏分割任务中,BatchSquareDice损失的表现优于默认的Dice损失,但改进幅度很小。在肝脏肿瘤和胰腺分割任务中,SampleSquareDice的NSD和DSC分别比默认的Dice损失略好。

In contrast, IoU loss and Dice loss drop three and nine places, respectively. In general, Dice-related compound losses are relatively robust, which have the best performance with all metrics in different ranking schemes.
**总的来说,与Dice有关的复合损失是相对稳健的,**在不同的排名方案中,它们在所有的指标上都有最好的表现。

Most of the distribution-based and region-based loss functions are the variants of cross entropy and Dice loss, respectively. Boundary-based losses are motivated by minimizing the distance between two boundaries, but we show that they have similarities to Dice loss in formulation, as both of them are computed in a region-based way, and the key difference is the way the mismatched region is weighted. Moreover, Focal loss and TopK loss follow the same goal (focus on hard training examples) but they approach it quite differently. Different loss functions may respond differently to annotation errors. Focal loss and TopK for example will focus on mislabelled pixels, potentially learning useless information from mislabelled training cases. Dice loss weights false positives and false negatives equally, while asymmetric similarity loss and Tversky loss give different weights to the false positives and false negatives, which could achieve a better balance between precision and recall. Generalised Dice (GDice) loss extends the standard Dice loss by assigning different weights to different classes. The penalized GDice further extends GDice by assigning different weights to false positives and false negatives.
大多数基于分布和基于区域的损失函数分别是交叉熵和Dice损失的变种。基于边界的损失的动机是最小化两个边界之间的距离,但我们表明它们在表述上与Dice损失有相似之处,因为它们都是以基于区域的方式计算的,关键区别在于不匹配区域的加权方式。此外,Focal loss和TopK loss遵循相同的目标(专注于困难的训练例子),但它们的方法却截然不同。不同的损失函数可能对注释错误有不同的反应。例如,Focal loss和TopK会关注误标的像素,可能会从误标的训练案例中学习无用的信息。Dice损失对假阳性和假阴性的权重相同,而不对称相似性损失和Tversky损失对假阳性和假阴性的权重不同,这可以在精确度和召回率之间取得更好的平衡。广义Dice(GDice)损失通过给不同的类别分配不同的权重,扩展了标准Dice损失。惩罚性的GDice通过给假阳性和假阴性分配不同的权重,进一步扩展了GDice。

Recommendations for choosing loss functions: With 20 loss functions to choose from, it is important but hard to identify the one to try first when we deal with a new segmentation task. However, our results show that for the QUESTION: which loss function should we choose for medical image segmentation tasks? The ANSWER could be that, overall, using Dice-related compound loss functions is a better choice.
关于选择损失函数的建议。有20个损失函数可供选择,当我们处理一个新的分割任务时,确定首先尝试的函数是很重要的,但很难。然而,我们的结果表明,对于问题:我们应该为医学图像分割任务选择哪个损失函数?答案可能是,总的来说,使用与Dice有关的复合损失函数是一个更好的选择。

  • 4
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值