Xval

This revives #235. Now that all the other elements are in place, I think that this is ready for review and in principle ready to be merged upstream (once it's been reviewed and fixed up, of course!). I am excited about this PR - evaluation of DWI models is something that I have been thinking a lot about in the past couple of years, since I started working on DWI. 

This PR also demonstrates the power and elegance of the uniform `Model`/`Fit` API we have in place. GGT!

For now, this PR only implements cross-validation for CSD and for the tensor model, but future work could extend this to other models, by implementing their `predict` methods. 

Also : a lot of PEP8 fixes in the CSD module and elsewhere :-) 
OK - I moved the classes back to the top of the file. We can have the
discussion about the general policy some other time.


On Wed, Jul 2, 2014 at 12:22 PM, Eleftherios Garyfallidis <
notifications@github.com> wrote:

> In dipy/reconst/csdeconv.py:
>
> > +    if np.iterable(S0):
> > +        # If it's an array, we need to give it one more dimension:
> > +        S0 = S0[..., None]
> > +
> > +    # This is the key operation: convolve and multiply by S0:
> > +    pre_pred_sig = S0 * np.dot(predict_matrix, sh_coeff)
> > +
> > +    # Now put everything in its right place:
> > +    pred_sig = np.zeros(pre_pred_sig.shape[:-1] + (gtab.bvals.shape[0],))
> > +    pred_sig[..., ~gtab.b0s_mask] = pre_pred_sig
> > +    pred_sig[..., gtab.b0s_mask] = S0
> > +
> > +    return pred_sig
> > +
> > +
> > +class ConstrainedSphericalDeconvModel(OdfModel, Cache):
>
> Yes, you asked me to change the CSD class to put it on the top of the file.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/nipy/dipy/pull/335/files#r14477908>.
>