mne-tools/mne-python — pull request #776 by Eric89GXL (2013-09-23 18:24:52+00:00)
Title: WIP ENH: Forward solution in python

I had some free time last week, so I ported some of Matti's code. I think the initial setup is working -- I've checked that specifying `mindist` works, as it seems to get the same result as the C code. Right now, the code gets to the point of composing the field computation matrix, and that takes forever, so I haven't debugged anything beyond that point (I've just translated the necessary code). There are a few things also not implemented, including EEG sphere model (for simplicity), label specification (for simplicity), and compensation (because I don't understand it).

I'm mostly posting this so @mluessi can have a look, and see if he wants to help me make things more efficient :) The big hangup is currently with the field computation matrix calculation, namely `_bem_specify_coils` (and thus in `_bem_lin_field_coeff` / `_bem_lin_field_coeff_simple`) in `_compute_forward.py`. In case anyone wants to try it, I'd suggest making an `oct-2` source space for sample (e.g., `mne_setup_source_space --subject sample --oct 2`) and then running:

```
import mne
path = mne.datasets.sample.data_path()
subjects_dir = path + '/subjects'
bem = path + '/subjects/sample/bem/sample-5120-bem-sol.fif'
meas = path + '/MEG/sample/sample_audvis_raw.fif'
src = path + '/subjects/sample/bem/sample-oct-2-src.fif'
mri = path + '/MEG/sample/sample_audvis_raw-trans.fif'
y = mne.forward.do_forward_solution2('sample', meas, bem=bem, src=src,
mri=mri, subjects_dir=subjects_dir,
mindist=10.0, eeg=False, verbose=True)
```