Example #1
0
    def report_scores(self, y, t):
        with chainer.no_backprop_mode():
            if self.nested_label:
                dice = mean_dice_coefficient(
                    dice_coefficient(y[:, 0:2, ...], t[:, 0, ...]))
                for i in range(1, t.shape[1]):
                    dices = dice_coefficient(y[:, 2 * i:2 * (i + 1), ...],
                                             t[:, i, ...])
                    dice = F.concat((dice, mean_dice_coefficient(dices)),
                                    axis=0)
            else:
                dice = dice_coefficient(y, t)
            mean_dice = mean_dice_coefficient(dice)

            if self.nested_label:
                b, c, h, w, d = t.shape
                y = F.reshape(y, (b, 2, h * c, w, d))
                t = F.reshape(t, (b, h * c, w, d))
            accuracy = F.accuracy(y, t)

        reporter.report({'acc': accuracy, 'mean_dc': mean_dice})
        xp = cuda.get_array_module(y)
        for i in range(len(dice)):
            if not xp.isnan(dice.data[i]):
                reporter.report({'dc_{}'.format(i): dice[i]})
Example #2
0
 def compute_dice_coef(self, y, t):
     if self.nested_label:
         dice = mean_dice_coefficient(dice_coefficient(y[:, 0:2, ...], t[:, 0, ...]))
         for i in range(1, t.shape[1]):
             dices = dice_coefficient(y[:, 2*i:2*(i+1), ...], t[:, i, ...])
             dice = F.concat((dice, mean_dice_coefficient(dices)), axis=0)
     else:
         dice = dice_coefficient(y, t, is_brats=self.is_brats)
     return dice