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(
def _check_itk_params(
img_seq: Sequence[sitk.Image],
paths: Sequence[Path],
) -> None:
) -> None:
"""
Check Dimension, Origin, Direction and Spacing of a Sequence of images
......@@ -283,15 +283,31 @@ def _check_itk_params(
ValueError: raised if spacing does not match
"""
for idx, img in enumerate(img_seq[1:], start=1):
if not (np.allclose(np.asarray(img_seq[0].GetDimension()) == \
np.asarray(img.GetDimension()))):
raise ValueError(f"Expected {paths[idx]} and {paths[0]} to have same dimensions!")
if not (np.allclose(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!")
if not (
np.asarray(img_seq[0].GetDimension()) == np.asarray(img.GetDimension())
).all():
raise ValueError(
f"Expected {paths[idx]} and {paths[0]} to have same dimensions!"
)
if not ((np.asarray(img_seq[0].GetSize()) == np.asarray(img.GetSize()))).all():
raise ValueError(
f"Expected {paths[idx]} and {paths[0]} to have same dimensions!"
)
if not np.allclose(
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