Commit e4274364 authored by Baumgartner, Michael's avatar Baumgartner, Michael
Browse files

fix itk param check

parent 082f7221
...@@ -268,7 +268,7 @@ def _full_check( ...@@ -268,7 +268,7 @@ def _full_check(
def _check_itk_params( def _check_itk_params(
img_seq: Sequence[sitk.Image], img_seq: Sequence[sitk.Image],
paths: Sequence[Path], paths: Sequence[Path],
) -> None: ) -> None:
""" """
Check Dimension, Origin, Direction and Spacing of a Sequence of images Check Dimension, Origin, Direction and Spacing of a Sequence of images
...@@ -283,15 +283,31 @@ def _check_itk_params( ...@@ -283,15 +283,31 @@ def _check_itk_params(
ValueError: raised if spacing does not match ValueError: raised if spacing does not match
""" """
for idx, img in enumerate(img_seq[1:], start=1): for idx, img in enumerate(img_seq[1:], start=1):
if not (np.allclose(np.asarray(img_seq[0].GetDimension()) == \ if not (
np.asarray(img.GetDimension()))): np.asarray(img_seq[0].GetDimension()) == np.asarray(img.GetDimension())
raise ValueError(f"Expected {paths[idx]} and {paths[0]} to have same dimensions!") ).all():
if not (np.allclose(np.asarray(img_seq[0].GetOrigin()) == \ raise ValueError(
np.asarray(img.GetOrigin()))): f"Expected {paths[idx]} and {paths[0]} to have same dimensions!"
raise ValueError(f"Expected {paths[idx]} and {paths[0]} to have same origin!") )
if not (np.allclose(np.asarray(img_seq[0].GetDirection()) == \ if not ((np.asarray(img_seq[0].GetSize()) == np.asarray(img.GetSize()))).all():
np.asarray(img.GetDirection()))): raise ValueError(
raise ValueError(f"Expected {paths[idx]} and {paths[0]} to have same direction!") f"Expected {paths[idx]} and {paths[0]} to have same dimensions!"
if not (np.allclose(np.asarray(img_seq[0].GetSpacing()) == \ )
np.asarray(img.GetSpacing()))): if not np.allclose(
raise ValueError(f"Expected {paths[idx]} and {paths[0]} to have same spacing!") np.asarray(img_seq[0].GetOrigin()), np.asarray(img.GetOrigin())
):
raise ValueError(
f"Expected {paths[idx]} and {paths[0]} to have same origin!"
)
if not np.allclose(
np.asarray(img_seq[0].GetDirection()), np.asarray(img.GetDirection())
):
raise ValueError(
f"Expected {paths[idx]} and {paths[0]} to have same direction!"
)
if not np.allclose(
np.asarray(img_seq[0].GetSpacing()), np.asarray(img.GetSpacing())
):
raise ValueError(
f"Expected {paths[idx]} and {paths[0]} to have same spacing!"
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment