Skip to content

Commit

Permalink
Condition on decrop is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
clementpoiret committed Sep 1, 2021
1 parent 62b733e commit 44f7548
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ROILoc"
version = "0.2.2"
version = "0.2.3"
description = "A simple package to center and crop T1w & T2w MRIs around a given region of interest by its name."
license = "MIT"
readme = "README.rst"
Expand Down
15 changes: 11 additions & 4 deletions roiloc/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,26 @@ def fit_transform(self, image: ANTsImage) -> list:
self.fit(image)
return self.transform(image)

def inverse_transform(self, image: ANTsImage) -> ANTsImage:
def inverse_transform(self,
image: ANTsImage,
decrop_is_zero: bool = True) -> ANTsImage:
"""Inverse transform the image to the native space.
Args:
image (ANTsImage): Image to inverse transform.
decrop_is_zero (bool, optional): Whether to decrop the image with
zeros or original tissue. Defaults to True.
Returns:
ANTsImage: Inverse transformed image.
"""
empty_image = self._image.new_image_like(
np.zeros_like(self._image.numpy()))
if decrop_is_zero:
reference = self._image.new_image_like(
np.zeros_like(self._image.numpy()))
else:
reference = self._image

return ants.decrop_image(image, empty_image)
return ants.decrop_image(image, reference)


def test():
Expand Down

0 comments on commit 44f7548

Please sign in to comment.