I have a file in format of nii.gz with 20 slices. But there are some problem that I just need the top 13 slices. So I use the load_nii or simpleITK to get the array of the 20 silces. What I want to do is just use the top 13 slices(now is array) to generate a new nii squence.
If you have loaded the image using SimpleITK, you can use python array slicing to extract the top 13 slices. It would be something like this:
import SimpleITK as sitk
img1 = sitk.ReadImage("input.nii.gz")
img2 = img1[0:13]