Forked from tonyreina/Save Numpy matrix to Nibabel (.nii.gz)
Created
July 30, 2021 06:30
-
-
Save billhhh/858379741e93a2d5a884c12fc14170e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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