Skip to content

Commit

Permalink
Using ants.core.ants_image.ANTsImage instead of ants.ANTsImage in…
Browse files Browse the repository at this point in the history
… case `ANTsImage` is not exported
  • Loading branch information
dipterix committed Dec 11, 2024
1 parent 3e0b7df commit e4fae0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rpyANTs
Title: An Alternative Advanced Normalization Tools ('ANTs')
Version: 0.0.3.9009
Version: 0.0.3.9010
Authors@R:
person("Zhengjia", "Wang", email = "[email protected]",
role = c("aut", "cre"))
Expand Down
4 changes: 2 additions & 2 deletions inst/rpyants/rpyants/registration/halpern.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def halpern_coregister_ct_mri(fixed_path, moving_path, outprefix, verbose=True):
# Register MRI to template for Casey Halpern's lab.
# '''
# # Make sure images are valid
# if not isinstance(fixed, ants.ANTsImage):
# if not isinstance(fixed, ants.core.ants_image.ANTsImage):
# raise Exception("`fixed` is not an instance of `ANTsImage`")
# if not isinstance(moving, ants.ANTsImage):
# if not isinstance(moving, ants.core.ants_image.ANTsImage):
# raise Exception("`moving` is not an instance of `ANTsImage`")
# # use forward slash to avoid escaping issues on windows
# outprefix = normalize_path(outprefix, sep="/")
Expand Down
10 changes: 5 additions & 5 deletions inst/rpyants/rpyants/registration/yael.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def get_template_mapping(self, template_name : str, native_type : str = "T1w", r
}
}

def transform_image_from_template(self, path : Union[str, ants.ANTsImage], template_name : str, native_type : str = "T1w", interpolator="nearestNeighbor", verbose : bool=True):
def transform_image_from_template(self, path : Union[str, ants.core.ants_image.ANTsImage], template_name : str, native_type : str = "T1w", interpolator="nearestNeighbor", verbose : bool=True):
'''
Map the image from the template to the native image.
Expand All @@ -652,7 +652,7 @@ def transform_image_from_template(self, path : Union[str, ants.ANTsImage], templ
@return: The mapped image.
@rtype: ANTsImage
'''
if isinstance(path, ants.ANTsImage):
if isinstance(path, ants.core.ants_image.ANTsImage):
moving_img = path
else:
if not os.path.exists(path):
Expand All @@ -671,7 +671,7 @@ def transform_image_from_template(self, path : Union[str, ants.ANTsImage], templ
)
return mapped_img

def transform_image_to_template(self, path : Union[str, ants.ANTsImage], template_name : str, template_path : Union[str, ants.ANTsImage], native_type : str = "T1w", interpolator="nearestNeighbor", verbose : bool=True):
def transform_image_to_template(self, path : Union[str, ants.core.ants_image.ANTsImage], template_name : str, template_path : Union[str, ants.core.ants_image.ANTsImage], native_type : str = "T1w", interpolator="nearestNeighbor", verbose : bool=True):
'''
Map the image from the native image to the template.
Expand All @@ -693,13 +693,13 @@ def transform_image_to_template(self, path : Union[str, ants.ANTsImage], templat
map_info = self.get_template_mapping(template_name = template_name, native_type = native_type)
if map_info is None:
raise FileNotFoundError(f"Missing mapping from {native_type} to {template_name}. Please register the image to the template first.")
if isinstance(path, ants.ANTsImage):
if isinstance(path, ants.core.ants_image.ANTsImage):
moving_img = path
else:
if not os.path.exists(path):
raise FileNotFoundError(f"Invalid image path: {path}")
moving_img = ants.image_read(path)
if isinstance(template_path, ants.ANTsImage):
if isinstance(template_path, ants.core.ants_image.ANTsImage):
template_img = template_path
else:
if not os.path.exists(template_path):
Expand Down

0 comments on commit e4fae0c

Please sign in to comment.