NKI-AI / ahcore-old

Ahcore are the AI for Oncology histopathology core models
Apache License 2.0
0 stars 1 forks source link

Compute overall dice score #19

Closed AjeyPaiK closed 1 year ago

AjeyPaiK commented 1 year ago

The PR makes changes:

  1. To the way model predictions are accessed in Lightning 2.0
  2. To the way how overall dice is computed during validation
  3. Adds files to gitignore so that some private files may be maintained locally.
AjeyPaiK commented 1 year ago

Changes:

  1. Lightning has changed the way it handles prediction outputs. Attached the screenshot below. Earlier, the model outputs were automatically consumed by on_predict_epoch_end() but this behavior has changed. Now, we access them through the trainer object as shown below on the right. image So, we make this change in lit_module,

  2. For my purposes, I need to maintain additional functionalities like a tracker that can measure tumor-stroma ratio during inference which doesn't align with general ahcore functionalities. So, I added such files to gitignore. This will allow me to have them in my local repo whereas the public code neednt have it. This is reflected here.

  3. One main change that this PR makes is it adds a flag to the way we compute dice scores over the WSIs. Instead of averaging individual dice scores over the total images, we now aggregate true_positives and cardinalities across the whole validation dataset and treat them as though they originate from a single image. Thus avoiding the need to average while providing more stable DIce estimates. This is reflected here.

  4. Finally, I have refactored the trackers.py a little bit. I moved the tile iterator out of the Tracker class since it was not dependent on the class variables to function.