Skip to content

Commit b588e0d

Browse files
fix: change warning logs to debug for bounds checking in CellMapImage
1 parent c3bde75 commit b588e0d

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/cellmap_data/image.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,22 @@ def __getitem__(self, center: Mapping[str, float]) -> torch.Tensor:
104104
# This eliminates repeated coordinate grid generation
105105
coords = {c: self.coord_offsets[c] + center[c] for c in self.axes}
106106

107-
# Bounds checking
107+
# Bounds checking: warn when crop edges extend beyond the
108+
# annotation bounding box. This is normal and handled by
109+
# padding when the crop window is larger than the annotation
110+
# volume, so log at DEBUG to avoid noise during training.
108111
for c in self.axes:
109112
if center[c] - self.output_size[c] / 2 < self.bounding_box[c][0]:
110-
logger.warning(
111-
f"Center {center[c]} is out of bounds for axis {c} in image {self.path}. {center[c] - self.output_size[c] / 2} would be less than {self.bounding_box[c][0]}"
113+
logger.debug(
114+
f"Crop edge for axis {c} in image {self.path} extends "
115+
f"below annotation bounds: {center[c] - self.output_size[c] / 2} "
116+
f"< {self.bounding_box[c][0]} (center={center[c]})"
112117
)
113118
if center[c] + self.output_size[c] / 2 > self.bounding_box[c][1]:
114-
logger.warning(
115-
f"Center {center[c]} is out of bounds for axis {c} in image {self.path}. {center[c] + self.output_size[c] / 2} would be greater than {self.bounding_box[c][1]}"
119+
logger.debug(
120+
f"Crop edge for axis {c} in image {self.path} extends "
121+
f"above annotation bounds: {center[c] + self.output_size[c] / 2} "
122+
f"> {self.bounding_box[c][1]} (center={center[c]})"
116123
)
117124

118125
# Apply any spatial transformations to the coordinates and return the image data as a PyTorch tensor

0 commit comments

Comments
 (0)