Skip to content

[BUG] Bounding box size inconsistent rounding #106

Open
@IgorTatarnikov

Description

@IgorTatarnikov

A precalculated output shape is needed for rotations that use affine_transform from Dask. The calculation is currently done by transforming the corners of the volume into the new space and extracting the full size. This calculation can result in fractional sizes which are incompatible as an input to affine_transform. The function deals with this by calling np.round before converting to int. However, this function converts to the nearest even number when the provided value is exactly between two integers (x.5).

Most atlases and data shouldn't have any data in the outer most pixels, however for consistency, I think this should always return the ceiling, rather than floor or ceiling as np.round currently does.

transformed_corners = np.dot(rotation_matrix, corners.T)
min_corner = np.min(transformed_corners, axis=1)
max_corner = np.max(transformed_corners, axis=1)
return (
int(np.round(max_corner[0] - min_corner[0])),
int(np.round(max_corner[1] - min_corner[1])),
int(np.round(max_corner[2] - min_corner[2])),
)

Metadata

Metadata

Assignees

No one assigned

    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