Skip to content

get_mask_edges wrongly uses squeeze #4312

@yiheng-wang-nv

Description

@yiheng-wang-nv

Describe the bug
This error place is in:

seg_pred, seg_gt = np.squeeze(cropper(seg_pred)), np.squeeze(cropper(seg_gt))

To use spatial crop, a channel dimension is expanded, thus it needs to be squeezed after the transform. However, axis should be specified otherwise more than one dimensions may be squeezed. If a input tensor only has one pixel that has label, after crop and squeeze, it will has shape (), and then after binary erosion and XOR, it will has type bool, rather than an array, and may get wrong surface_distance.

To Reproduce
Steps to reproduce the behavior:

import numpy as np

print(np.squeeze(np.random.rand(1, 1, 16, 16, 16)).shape)

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions