Call a custom solver on evoked data. This function does all the necessary computation: - to select the channels in the forward given the available ones in the data - to take into account the noise covariance and do the spatial whitening - to apply loose orientation constraint
(solver, evoked, forward, noise_cov, loose=0.2, depth=0.8)
| 56 | |
| 57 | |
| 58 | def apply_solver(solver, evoked, forward, noise_cov, loose=0.2, depth=0.8): |
| 59 | """Call a custom solver on evoked data. |
| 60 | |
| 61 | This function does all the necessary computation: |
| 62 | |
| 63 | - to select the channels in the forward given the available ones in |
| 64 | the data |
| 65 | - to take into account the noise covariance and do the spatial whitening |
| 66 | - to apply loose orientation constraint as MNE solvers |
| 67 | - to apply a weigthing of the columns of the forward operator as in the |
| 68 | weighted Minimum Norm formulation in order to limit the problem |
| 69 | of depth bias. |
| 70 | |
| 71 | Parameters |
| 72 | ---------- |
| 73 | solver : callable |
| 74 | The solver takes 3 parameters: data M, gain matrix G, number of |
| 75 | dipoles orientations per location (1 or 3). A solver shall return |
| 76 | 2 variables: X which contains the time series of the active dipoles |
| 77 | and an active set which is a boolean mask to specify what dipoles are |
| 78 | present in X. |
| 79 | evoked : instance of mne.Evoked |
| 80 | The evoked data |
| 81 | forward : instance of Forward |
| 82 | The forward solution. |
| 83 | noise_cov : instance of Covariance |
| 84 | The noise covariance. |
| 85 | loose : float in [0, 1] | 'auto' |
| 86 | Value that weights the source variances of the dipole components |
| 87 | that are parallel (tangential) to the cortical surface. If loose |
| 88 | is 0 then the solution is computed with fixed orientation. |
| 89 | If loose is 1, it corresponds to free orientations. |
| 90 | The default value ('auto') is set to 0.2 for surface-oriented source |
| 91 | space and set to 1.0 for volumic or discrete source space. |
| 92 | depth : None | float in [0, 1] |
| 93 | Depth weighting coefficients. If None, no depth weighting is performed. |
| 94 | |
| 95 | Returns |
| 96 | ------- |
| 97 | stc : instance of SourceEstimate |
| 98 | The source estimates. |
| 99 | """ |
| 100 | # Import the necessary private functions |
| 101 | from mne.inverse_sparse.mxne_inverse import ( |
| 102 | _make_sparse_stc, |
| 103 | _prepare_gain, |
| 104 | _reapply_source_weighting, |
| 105 | is_fixed_orient, |
| 106 | ) |
| 107 | |
| 108 | all_ch_names = evoked.ch_names |
| 109 | |
| 110 | # Handle depth weighting and whitening (here is no weights) |
| 111 | forward, gain, gain_info, whitener, source_weighting, mask = _prepare_gain( |
| 112 | forward, |
| 113 | evoked.info, |
| 114 | noise_cov, |
| 115 | pca=False, |
no test coverage detected