Skip to content

Commit

Permalink
rename functions to to_sitk, from_sitk
Browse files Browse the repository at this point in the history
  • Loading branch information
dyollb committed Nov 16, 2024
1 parent 7d743fd commit 03f9922
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ants/utils/sitk_to_ants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import ants


def image_to_ants(sitk_image: "SimpleITK.Image") -> ants.ANTsImage:
def from_sitk(sitk_image: "SimpleITK.Image") -> ants.ANTsImage:
"""
Converts a given SimpleITK image into an ANTsPy image
Expand Down Expand Up @@ -38,7 +38,7 @@ def image_to_ants(sitk_image: "SimpleITK.Image") -> ants.ANTsImage:
return ants_img


def image_from_ants(ants_image: ants.ANTsImage) -> "SimpleITK.Image":
def to_sitk(ants_image: ants.ANTsImage) -> "SimpleITK.Image":
"""
Converts a given ANTsPy image into an SimpleITK image
Expand Down
12 changes: 6 additions & 6 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,10 +1011,10 @@ def setUp(self):
def tearDown(self):
pass

def test_image_to_ants(self):
from ants.utils.sitk_to_ants import image_to_ants
def test_from_sitk(self):
from ants.utils.sitk_to_ants import from_sitk

ants_img = image_to_ants(self.img)
ants_img = from_sitk(self.img)

with TemporaryDirectory() as temp_dir:
temp_fpath = os.path.join(temp_dir, "img.nrrd")
Expand All @@ -1028,15 +1028,15 @@ def test_image_to_ants(self):
nptest.assert_almost_equal(self.img.GetSpacing(), img.GetSpacing())
nptest.assert_almost_equal(self.img.GetDirection(), img.GetDirection())

def test_image_from_ants(self):
from ants.utils.sitk_to_ants import image_from_ants
def test_ito_sitk(self):
from ants.utils.sitk_to_ants import to_sitk

with TemporaryDirectory() as temp_dir:
temp_fpath = os.path.join(temp_dir, "img.nrrd")
sitk.WriteImage(self.img, temp_fpath)
ants_img = ants.image_read(temp_fpath)

img = image_from_ants(ants_img)
img = to_sitk(ants_img)

nptest.assert_equal(
sitk.GetArrayViewFromImage(self.img), sitk.GetArrayViewFromImage(img)
Expand Down

0 comments on commit 03f9922

Please sign in to comment.