Skip to content

RandCropByPosNegLabel: Random location #1789

Closed

Description

@lukasfolle

Is your feature request related to a problem? Please describe.
I noticed that RandCropByPosNegLabel always crops objects with the foreground pixels being in the center.

Describe the solution you'd like
To get more variance into this transformation, I think it would be nice to have a flag indicating that the foreground voxel has not to be sampled in a centered way, but randomly in the patch. Especially for segmentation task with very few foreground voxels this would make sense IMO.

I am not entirely sure how that would affect model experiements but I would like to find out in case this gets implemented.
BTW: I absolutely love the functionality that this transformation already has!

Activity

  1. Nic-Ma commented on Mar 18, 2021

    @Nic-Ma
    Contributor

    Hi @lukasfolle ,

    Thanks for raising this up.
    Actually, we have a duplicated ticket: #586
    Could you please help submit a PR for this new transform if you are interested?

    Thanks.

  2. wyli commented on Mar 18, 2021

    @wyli
    Contributor

    i think this could be achieved by providing a dilated version of the original foreground as the sampling candidate locations (label_key). it’s slightly different from #586

  3. lukasfolle commented on Mar 18, 2021

    @lukasfolle
    Author

    @wyli Could you elaborate on "dilated version of the original foreground as the sampling candidate locations"?

    I had the following in mind:

    1. Get foreground indices like before
    2. Create a region around the foreground indices such that every valid crop yields a least one foreground index
    3. Randomly sample the region

    Please let me know what you think of this proposal.

  4. wyli commented on Mar 18, 2021

    @wyli
    Contributor

    yes, to achieve the same without modifying the transform:

    1. dilate the foreground by k voxels and put it into the data dict with "label_dilated" key
    2. invoke RandCropByPosNegLabel (label_key="label_dilated", spatial_size=2*k, ...)
  5. lukasfolle commented on Mar 18, 2021

    @lukasfolle
    Author

    I agree on 1., but why should the spatial_size be changed in any way? If we choose k appropriately (depending on foregorund extent), shouldn´t the spatial_size be kept the same?

  6. wyli commented on Mar 18, 2021

    @wyli
    Contributor

    sure, dilation k and spatial size are free parameters here, I just wanted to set them in this particular relation so that the sampling roughly achieves "not to be sampled in a centered way, but randomly in the patch."

  7. lukasfolle commented on Mar 18, 2021

    @lukasfolle
    Author

    @wyli Do you have some code working already?

  8. locked and limited conversation to collaborators on Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions