Skip to content

Commit

Permalink
FIX: Catch cases of unexpected resampling
Browse files Browse the repository at this point in the history
  • Loading branch information
mgxd committed Jun 5, 2024
1 parent a28212d commit bcc7d3e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fmriprep/utils/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ def load_ants_h5(filename: Path) -> nt.base.TransformBase:

fixed_params = transform2['TransformFixedParameters'][:]

spacing = fixed_params[6:9]
direction = fixed_params[9:]

# Supported spacing
if not np.array_equal(spacing, np.array([1.0, 1.0, 1.0])):
raise ValueError(f'Unexpected spacing: {spacing}')

if not np.array_equal(direction, np.diag([-1, -1, -1])):
raise ValueError(f'Asymmetric direction matrix: {direction}')

shape = tuple(fixed_params[:3].astype(int))
# ITK stores warps in Fortran-order, where the vector components change fastest
# Nitransforms expects 3 volumes, not a volume of three-vectors, so transpose
Expand Down

0 comments on commit bcc7d3e

Please sign in to comment.