Traco Redesign

I've put together a pull request to help clarify some of the ideas I proposed earlier on this thread.

In this pull request there is an example called newApi.py this example still needs some work, but I hope it will help show how this new tracking framework is meant to be used. In the example I've done some probabilistic tracking with the CSA and CSD models and some deterministic tracking with the CSA model. Be warned that the CSD fitting takes about 45 min.

To describe how this works, in each of the three tracking examples I create a direction getter and a tissue classifier which I pass with seeds and affine and a step_size to LocalTracking.

LocalTracking is an example of what we've been calling a “streamline manager” it tracks each seed and yields a streamline if the streamline doesn't hit any invalid points during tracking.

For the deterministic tracking I've modified the PeaksAndMetrics class to make it a bonefied DirectionGetter. It calls existing cython code that was written for EuDx.

For something to be a  DirectionGetter it needs to subclass from dipy.tracking.local.DirectionGetter and implement a cython cdef method called get_direction. The cython requirement is so the inner tracking loop can be compiled. A DirectionGetter needs to also have an initial_direction method. This method is python for now (but we can change this).

For the probabilist tracking the direction getter is ProbabilisticOdfWightedDirectionGetter (I'm open to a more succinct name). I've written the it in python, but used a cython helper type to make it work. Let me know if anyone wants to hear me rant about how this awesomeness works.

I've implemented one example tissue classifier,  ThresholdTissueClassifier, which like direction getter has a cython method called check_point. This method returns the type of tissue to the streamline manager/framework which then has to decide what to do next.

This PR needs more tests, a better example and there are some corner cases to deal with (literally the interpolation breaks at the corners of the image). But I promised you guys some code so here it is
also : "shearing", rather than "sheering"

On Thu, Sep 25, 2014 at 7:17 AM, Eleftherios Garyfallidis <
notifications@github.com> wrote:

> In dipy/tracking/local/__init__.py:
>
> > +class LocalTracking(object):
> > +    """A streamline generator for local tracking methods"""
> > +
> > +    @staticmethod
> > +    def _get_voxel_size(affine):
> > +        """Computes the voxel sizes of an image from the affine.
> > +
> > +        Checks that the affine does not have any sheer because local_tracker
> > +        assumes that the data is sampled on a regular grid.
> > +
> > +        """
> > +        lin = affine[:3, :3]
> > +        dotlin = np.dot(lin.T, lin)
> > +        # Check that the affine is well behaved
> > +        if not np.allclose(np.triu(dotlin, 1), 0.):
> > +            msg = ("The affine provided seems to contain sheering, data must "
>
> This test is unexpected for me. I don't see why the affine would be a
> problem here and why you use that to check for sheering. In which space are
> you doing the tracking?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/nipy/dipy/pull/341/files#r18033916>.
>