Skip to content

Commit daefc6c

Browse files
authored
fix: Remove checks for unit zooms and symmetric rotations in template warp (#3376)
A user with a custom template is generating warps that have spacing `[1.5 1.5 1.5]`: https://neurostars.org/t/use-custom-dartel-template-in-fmriprep/30670/8 The check for unit spacing was mostly intended to avoid weird behavior where we might generate a bad affine. The interpretation of isotropic spacing is straightforward, so I think we can relax this. Creating a docker image to allow for testing.
2 parents 08933bf + 1607996 commit daefc6c

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

fmriprep/utils/transforms.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def load_ants_h5(filename: Path) -> nt.base.TransformBase:
4949
# * Always return a nitransforms TransformBase
5050
# * Construct warp affine from fixed parameters
5151
#
52-
# This should be upstreamed into nitransforms
52+
# This has been upstreamed into nitransforms.
53+
# Future versions should switch to using nitransforms directly.
5354
h = h5py.File(filename)
5455
xform = ITKCompositeH5.from_h5obj(h)
5556

@@ -78,14 +79,6 @@ def load_ants_h5(filename: Path) -> nt.base.TransformBase:
7879
spacing = transform2['TransformFixedParameters'][6:9]
7980
direction = transform2['TransformFixedParameters'][9:].reshape((3, 3))
8081

81-
# We are not yet confident that we handle non-unit spacing
82-
# or direction cosine ordering correctly.
83-
# If we confirm or fix, we can remove these checks.
84-
if not np.allclose(spacing, 1):
85-
raise ValueError(f'Unexpected spacing: {spacing}')
86-
if not np.allclose(direction, direction.T):
87-
raise ValueError(f'Asymmetric direction matrix: {direction}')
88-
8982
# ITK uses LPS affines
9083
lps_affine = compose_affine(T=origin, R=direction, Z=spacing)
9184
ras_affine = np.diag([-1, -1, 1, 1]) @ lps_affine

0 commit comments

Comments
 (0)