mne-tools/mne-python — pull request #802 by Eric89GXL (2013-10-10 22:04:48+00:00)
Title: WIP ENH: Add source-space distances

It would be nice to have the ability to add source space distances along the cortical surface in `mne-python`. This moves us in that direction using a fast `sklearn` algorithm. Using `n_jobs=2` (one for each hemi) on fsaverage's grade-5 source space (10242 per hemi), it only takes 68 seconds to calculate **all** of the distances between points in each source space, which is awesome.

Before proceeding, I need feedback on:

1. If we want to use `networkx`, and in a related issue...
2. Decide if we want to add `dist_limit` parameter like in the C code.
3. Decide if we want to use the same function, or a different one, for computing distances for volume / discrete source spaces.

If we want to add `dist_limit` capabilities like in the C code, there is no way to limit the calculations done by `sklearn` (current implementation). Thus we would just have to calculate everything, then limit it afterward (which seems inefficient and a bit silly). There is an implementation also in the package `networkx` that allows for setting a maximum, and if I use something reasonable like 1cm it takes only about 10 seconds to run. However, this algorithm is much slower than `sklearn` once more than ~2-3cm is used as `dist_limit`. It would also add another dependecy, which isn't great.

I lean toward just using `sklearn` and always doing all distances and saving them, since this in principle only needs to be done once for each subject, when creating the source space. What do people think?

On the last point about vol/discrete, I think it makes sense to make this function be "smart" where it uses surface distances for surface source spaces and euclidean for volume / discrete ones, but maybe we just want to start with surface for now (since it's the more complicated example).