Skip to content

Conversation

@tkkuehn
Copy link
Collaborator

@tkkuehn tkkuehn commented Jan 11, 2023

Proposed changes

Overlay exceptions' behaviour was kind of ambiguous, so this clarifies it and adds the option to drop labels from either input map. Now overlay exceptions are overwritten by base labels, base exceptions overwrite everything else, and base/overlay drops are just removed entirely.

Types of changes

What types of changes does your code introduce? Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionalitiy)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you are unsure about any of the choices, don't hesitate to ask!

  • Changes have been tested to ensure that fix is effective or that a feature works.
  • Changes pass the unit tests
  • Code has been run through the poe quality task
  • I have included necessary documentation or comments (as necessary)
  • Any dependent changes have been merged and published

Notes

All PRs will undergo the unit testing before being reviewed. You may be requested to explain or make additional changes before the PR is accepted.

@tkkuehn tkkuehn added the enhancement New feature or request label Jan 11, 2023
Copy link
Collaborator

@kaitj kaitj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some minor concerns with how merge_labels works now if I understand it correctly, stemming from some original discussions about dropping vs overwriting labels, but I think those can be fixed down the line and not necessarily needed for this PR.

drops=overlay_drops,
)
# Note that overlay exceptions are ignored
merged_map, merged_metadata = merge_labels(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you just walk me through this? From what I gather, we are adding (in order):

overlay exceptions -> base inclusions -> overlay inclusions -> base exceptions?

I am guessing this results in some overwriting of the existing labels?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure:
split_labels considers each unique label found in a label map. If that label is in the list of drops, it is ignored. If that label is in the list of exclusions, it's split into a dataset that contains all the exclusion masks. Otherwise, it's split into a dataset that contains all the "regular" masks. (If there are no exceptions, only the dataset of "regular" masks is returned)

So, after applying split_labels to the base and overlay input label maps, we have a base dataset, an overlay dataset, and maybe a base exclusions dataset and/or overlay exclusion dataset.

We then pass a list of those datasets in the priority order you identified (overlay exceptions (if applicable) -> base regular -> overlay regular -> base exceptions (if applicable)) to merge_labels, which reindexes all the label names that show up in the datasets, and writes the masks to an output 3D array with the new indices in order, so that later datasets overwrite labels written by earlier datasets.

Copy link
Collaborator

@kaitj kaitj Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - I think there is still a potential fundamental concern about mixed labels for voxels within a region that don't overlap, but that was present prior to this. In any case, this PR looks good to merge to me.

@tkkuehn tkkuehn merged commit bdd9e81 into main Jan 11, 2023
@tkkuehn tkkuehn deleted the drops branch January 11, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants