I am using numpy and nibabel lib to load data from nii file. This is my code to load the image data
import os, glob
import nibabel as nib
import numpy as np
import matplotlib.pyplot as plt
DataInputPath = '/content/drive/MyDrive/Data/Volumes/Img'
ImgPath = os.path.join(DataInputPath, 'Patient1.nii')
Img = nib.load(ImgPath).get_fdata()
np.min(Img), np.max(Img), Img.shape, type(Img)
And the output (image properties) are as shown below:
"(-1000.0, 2976.0, (512, 512, 193), numpy.memmap)"
When I want to plot the image using matplotlib using the code below, the output images seems like cropped as it using the image shape as above 512x512x193. How do I change the dimension when I want to plot the slice from x and y, so that the image won't be cropped? Plotting the slice z seems okay.
Ex1: Plotting X slice and the image is cropped
ImgSlice = Img[100,:,:]
plt.imshow(ImgSlice, cmap='gray')
plt.imshow
plt.show()
Ex2: Plotting Z where the image is okay
ImgSlice = Img[:,:,100]
plt.imshow(ImgSlice, cmap='gray')
plt.imshow
plt.show()