I have 3D array in Nifti file (.ii.gz) and I want to save it as a 3D numpy array. I used Nibabel to convert Numpy to Nifti1. Can I do the opposite?
Asked
Active
Viewed 1.9k times
2 Answers
22
From nipy
import numpy as np
import nibabel as nib
img = nib.load(example_filename)
a = np.array(img.dataobj)

piRSquared
- 285,575
- 57
- 475
- 624
-
-
4
-
@Soyol you can post a new question about this. There is a way to do it – seralouk Jun 17 '19 at 17:10
8
You can also do this:
import numpy as np
import nibabel as nib
img_nifti = nib.load(filepath)
img = img_nifti.get_data()

schrodingercat
- 246
- 4
- 21