Open effigies opened 5 years ago
So this may be a feature, not a bug...
Note particularly
# If the affine is not None, and it is different from the main affine
# in the header, update the header
if self._affine is None:
return
if np.allclose(self._affine, hdr.get_best_affine()):
return
self._affine2header()
This reads as if images with multiple affines may have different zooms. Presumably this derives from the qform/sform distinction, where the qform is supposed to indicate scanner coordinates, and the sform can be set to indicate locations in another space (e.g. some template) without necessarily resampling.
So perhaps it's an ambiguity of what set_zooms()
means. Perhaps, in a NIfTI with a valid sform, set_zooms
should actually modify the sform and not pixdim
.
Nifti1Header.set_zooms()
updates thepixdim
field, but this doesn't translate to an updated affine.get_qform()
will reflect the change, butget_sform()
will not, and hence in almost all (perhaps all?) cases we'll get out of sync.As
img.affine
is considered correct,update_header()
should overridepixdim
settings with zooms derived from the affine. This may be best dealt with in some superclass ofNifti1Image
, but we should not be creating invalid files.Sub-issue identified in #619.