Closed seanm closed 1 year ago
Thanks @hjmjohnson !
Note that this commit has been undone with PR 170. The addressing in 166 does not account for types in indexing. For example char * offsetp = &(((char *)basep + field->offset)[fc]);
with float data needs [fc] to offset by floats, not chars.
Note that this commit has been undone with PR 170. The addressing in 166 does not account for types in indexing.
Oh damn, indeed you are right. The many brackets threw me for a loop. Disturbing that no test failed due to this. I'll make a new PR to fix it.
I could add a test for that, something like:
nifti_tool -mod_hdr -new_dim 4 64 64 21 180 0 0 0 \
-mod_field pixdim "0.0 4.0 4.0 6.0 3.0 1.0 1.0 1.0" \
-prefix new_image.nii -infiles MAKE_IM
nifti_tool -disp_hdr -field pixdim -quiet -infiles new_image.nii
If pixdim were set using a variable, that could be checked against the output.
@afni-rickr please see my fix in https://github.com/NIFTI-Imaging/nifti_clib/pull/172
Modern compilers optimize memcpy() very well, this will likely produce the same code.