Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Flesh out front page example. #1237

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 30 additions & 19 deletions doc/index.rst
Expand Up @@ -56,36 +56,47 @@ See some of our :ref:`past announcements <old_news>`
Getting Started
***************

Here is a simple example showing how to calculate `color FA`. We
use a single Tensor model to reconstruct the datasets which are saved in a
Nifti file along with the b-values and b-vectors which are saved as text files.
In this example we use only a few voxels with 101 gradient directions::
Here is a simple example showing how to fit a DTI model to diffusion MRI data::

from dipy.data import get_data
fimg, fbval, fbvec = get_data('small_101D')
# The dipy.data module includes example data-sets:
import dipy.data as dpd
fimg, fbval, fbvec = dpd.get_data('small_101D')

# Print fimg, fbval and fbvec to the console:
print(fimg, fbval, fbvec)

# Read the data in, using nibabel
import nibabel as nib
img = nib.load(fimg)
data = img.get_data()

from dipy.io import read_bvals_bvecs
bvals, bvecs = read_bvals_bvecs(fbval, fbvec)
# Create a gradient table object from the b-values and b-vectors:
import dipy.core.gradients as dpg
gtab = dpg.gradient_table(fbval, fbvec)

# We will use DTI as the model for the data:
import dipy.reconst.dti as dti

# We initialize a model object:
ten = dti.TensorModel(gtab)

from dipy.core.gradients import gradient_table
gtab = gradient_table(bvals, bvecs)
# Fitting the model to the data:
fit = ten.fit(data)

from dipy.reconst.dti import TensorModel
ten = TensorModel(gtab)
tenfit = ten.fit(data)
# We calculate the FA from the model fit:
fa = dti.fractional_anisotropy(fit.evals)

from dipy.reconst.dti import fractional_anisotropy
fa = fractional_anisotropy(tenfit.evals)
# An RGB map of the principal diffusion direction can be computed:
cfa = dti.color_fa(fa, fit.evecs)

from dipy.reconst.dti import color_fa
cfa = color_fa(fa, tenfit.evecs)
# And displayed using Matplotlib:
import matplotlib.pyplot as plt
plt.imshow(cfa[cfa.shape[0]//2])
plt.show()

As an exercise try to calculate the `color FA` with your datasets. Here is what
a slice should look like.
As an exercise try to calculate the `color FA` with your datasets, by replacing
fimg, fbval, and fbvec with the names of files with your data. Here is what an
image of a middle slice through the brain should look like.

.. image:: _static/colorfa.png
:align: center
Expand Down