JunMa11 / SegLossOdyssey

A collection of loss functions for medical image segmentation
Apache License 2.0
3.76k stars 597 forks source link

Some Code issues! #12

Closed Sayantan17 closed 3 years ago

Sayantan17 commented 3 years ago

Hi Jun @JunMa11

Thanks for getting time for collecting all loss functions at one place. You are.awesome.~😉

Can you please help me in understanding why you did them? (One by one). Will be great if you help.

  1. In get_tp_fp_fn function, why you did this?

Started the tuple from 2 and the next lines, I mean you checking masks are returning proper identity without squares, then can you please explain x_i * with all rows + columns of the mask?

axes = tuple(range(2, len(net_output.size()))) ...... tp = torch.stack(tuple(x_i * mask[:, 0] for x_i in torch.unbind(tp, dim=1)), dim=1)

  1. In soft dice loss, can you please explain?

if self.batch_dice: axes = [0] + list(range(2, len(shp_x))) else: axes = list(range(2, len(shp_x))) if self.apply_nonlin is not None: x = self.apply_nonlin(x)

JunMa11 commented 3 years ago

Hi @Sayantan17 ,

Thanks for your interest very much.

The code was copied from nnUNet as I mentioned in the comments. https://github.com/JunMa11/SegLoss/blob/858c27e0eda817238b827d3972c198ec68f6cebf/losses_pytorch/dice_loss.py#L2

Honestly speaking, I do not dig these details.

I think Fabian would be the best person to answer your question:) Could you please raise this issue at https://github.com/MIC-DKFZ/nnUNet?

Best, Jun

Sayantan17 commented 3 years ago

Sure. Thx. Sure thing. I will take you in a loop.