Skip to content

Commit 92d78cc

Browse files
authored
Merge pull request #162 from poldracklab/fix/137
FIX: Orientation of displacements field and header when reading ITK's h5
2 parents 59fd890 + e924f5c commit 92d78cc

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

nitransforms/io/itk.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,15 @@ def from_h5obj(cls, fileobj, check=True):
342342
directions = _fixed[9:].astype("float").reshape((3, 3))
343343
affine = from_matvec(directions * zooms, offset)
344344
field = np.asanyarray(xfm[f"{typo_fallback}Parameters"]).reshape(
345-
tuple(shape + [1, -1])
345+
(*shape, 1, -1)
346346
)
347+
field[..., (0, 1)] *= -1.0
347348
hdr = Nifti1Header()
348349
hdr.set_intent("vector")
349350
hdr.set_data_dtype("float")
350351

351352
xfm_list.append(
352-
ITKDisplacementsField.from_image(
353-
Nifti1Image(field.astype("float"), affine, hdr)
354-
)
353+
Nifti1Image(field.astype("float"), LPS @ affine @ LPS, hdr)
355354
)
356355
continue
357356

0 commit comments

Comments
 (0)