Reputation: 1
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?
Upvotes: 0
Views: 155
Reputation: 2085
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])
Upvotes: 0