Skip to content

Commit

Permalink
BUG: Output oriented image
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Sep 29, 2022
1 parent 0642ee0 commit 75ee247
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ def itk_image_to_multiscale(
# Orient 3D image so that direction is identity wrt RAI coordinates
image_dimension = image.GetImageDimension()
input_direction = np.array(image.GetDirection())
oriented_image = image
if anatomical_axes and image_dimension == 3 and not (np.eye(image_dimension) == input_direction).all():
desired_orientation = itk.SpatialOrientationEnums.ValidCoordinateOrientations_ITK_COORDINATE_ORIENTATION_RAI
oriented_image = itk.orient_image_filter(image, use_image_direction=True, desired_coordinate_orientation=desired_orientation)

elif anatomical_axes and image_dimension != 3:
raise ValueError(f'Cannot use anatomical axes for input image of size {image_dimension}')

image_da = itk.xarray_from_image(image)
image_da = itk.xarray_from_image(oriented_image)
image_da.name = name

image_dims: Tuple[str, str, str, str] = ("x", "y", "z", "t") # ITK dims are in xyzt order
Expand Down

0 comments on commit 75ee247

Please sign in to comment.