NKI-AI / ahcore

Ahcore is the AI for Oncology core computational pathology toolkit
Apache License 2.0
15 stars 1 forks source link

Wrong initialization H5 writer Grid during validation #55

Closed EricMarcus-ai closed 7 months ago

EricMarcus-ai commented 7 months ago

Describe the bug During validation H5 writing, the writer is initialized with the first batch, and a grid is made here: https://github.com/NKI-AI/ahcore/blob/25cfc2c4d03ea351f2870288b1fba554bfd6adb8/ahcore/writers.py#L120 However, during validation, we are dealing with ROIs, and the resulting coordinates may be at an arbitrary place in the WSI. This results in a misaligned grid and patches from a subsequent ROI on the same WSI may fall outside the created grid, resulting in errors here https://github.com/NKI-AI/ahcore/blob/25cfc2c4d03ea351f2870288b1fba554bfd6adb8/ahcore/writers.py#L245 as the correct place is never found.

To Reproduce A train + validation run with the h5 writing enabled.

Expected behavior It should write a h5 (slightly) around all ROIs. The correct Grid is already available in the validation dataset.