Skip to content

Commit

Permalink
[FIX] assertion that shapes do not match
Browse files Browse the repository at this point in the history
break code run if this is raised for debugging purposes.
  • Loading branch information
sophiamaedler committed Feb 20, 2025
1 parent 0fbb146 commit 238675a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/scportrait/pipeline/segmentation/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,12 +758,11 @@ def _resolve_sharding(self, sharding_plan):
if orig_input.shape != shifted_map.shape:
Warning("Shapes do not match")
self.log("Shapes do not match")
self.log("window", window[0], window[1])
self.log("shifted_map shape:", shifted_map.shape)
self.log("orig_input shape:", orig_input.shape)
self.log(f"window: {(window[0], window[1])}")
self.log("shifted_map shape: {shifted_map.shape}")
self.log("orig_input shape: {orig_input.shape}")

# dirty fix to get this to run until we can implement a better solution
shifted_map = np.zeros(orig_input.shape)
raise ValueError("Shapes do not match. Please send this example to the developers for troubleshooting.")

# since shards are computed with overlap there potentially already exist segmentations in the selected area that we wish to keep
# if orig_input has a value that is not 0 (i.e. background) and the new map would replace this with 0 then we should keep the original value, in all other cases we should overwrite the values with the
Expand All @@ -779,7 +778,7 @@ def _resolve_sharding(self, sharding_plan):
np.unique(orig_input[np.where((orig_input != 0) & (shifted_map != 0))])
) # gets all ids that potentially need to be discarded over both masks

# we dont want to discard any ideas that touch the edge of the image
# we dont want to discard any id's' that touch the edge of the image
# for these ids we can not ensure when processing this shard that the entire cell is present in the shard
# if we would delete these ids we would potentially be deleting half of a cell
edge_labels = set(_return_edge_labels(orig_input))
Expand Down

0 comments on commit 238675a

Please sign in to comment.