Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Add nifti sform read/write testing
Add images and a test suite to ensure that the sform and qform variants of the nifti direction representations are properly interpreted. This makes ITK more compatible with both nibabel and dcm2niix tools with respect to improved direction precsion representation. ```bash \# Need uncompressed files of file with both sform and qform as converted by dcm2niix tool from DICOM gunzip LPSLabels.nii \# make no_qform variant nifti_tool -mod_hdr -prefix LPSLabels_noqform.nii -infiles LPSLabels.nii -mod_field qform_code 0 -mod_field quatern_b 0 -mod_field quatern_c 0 -mod_field quatern_d 0 -mod_field qoffset_x 0 -mod_field qoffset_y 0 -mod_field qoffset_z 0 \# make no_sform variant nifti_tool -mod_hdr -prefix LPSLabels_nosform.nii -infiles LPSLabels.nii -mod_field sform_code 0 -mod_field srow_x "0 0 0 0" -mod_field srow_y "0 0 0 0" -mod_field srow_z "0 0 0 0" \# Verify results are as desired nifti_tool -diff_hdr -in LPSLabels_noqform.nii LPSLabels.nii nifti_tool -diff_hdr -in LPSLabels_nosform.nii LPSLabels.nii \# Make an invalid nifti file! pixdim is required for nibabel and ITK readings \# nifti_tool -mod_hdr -prefix LPSLabels_noqform_nopixdim.nii -infiles LPSLabels.nii -mod_field qform_code 0 -mod_field quatern_b 0 -mod_field quatern_c 0 -mod_field quatern_d 0 -mod_field qoffset_x 0 -mod_field qoffset_y 0 -mod_field qoffset_z 0 -mod_field pixdim "0 0 0 0 0 0 0 0"\n gzip -9v LPSLabels.nii LPSLabels_nosform.nii LPSLabels_noqform.nii ``` ``` python import nibabel LPSLabels=nibabel.load('LPSLabels.nii.gz') LPSLabels_noqform =nibabel.load('LPSLabels_noqform.nii.gz') LPSLabels_nosform =nibabel.load('LPSLabels_nosform.nii.gz') LPSLabels.affine == LPSLabels_noqform.affine LPSLabels.affine == LPSLabels_nosform.affine ```
- Loading branch information