6699 random sort grid patch#6701
Conversation
Signed-off-by: jmnolte <[email protected]>
…te/MONAI into 6699-random-sort-GridPatch "Add random sorting option to sort_fn argument in GridPatch transform"
I, jmnolte <[email protected]>, hereby add my Signed-off-by to this commit: d1829f3 Signed-off-by: jmnolte <[email protected]>
Signed-off-by: jmnolte <[email protected]>
Signed-off-by: jmnolte <[email protected]>
Signed-off-by: jmnolte <[email protected]>
Signed-off-by: jmnolte <[email protected]>
bhashemian
left a comment
There was a problem hiding this comment.
@jmnolte Thanks for your contribution. The only downside of implementing the randomness is GridPatch is that this transform is supposed to be non-random while relying on its random counter part RandGridPatch to include randomness. Thus, I would suggest to only modify RandGridPatch for this purpose by overriding its filter_count method, handling situation with sort_fn="random", and delegating the rest to the its parent class.
def filter_count(self, image_np: NdarrayOrTensor, locations: np.ndarray) -> tuple[NdarrayOrTensor, np.ndarray]:
if self.sort_fn == GridPatchSort.RANDOM:
pass # do your logic for random sorting here
return image_np, locations
return super().filter_count(image_np, locations)|
Thanks to everyone for the reviews. As per popular request from @wyli and @drbeh, I have now adapted the random sorting option to only be implemented in the class' randomised version |
Signed-off-by: jmnolte <[email protected]>
|
Thanks for the feedback! I have now created a new |
Co-authored-by: YunLiu <[email protected]> Signed-off-by: Jakob Nolte <[email protected]>
Co-authored-by: YunLiu <[email protected]> Signed-off-by: Jakob Nolte <[email protected]>
Signed-off-by: jmnolte <[email protected]>
wyli
left a comment
There was a problem hiding this comment.
thanks, it looks good to me -- please help fix the typing error
KumoLiu
left a comment
There was a problem hiding this comment.
Thanks for the quick update, LGTM. Could you please help also update the docstring in the RandGridPatchd?
…Patch Signed-off-by: jmnolte <[email protected]>
|
I am not quite sure, what's causing the typing error. It appears that the index is of an invalid type but I don't see how the index type returned from |
|
sure, I'll have a look and trigger more tests @jmnolte. |
…dPatch Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
|
/build |
bhashemian
left a comment
There was a problem hiding this comment.
Thanks for addressing the comments. LGTM!
Description
The PR introduces a random sorting option to the
GridPatch, RandGridPatch, GridPatchd, RandGridPatchdtransforms. So far, the transforms allowed patches to be sorted according to the sum of their intensity or in their default order (i.e., sliding-window manner). With this PR, random extraction of patches as described in Myronenko et al. is enabled.Types of changes