Skip to content

Instantly share code, notes, and snippets.

@McSpooder
Last active July 22, 2020 12:42
Show Gist options
  • Save McSpooder/ad67958f0a24a3f66f62de80e3142e1a to your computer and use it in GitHub Desktop.
Save McSpooder/ad67958f0a24a3f66f62de80e3142e1a to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import nibabel as nib
def show_image(image):
plt.imshow(image)
fig = plt.figure()
mri = nib.load("path_to_mri_scan\\mri_volume.nii").get_fdata()
mri.shape
for i in range(0, 2):
for j in range(1, 5):
index = i*4
ax = plt.subplot(3, 4, index + j)
plt.tight_layout()
ax.set_title('slice #{}'.format(index + j))
ax.axis('off')
show_image(mri[50 + (index+j)*2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment