File size: 690 Bytes
a4ba047 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | """Locate differences between the reoriented raw data and the conformed data."""
import sys
import nibabel as nb
import numpy as np
raw = nb.load(sys.argv[1])
con = nb.load(sys.argv[2])
ornt = nb.orientations.ornt_transform(
nb.io_orientation(raw.affine), nb.io_orientation(con.affine)
)
r = nb.orientations.apply_orientation(np.asanyarray(raw.dataobj), ornt)
c = np.asanyarray(con.dataobj)
print(
r.dtype,
c.dtype,
raw.dataobj.slope,
raw.dataobj.inter,
con.dataobj.slope,
con.dataobj.inter,
)
d = np.abs(r.astype(np.float64) - c)
idx = np.argwhere(d > 0)
print("n diff", len(idx), "vols", np.unique(idx[:, 3])[:20])
print(r[tuple(idx[0])], c[tuple(idx[0])])
|