webapps / hmc /reference /scripts /conform_diff.py
gdevenyi's picture
hmc: NiFreeze 3bcfb00 and QSIPrep 26.1.1 SHORELine reference runs on ds005577 sub-107 (part 9)
a4ba047 verified
Raw History Blame Contribute Delete
690 Bytes
"""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])])