d938f476feee0efd9045bc8f9bb1fe76b9898fae,doc/examples/introduction_to_basic_tracking.py,,,#,32

Before Change


streamlines = list(streamlines)

// Prepare the display objects.
color = line_colors(streamlines)

if fvtk.have_vtk:
    streamlines_actor = fvtk.line(streamlines, line_colors(streamlines))

After Change


from dipy.viz.colormap import line_colors

// Enables/disables interactive visualization
interactive = False

// Initialization of LocalTracking. The computation happens in the next step.
streamlines = LocalTracking(csa_peaks, classifier, seeds, affine, step_size=.5)

// Compute streamlines and store as a list.
streamlines = list(streamlines)

// Prepare the display objects.
color = line_colors(streamlines)

if window.have_vtk:
    streamlines_actor = actor.line(streamlines, line_colors(streamlines))

    // Create the 3d display.
    r = window.Renderer()
    r.add(streamlines_actor)

    // Save still images for this static example. Or for interactivity use
    window.record(r, n_frames=1, out_path="deterministic.png", size=(800, 800))
    if interactive:
        window.show(r)


.. figure:: deterministic.png
   :align: center

   **Corpus Callosum Deterministic**

We"ve created a deterministic set of streamlines, so called because if you
repeat the fiber tracking (keeping all the inputs the same) you will get
exactly the same set of streamlines. We can save the streamlines as a Trackvis
file so it can be loaded into other software for visualization or further
analysis.


from dipy.io.trackvis import save_trk
save_trk("CSA_detr.trk", streamlines, affine, labels.shape)


Next let"s try some probabilistic fiber tracking. For this, we"ll be using the
Constrained Spherical Deconvolution (CSD) Model. This model represents each
voxel in the data set as a collection of small white matter fibers with
different orientations. The density of fibers along each orientation is known
as the Fiber Orientation Distribution (FOD). In order to perform probabilistic
fiber tracking, we pick a fiber from the FOD at random at each new location
along the streamline. Note: one could use this model to perform deterministic
fiber tracking by always tracking along the directions that have the most
fibers.

Let"s begin probabilistic fiber tracking by fitting the data to the CSD model.


from dipy.reconst.csdeconv import (ConstrainedSphericalDeconvModel,
                                   auto_response)

response, ratio = auto_response(gtab, data, roi_radius=10, fa_thr=0.7)
csd_model = ConstrainedSphericalDeconvModel(gtab, response, sh_order=6)
csd_fit = csd_model.fit(data, mask=white_matter)


Next we"ll need to make a ``ProbabilisticDirectionGetter``. Because the CSD
model represents the FOD using the spherical harmonic basis, we can use the
``from_shcoeff`` method to create the direction getter. This direction getter
will randomly sample directions from the FOD each time the tracking algorithm
needs to take another step.


from dipy.direction import ProbabilisticDirectionGetter

prob_dg = ProbabilisticDirectionGetter.from_shcoeff(csd_fit.shm_coeff,
                                                    max_angle=30.,
                                                    sphere=default_sphere)


As with deterministic tracking, we"ll need to use a tissue classifier to
restrict the tracking to the white matter of the brain. One might be tempted
to use the GFA of the CSD FODs to build a tissue classifier, however the GFA
values of these FODs don"t classify gray matter and white matter well. We will
therefore use the GFA from the CSA model which we fit for the first section of
this example. Alternatively, one could fit a ``TensorModel`` to the data and use
the fractional anisotropy (FA) to build a tissue classifier.


classifier = ThresholdTissueClassifier(csa_peaks.gfa, .25)


Next we can pass this direction getter, along with the ``classifier`` and
``seeds``, to ``LocalTracking`` to get a probabilistic model of the corpus
callosum.


streamlines = LocalTracking(prob_dg, classifier, seeds, affine,
                            step_size=.5, max_cross=1)

// Compute streamlines and store as a list.
streamlines = list(streamlines)

if window.have_vtk:
    streamlines_actor = actor.line(streamlines, line_colors(streamlines))

    // Create the 3d display.
    r = window.Renderer()
    r.add(streamlines_actor)

    // Save still images for this static example.
    window.record(r, n_frames=1, out_path="probabilistic.png", size=(800, 800))
    if interactive:
        window.show(r)


.. figure:: probabilistic.png
   :align: center
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: nipy/dipy
Commit Name: d938f476feee0efd9045bc8f9bb1fe76b9898fae
Time: 2018-01-10
Author: skab12@gmail.com
File Name: doc/examples/introduction_to_basic_tracking.py
Class Name:
Method Name:


Project Name: nipy/dipy
Commit Name: c2cfaf314a381e520883eba2d965cd93fd5572e0
Time: 2019-07-21
Author: girard.gabriel@gmail.com
File Name: doc/examples/tracking_bootstrap_peaks.py
Class Name:
Method Name:


Project Name: nipy/dipy
Commit Name: d938f476feee0efd9045bc8f9bb1fe76b9898fae
Time: 2018-01-10
Author: skab12@gmail.com
File Name: doc/examples/introduction_to_basic_tracking.py
Class Name:
Method Name:


Project Name: nipy/dipy
Commit Name: aac7b54c8d6957786a9aa70e896cef10fe0ab9fe
Time: 2019-07-21
Author: girard.gabriel@gmail.com
File Name: doc/examples/tracking_pft.py
Class Name:
Method Name: