Skip to content

How to convert multiple Nifti1Image of different sizes to a nii.gz #1223

Answered by ZviBaratz
emmanuel-nwogu asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @emmanuel-nwogu,

I hope it's OK I converted your issue to a discussion, since it is more a support question, rather than an issue with nibabel.

Unfortunately, I don't think it is possible for a single NIfTI file to hold differently sized 2D arrays to represent a single 3D array. However, I imagine this is practically equivalent to zero-padding the arrays to match the largest dimension sizes. If you do that after cropping, it might be difficult to realign the slices correctly. Therefore, I would suggest finding out how the slice with the largest dimensions is cropped, and then applying the same cropping to all the other slices. Does that make sense?

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@emmanuel-nwogu
Comment options

Answer selected by emmanuel-nwogu
Comment options

You must be logged in to vote
2 replies
@emmanuel-nwogu
Comment options

@effigies
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #1222 on April 13, 2023 05:41.