I have a function which, given a NIfTI file, generates a set of images. How can I essentially reverse that process with another function which takes in these images and creates a NIfTI file from them?
Asked
Active
Viewed 22 times
0
-
NIftI file includes more than mere images, Pixel spacing, Affine transform, etc.., please refer to [Nibabel Nifti header](https://nipy.org/nibabel/nifti_images.html#the-nifti-header) – Bilal Aug 01 '23 at 09:55
1 Answers
0
You do that with SimpleITK's ImageSeriesReader class. It'd look something like this:
import SimpleITK as sick
reader = sitk.ImageSeriesReader()
reader.SetFileNames(["slice1.png", ..., "sliceN.png"])
volume_image = reader.Execute()
Note that the volume won't have any voxel spacing information, so you might need to call the SetSpacing method
volume_image.SetSpacing([x_spacing, y_spacing, z_spacing])

Dave Chen
- 1,905
- 1
- 12
- 18