Skip to content

Commit a254744

Browse files
committed
ENH: Add units to qform overwrite report
1 parent 22db00a commit a254744

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

niworkflows/interfaces/images.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,21 @@ def _run_interface(self, runtime):
529529
diff = np.linalg.inv(qform) @ new_qform
530530
trans, rot, _, _ = transforms3d.affines.decompose44(diff)
531531
angle = transforms3d.axangles.mat2axangle(rot)[1]
532+
xyz_unit = img.header.get_xyzt_units()[0]
533+
if xyz_unit == "unknown":
534+
xyz_unit = "mm"
535+
532536
total_trans = np.sqrt(
533537
np.sum(trans * trans)
534538
) # Add angle and total_trans to report
535539
warning_txt = "Note on orientation: qform matrix overwritten"
536-
description = """\
540+
description = f"""\
537541
<p class="elem-desc">
538542
The qform has been copied from sform.
539-
The difference in angle is {angle:.02g}.
540-
The difference in translation is {total_trans:.02g}.
543+
The difference in angle is {angle:.02g} radians.
544+
The difference in translation is {total_trans:.02g}{xyz_unit}.
541545
</p>
542-
""".format(
543-
angle=angle, total_trans=total_trans
544-
)
546+
"""
545547
elif qform_code > 0:
546548
# qform code indicates the qform is supposed to be valid. Use more stridency.
547549
warning_txt = "WARNING - Invalid qform information"

0 commit comments

Comments
 (0)