neuronflow / blob_loss

blob loss example implementation
https://arxiv.org/abs/2205.08209
MIT License
35 stars 2 forks source link

Questions about blob loss #5

Open marwanabb opened 1 month ago

marwanabb commented 1 month ago

Hi @neuronflow ,

Thank you for sharing the implementation of the blob loss.

I was wondering if the method could be applied on compound losses, such as DICE+CE. In addition, does the current code snipset provided in the repo could be interfaced easily with the MONAI training loop ?

Best, Marwan

neuronflow commented 1 month ago

@marwanabb thanks for your interest in blob loss. Yes, it can be used with compound losses both in the global, as well as in the "blob" part. I often did this when my aim was maximizing DICE or other similarity metrics.

I don't think integration in the MONAI training loop is trivial. I usually wrote my own training loop as I precomputed the blob labels by doing a CCA and then had the data loader load multiple label channels. But I'd be happy to be proven wrong here.

For evaluating your multi-instance segmentation problem, you might enjoy our new package https://github.com/BrainLesion/panoptica

marwanabb commented 1 month ago

@neuronflow Thanks for your quick reply! I'm currently focusing on treatment response assessment for hepatic metastases in radiology/oncology. Our main goal is to get robust lesion delineations using semantic segmentation models. It's quite similar to the LiTS challenge, as we're dealing with the same type of pathological tumors. For our approach, we're using MONAI to train semantic segmentation pipelines, mainly with SwinUNETR architectures and custom training loops. We're training on a combination of private hepatic metastases datasets and LiTS data. Our raw results on the test set are promising in terms of volumetric/voxel performance metrics like Dice scores. When it comes to instance detection, we're seeing few false negatives, which is good. However, we're still getting a lot of false positives, and that's a big limitation for clinical application. That's why I found your method really interesting and relevant. I think it could help us in two key ways:

  1. Potentially erasing many of the false positives we're seeing
  2. Possibly reducing our false negative rate even further

Both of these improvements would be huge steps towards making our model clinically applicable. If I understand correctly, your current implementation uses CCA to label individual blobs for each tensor (e.g., exam/CT-scan) in the data loader. I'm particularly interested in how you compute the "blob" part :

  1. Is it calculated for each connected component (e.g., lesions/tumors) within a particular tensor, maintaining the context of the same exam?
  2. Or is it computed across all possible blobs present in the data loader, treating each lesion as a separate entity regardless of which exam it's from?

I'd really appreciate hearing your insights on this. Also, thank you for bringing the instance evaluation package to my attention - it will be quite usefull in our work.

neuronflow commented 1 month ago

Ahh, I remember colleagues at TUM actually used blob loss in a MONAI training loop, but they computed the CCA for each batch again. I prefer to precompute it once, but this requires quite some modifications.

Whether blob loss will help you is, unfortunately, an empiric question.

Both options you propose to implement the blob part seem to be valid experiments?

In my case, I aggregated on a patient level (=exam level, as I had one exam per patient); I wanted to treat all patients equally, no matter whether they have few or many lesions.

marwanabb commented 1 month ago

Thank you for the feedback. It's great to hear that an attempt with MONAI was successful. I'll try to implement this on my own as well. Regarding the CCA for each batch, I understand it requires more computational resources, especially for large validation sets. If I'm interpreting correctly, in the compute_blob_loss_multi function of your implementation, the tensors grabbed (for instance located in a dedicated data loarder) for each training batch have already been 'preprocessed' for the blob part, with each lesion assigned a unique label. Is this understanding correct?

Both options are indeed valid. I was just wondering if the second option could lead to improved performance, where patients are not treated equally when aggregating loss results (i was thinking about metastatic cases where some patients present dozens or even hundreds of lesions). I guess I'll have to experiment.

aymuos15 commented 1 month ago

https://www.sciencedirect.com/science/article/pii/S0010482524004980#:~:text=Instance%20loss%20functions%20consist%20of,benefit%20from%20these%20new%20losses.

Nice paper here basically on what you guys are discussing about the compound blob loss. My own personal experiments show minor improvements as well.

marwanabb commented 1 month ago

Thanks @aymuos15 , that's exactly what I was looking for.

neuronflow commented 1 month ago

...with each lesion assigned a unique label. Is this understanding correct?

yes :)

Both options are indeed valid. I was just wondering if the second option could lead to improved performance, where patients are not treated equally when aggregating loss results (i was thinking about metastatic cases where some patients present dozens or even hundreds of lesions). I guess I'll have to experiment.

Yes, this could work. Especially for those cases with more lesions.

Once again we encourage experimenting with compound losses. Some quotes from the paper:

We propose a novel family of loss functions, blob loss, primarily aimed at maximizing instance-level detection metrics, such as F1 score and sensitivity.>

Outlook: Future research will have to reveal to which extent transformation to blob loss can be beneficial for other segmentation tasks and loss functions. A first and third place in recent public segmentation challenges using a compoundbased variant blob loss indicate that blob loss might possess broad applicability towards other instance imbalanced semantic segmentation problems.>

In the VALDO challenge I used a DICE+BCE variant.