Skip to content

Commit

Permalink
Merge pull request #5 from LoicDorval/ld_update_nb
Browse files Browse the repository at this point in the history
changes for nibabel new syntax
  • Loading branch information
AGrigis authored Nov 7, 2024
2 parents adb3fd7 + 31b62a4 commit 4c88a6d
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 4c88a6d

Please sign in to comment.