-
Notifications
You must be signed in to change notification settings - Fork 105
Description
Just two tiny super nitpicky things you might consider.
I’d slightly change this function:
TRIDENT/trident/wsi_objects/WSIPatcher.py
Lines 343 to 348 in a6305ac
| def _prepare(self) -> None: | |
| level, _ = self.wsi.get_best_level_and_custom_downsample(self.downsample, tolerance=0.1) | |
| level_downsample = int(self.wsi.level_downsamples[level]) | |
| patch_size_level = round(self.patch_size_src / level_downsample) | |
| overlap_level = round(self.overlap_src / level_downsample) | |
| return level, patch_size_level, overlap_level |
Into something like:
def _prepare(self) -> None:
level, level_downsample = self.wsi.get_best_level_and_custom_downsample(self.downsample, tolerance=0.1)
patch_size_level = round(self.patch_size_target * level_downsample)
# overlap_level = round(self.overlap * level_downsample) # I guess this is never used
return level, patch_size_level #, overlap_levelWhy?
In cases where you bind to the nearest level, I think the patch size at that level should exactly match the desired output patch size.
Otherwise, the level patch size might be slightly smaller than the actual patch size, leading to minor resizing artefacts.
Situations when this is triggered are what I mean:
TRIDENT/trident/wsi_objects/WSI.py
Lines 607 to 609 in a6305ac
| for level, level_downsample in enumerate(level_downsamples): | |
| if abs(level_downsample - downsample) <= tolerance: | |
| return level, 1.0 # Exact match, no custom downsampling needed |
Speaking of binding — I’d probably only “push up” cases that are just below the upper-level downsample rate, for efficiency.
If the requested downsample is already above that level, I’d stay exact, since there’s no real speed gain from binding.
So maybe change this:
TRIDENT/trident/wsi_objects/WSI.py
Lines 607 to 609 in a6305ac
| for level, level_downsample in enumerate(level_downsamples): | |
| if abs(level_downsample - downsample) <= tolerance: | |
| return level, 1.0 # Exact match, no custom downsampling needed |
Into something like this:
# If the actual downsample is just below a specific level-downsample within tolerance, push to that level for efficiency
for level, level_downsample in enumerate(level_downsamples):
if 0 <= (level_downsample - downsample) <= tolerance:
return level, 1.0 # Exact match, no custom downsampling neededLet me know if you’d like me to open a PR with these changes.
I’m currently building a preprocessing pipeline myself and have been heavily inspired by your work here!