First notebook:

This notebook contains a demonstration of how to open DTI from the nifti format.


In [1]:
# Importanto as bibliotecas necessárias: 

import DTIlib as DTI
from IPython.display import Image
from IPython.display import display

%matplotlib 
import matplotlib.pyplot as plt
import numpy as np


Using matplotlib backend: MacOSX

In [2]:
# Loading the data, at this case for subject 01

BASE_PATH = 'subject001'
fa, evl, evt = DTI.load_fa_evl_et(BASE_PATH)


/Users/mariecp/anaconda/lib/python2.7/site-packages/dicom/__init__.py:53: UserWarning: 
This code is using an older version of pydicom, which is no longer 
maintained as of Jan 2017.  You can access the new pydicom features and API 
by installing `pydicom` from PyPI.
See 'Transitioning to pydicom 1.x' section at pydicom.readthedocs.org 
for more information.

  warnings.warn(msg)
FA Loaded

In [7]:
# Printing shapes
#fa.shape
print('FA shape: ' , fa.shape)
print('Evl shape: ', evl.shape)


('FA shape: ', (70, 256, 256))
('Evl shape: ', (3, 70, 256, 256))

Visualizing the data

The plot shows FA image in three different views (Axial, Coronal and Sagittal)


In [16]:
# Viewing data
%matplotlib inline
from matplotlib.widgets import Slider

# Set up figure
sz, sy, sx = fa.shape
fig = plt.figure(figsize=(15,15))
xy = fig.add_subplot(1,3,1)
plt.title("Axial Slice")
xz = fig.add_subplot(1,3,2)
plt.title("Coronal Slice")
yz = fig.add_subplot(1,3,3)
plt.title("Sagittal Slice")

frame = 0.5
# Normalize the FA values for better visualization
maximo = np.max(np.abs(fa)) 
minimo = np.min(np.abs(fa))
xy.imshow(fa[np.floor(frame*sz),:,:], origin='lower', interpolation='nearest', cmap="gray",vmin=0, vmax=maximo )
xz.imshow(fa[:,np.floor(frame*sy),:], origin='lower', interpolation='nearest', cmap="gray",vmin=0 , vmax=maximo )
yz.imshow(fa[:,:,np.floor(frame*sx)], origin='lower', interpolation='nearest', cmap="gray",vmin=0 , vmax=maximo )


/Users/mariecp/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:19: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
/Users/mariecp/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:20: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
/Users/mariecp/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:21: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
Out[16]:
<matplotlib.image.AxesImage at 0x123df9650>

In [ ]: