0

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.

Salmon
  • 369
  • 1
  • 4
  • 14

1 Answers1

1

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]
Dave Chen
  • 1,905
  • 1
  • 12
  • 18
  • Hellp Dave Chen and Salmon, Can you please help me with this post? https://stackoverflow.com/questions/56698087/how-to-remove-a-modality-from-mri-image-python-nibabel – The Great Jun 21 '19 at 07:09