Mismatch in Expected Dimensions After Resampling NIfTI Image to 1x1x1 mm³ with Nibabel

46 views Asked by At

I am working with NIfTI MRI images and trying to resample them to a resolution of 1x1x1 mm³ using the nibabel library in Python. Although the resampling process completes without errors, the resulting image dimensions are not as expected.

Original Image Metadata:

  • Voxel size: 1.5x1.5x3 mm³
  • Image dimensions: 128x128x16 (Width x Height x Depth)

After resampling to a voxel size of 1x1x1 mm³, I expected the dimensions to be 192x192x48 voxels. However, I am getting dimensions of 193x200x114 voxels instead.

The resample_to_output function seems not to be considering the expected dimensions based on the new voxel size. What could be causing this discrepancy, and how can I correct the dimensions of the resampled image to match the intended size?

Here's the relevant part of my code and the meta data of the original image Any help in understanding and fixing this issue would be greatly appreciated.

import nibabel as nib
from nibabel.processing import resample_to_output

# Load the original T1 image
img_t1 = nib.load('path_to_t1_image.nii.gz')

# Perform resampling
resampled_img_t1 = resample_to_output(img_t1, voxel_sizes=(1, 1, 1))

# Check the dimensions of the resampled image
print('Resampled T1 image shape:', resampled_img_t1.shape)

Meta Data from the original image

0

There are 0 answers