I am not sure if it will be of any help, but the imaging tools codebase has some code for supporting nifti1 as well: https://cirl.berkeley.edu/trac/browser/bic/trunk/imaging-tools/root/imaging/nifti.py