BrainImageAnalysis / instance-loss

Official implementation of instance loss functions, a family of instance-level segmentation and detection loss functions, to improve semantic segmentation and detection of multiple instances in biomedical images
Apache License 2.0
2 stars 2 forks source link

Question about arguments class #1

Closed marwanabb closed 3 months ago

marwanabb commented 3 months ago

Hi @febrianrachmadi ,

Thank you for sharing the implementation of the instance losses.

I have a question regarding the following class arguments : image

By default num_out_chn and object_chn are set to 1 for a two-class segmentation problem (background vs foreground). But how to handle them for a multi-class problem. Let's say a three-class : background, organ and tumor. Should N equal 2 or 3 in this case ? In the notebook example you provided it's N=1 while there is two classes : background and foreground.

Moreover, the tensors are like that in my case (using MONAI data loader this configuration works well using MONAI losses) :

Could you provide more information on how to setup num_out_chn and object_chn ?

febrianrachmadi commented 3 months ago

Hi @marwanabb ,

Thanks for your question. So, the most straightforward implementation for a multi-class problem is to separate each foreground channel that you want to calculate, which reduces a multi-class problem into a two-class problem. For example, let's say you have 3 channels for background, organ, and tumor; then, you can separate and combine the background and tumor channels to calculate instance losses for the tumor class. The same approach can be used for the organ channel.

We implemented the instance losses like this because it is the most straightforward implementation, as the connected components analysis (CCA) must be done for each foreground channel anyway. Also, the benefit of this approach is that sometimes we do not need instance losses for all classes (e.g., single organs such as the heart or liver do not need instance losses), so the implementation makes it easier for a user to choose which foreground classes that need instance losses for the training.

I hope my explanation helps.

Best wishes,

Febrian

marwanabb commented 3 months ago

Thanks for the quick reply @febrianrachmadi ,

It's very clear and it makes sense now, I just have to preprocess my tensors before feeding them to the instance loss. Thanks for the feedback.