Skip to content

Commit

Permalink
changes for nibabel new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
LoicDorval committed Oct 10, 2024
1 parent adb3fd7 commit 31b62a4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions limri/regtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def flirt2aff(mat_file, in_file, ref_file):
flirt_affine = np.loadtxt(mat_file)
in_img = nibabel.load(in_file)
ref_img = nibabel.load(ref_file)
in_hdr = in_img.get_header()
ref_hdr = ref_img.get_header()
in_hdr = in_img._header
ref_hdr = ref_img._header

def _x_flipper(n):
flipr = np.diag([-1, 1, 1, 1])
Expand All @@ -174,9 +174,9 @@ def _x_flipper(n):

inspace = np.diag(in_hdr.get_zooms()[:3] + (1, ))
refspace = np.diag(ref_hdr.get_zooms()[:3] + (1, ))
if np.linalg.det(in_img.get_affine()) >= 0:
if np.linalg.det(in_img._affine) >= 0:
inspace = np.dot(inspace, _x_flipper(in_hdr.get_data_shape()[0]))
if np.linalg.det(ref_img.get_affine()) >= 0:
if np.linalg.det(ref_img._affine) >= 0:
refspace = np.dot(refspace, _x_flipper(ref_hdr.get_data_shape()[0]))

omat = np.dot(np.linalg.inv(refspace), np.dot(flirt_affine, inspace))
Expand Down

0 comments on commit 31b62a4

Please sign in to comment.