-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Both nifti1.ts and nifti2.ts implement getQformMat along the lines of the nifti_clib reference implementation. However, only nifti1.ts implements the three affine methods, while nifti2.ts unconditionally loads the sform. Additionally, nifti1.ts implements the qform again, although inconsistently with the reference implementation, and it has no method to access the sform if the sform is not the determined method.
I would suggest:
-
Load the sform into
header.sform. -
Add a method, called at the end of
readHeader(in both implementations) to setheader.affineaccording to the three methods:#setAffine() { if (this.sform_code != 0) { this.affine = this.sform } else if (this.qform_code != 0) { this.affine = this.getQformMat() } else { // Default LAS matrix } }
The current implementation prefers the qform to the sform if sform_code < qform_code, but I haven't seen that logic elsewhere. The standard does not say to prefer one to the other, and the reference implementation's image structure contains both, leaving calling code to either use both or choose one to prefer, invalidating the other on changes.
The above logic matches the nibabel and FreeSurfer's load_nifti_hdr.m. The ANTs logic is convoluted, and I won't reproduce it here. I haven't looked into other implementations.