nipy/dipy — pull request #341 by MrBago (2014-03-25 03:38:01+00:00)
Title: 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