My goal is to use nilearn’s resample_img function to resample all my volumes to the same shape. The function takes the arguments target_affine and target_shape. By setting the diagonal of the target_affine matrix to a voxel size of 0.5 mm (and leaving the target_shape undefined), I expected the image dimensions of the volume to double from (150 x 256 x 256) to (300 x 512 x 512). Unfortunately, the resultant dimensions turned out to be (359 x 535 x 535). This is demonstrated in the upsampling portion of this notebook .
To bring the image to the standard size I desire (300 x 512 x 512), it appears that target_shape must be defined to the desired shape to perform a subsequent crop/pad operation.
Is this logic correct and the best route to meet my goal? If possible, I would like to avoid cropping so there is no information loss. Also, can someone shed some light as to why the volume dimensions aren’t exactly doubled?