Skip to content

Commit

Permalink
fix: GridAttrs initialization and grid.center property getter
Browse files Browse the repository at this point in the history
  • Loading branch information
aschuh-hf committed Oct 18, 2024
1 parent 0cf0f15 commit 1eab935
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/deepali/utils/simpleitk/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def __init__(
if center is None:
origin = (0.0,) * ndim
else:
offset = np.array(0.5 * n if n > 0 else 0 for n in self._int_size(size))
rotation = np.array(self.direction).reshape(ndim, ndim)
offset = np.array([0.5 * n if n > 0 else 0 for n in self._int_size(size)])
rotation = np.array(direction).reshape(ndim, ndim)
scaling = np.diag(spacing)
coords: NDArray = np.asanyarray(center) - np.matmul(rotation @ scaling, offset)
origin = tuple(float(x) for x in coords)
Expand All @@ -68,7 +68,7 @@ def __init__(
@property
def center(self) -> Tuple[float, ...]:
r"""Get grid center point coordinates in world space."""
offset = np.array(0.5 * n if n > 0 else 0 for n in self.size)
offset = np.array([0.5 * n if n > 0 else 0 for n in self.size])
coords: NDArray = self.origin + np.matmul(self.transform[:-1, :-1], offset)
return tuple(float(x) for x in coords)

Expand Down

0 comments on commit 1eab935

Please sign in to comment.