Visualizing Neuroimaging Volume Files

This is to write a function that I want to later turn into a package. Here are some of the things I want this to do (not necessarily:

  • Show a fslview like representation of the volume with a given coordinate
  • Make a niak_montage like montage of the volume that covers the whole brain.
  • Have some summary metrics of the volume

Pierre generates one big matrix with all the images together and then just visualizes this. I think this is a pretty good template for what I want to do as well.


In [54]:
# Imports
import os
import numpy as np
import nibabel as nib
from scipy import ndimage as sn
from matplotlib import pyplot as plt

In [6]:
# Paths
in_file = '/home/surchs/Test/mni_152.nii.gz'

In [89]:
# Load the file and pick a volume
data = nib.load(in_file).get_data()
rolled = sn.interpolation.rotate(data, 0, [1,2])
print('The input file has the dimension {}'.format(data.shape))
slic_x = rolled[100,:,:]
slic_y = rolled[:,120,:]
slic_z = rolled[:,:,120]
print('The test slice has the dimension {}'.format(slic.shape))


The input file has the dimension (197, 233, 189)
The test slice has the dimension (197, 189)

In [90]:
f = plt.figure()
ax_x = f.add_subplot(131)
ax_x.imshow(slic_x, interpolation='nearest')
ax_y = f.add_subplot(132)
ax_y.imshow(slic_y, interpolation='nearest')
ax_z = f.add_subplot(133)
ax_z.imshow(slic_z, interpolation='nearest')


Out[90]:
<matplotlib.image.AxesImage at 0x7ffa5388f750>

In [ ]: