Example #1
0
def get_dti_streamlines(data_container,
                        random_seeds=False,
                        seeds_count=30000,
                        seeds_per_voxel=False,
                        step_width=1.0,
                        max_angle=30.0,
                        fa_threshold=0.15):
    """
    Tracks and returns CSD Streamlines for the given DataContainer.

    Parameters
    ----------
    data_container
        The DataContainer we would like to track streamlines on
    random_seeds
        A boolean indicating whether we would like to use random seeds
    seeds_count
        If we use random seeds, this specifies the seed count
    seeds_per_voxel
        If True, the seed count is specified per voxel
    step_width
        The step width used while tracking
    fa_threshold
        The FA threshold to use to stop tracking
    max_angle
        The maximum allowed angle between incoming and outgoing angle, float between 0.0 and 90.0 deg
    Returns
    -------
    Streamlines
        A list of Streamlines
    """
    seeds = _get_seeds(data_container, random_seeds, seeds_count,
                       seeds_per_voxel)

    dti_fit = TensorModel(data_container.gtab).fit(
        data_container.dwi, mask=data_container.binary_mask)
    dti_fit_odf = dti_fit.odf(sphere=default_sphere)

    direction_getter = DeterministicMaximumDirectionGetter.from_pmf(
        dti_fit_odf, max_angle=max_angle, sphere=default_sphere)
    classifier = ThresholdStoppingCriterion(dti_fit.fa, fa_threshold)

    streamlines_generator = LocalTracking(direction_getter,
                                          classifier,
                                          seeds,
                                          data_container.aff,
                                          step_size=step_width)
    streamlines = Streamlines(streamlines_generator)

    return streamlines