Skip to content

Commit

Permalink
Merge pull request #162 from poldracklab/fix/137
Browse files Browse the repository at this point in the history
FIX: Orientation of displacements field and header when reading ITK's h5
  • Loading branch information
oesteban authored Mar 15, 2022
2 parents 59fd890 + e924f5c commit 92d78cc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions nitransforms/io/itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,15 @@ def from_h5obj(cls, fileobj, check=True):
directions = _fixed[9:].astype("float").reshape((3, 3))
affine = from_matvec(directions * zooms, offset)
field = np.asanyarray(xfm[f"{typo_fallback}Parameters"]).reshape(
tuple(shape + [1, -1])
(*shape, 1, -1)
)
field[..., (0, 1)] *= -1.0
hdr = Nifti1Header()
hdr.set_intent("vector")
hdr.set_data_dtype("float")

xfm_list.append(
ITKDisplacementsField.from_image(
Nifti1Image(field.astype("float"), affine, hdr)
)
Nifti1Image(field.astype("float"), LPS @ affine @ LPS, hdr)
)
continue

Expand Down

0 comments on commit 92d78cc

Please sign in to comment.