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 :-) 
I've found that it's helpful to know where to look for something. If you
see something (a function, variable, etc.) being used in code, you know you
will always find it defined, allocated, or imported somewhere earlier in
the file. So, you *always* know which way to search.


On Wed, Jun 18, 2014 at 5:05 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):
>
> Well... @stefanv <https://github.com/stefanv> may have a different
> opinion on that. Also this rule makes sense for C code but not for Python.
>
> I personally think that when classes are defined at the top it is easier
> to get to the most important parts of the code faster. The CSDModel is a
> good example.
> But because people reviewing my code have asked me in the past to put
> classes'
> definitions at the top and I started using this style... I saw the
> benefits myself and
> I wanted to share this experience with you too.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/nipy/dipy/pull/335/files#r13947669>.
>