Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save billhhh/858379741e93a2d5a884c12fc14170e9 to your computer and use it in GitHub Desktop.
Save billhhh/858379741e93a2d5a884c12fc14170e9 to your computer and use it in GitHub Desktop.
import nibabel as nib
import numpy as np
data = np.ones((32, 32, 15, 100), dtype=np.int16) # dummy data in numpy matrix
img = nib.Nifti1Image(data, np.eye(4)) # Save axis for data (just identity)
img.header.get_xyzt_units()
img.to_filename(os.path.join('build','test4d.nii.gz')) # Save as NiBabel file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment