Multiple layers of nii need to be merged into one #1384
Replies: 3 comments
-
The affine and header of the bottom slice should work for the 3d image. You can use numpy.stack to stack the slices. |
Beta Was this translation helpful? Give feedback.
-
Hi, @effigies. Thanks your help. In fact, the affine matrix of each layer is corrected, that is, the layers may not be parallel to each other, and the direct np.stack loses the meaning of correction. |
Beta Was this translation helpful? Give feedback.
-
Got it. There's no easy tool to solve this problem, then. You'll need to decide how you want to extrapolate the data, what field of view to resampled them into, and how to combine the data from each slice. You can probably create masks of ones and resample them in the same way, then divide the sum of the data images by the sum of the mask images to get a reasonable per voxel average. |
Beta Was this translation helpful? Give feedback.
-
I encountered a situation where each layer was saved as a separate nii file, and each file had a corrected affine matrix. How should I combine them into a 3D nii file using nibabel?
Beta Was this translation helpful? Give feedback.
All reactions