Improve Performance of Resolving Transcript Based Segmentations #197
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Two issues with the
solve_conflicts
method I noticed:I've noticed that resolving
baysor
patches has an ETA of 14 hours in my usage.The method
solve_conflicts
merges overlapping segments only between patches, but this still means the number of overlaps is quadratic with the number of patches. I get something like 9 million overlaps, and the iteration of each geometry pair takes forever.People will have to set a small patch size for baysor because it takes for some reason huge amounts of memory and time to run on larger patches. With 500 micron patches even it can take many hours for each patch. So I assume I won't be the only person to run into this.
I don't think that in the context of baysor merging overlapping segments from different patches is really appropriate. I feel like this would create edge effects. It may be appropriate for the imaging based methods, I'm not sure.
Previously in my work with baysor I have simply only kept the segments that are closest to the centroid of the patch to which they belong. This essentially splits the overlap regions in half and keeps the segments that are furthest from the edge. This has the benefit of being extremely computationally fast and eliminates the potential for edge effects assuming the overlap size is big enough.
In this PR I use this method in
solve_conflicts
if possible. After it runs any remaining overlapping segments will be merged in the previous way.