Skip to main content

FwdBemSolution

Namespace: FWDLIB  ·  Library: Forward Library

#include <fwd/fwd_bem_solution.h>

class FWDLIB::FwdBemSolution

Implements a Forward BEM Solution (replaces fwdBemSolution / fwdBemSolutionRec from MNE-C fwd_types.h).

Channel-specific projection that contracts a BEM node-potential vector down to one entry per MEG coil or EEG electrode — i.e. the Geselowitz surface-integral weights cached as a dense ncoil × np matrix.

src/examples/ex_fwd_api/main.cpp
auto bem = FwdBemModel::fwd_bem_load_homog_surface(data + "/subjects/sample/bem/sample-5120-bem.fif");
bem->fwd_bem_load_recompute_solution(data + "/subjects/sample/bem/sample-5120-bem-sol.fif", FWD_BEM_LINEAR_COLL, 0);
bem->fwd_bem_set_head_mri_t(FiffCoordTrans::readMriTransform(data + "/MEG/sample/all-trans.fif"));
bem->fwd_bem_specify_coils(coils.get()); // stores a FwdBemSolution per coil set in coils->user_data
VectorXf B(coils->ncoil());
FwdBemModel::fwd_bem_field(rd, Q, *coils, B, bem.get()); // T per A m

Public Methods​

FwdBemSolution()​

Constructs the Forward BEM Solution.


~FwdBemSolution()​

Destroys the Forward BEM Solution.


Example​

Used in examples​

ex_fwd_api​

Forward library: coil definitions, BEM and sphere models, field maps and forward solutions.

src/examples/ex_fwd_api/main.cpp, line 130
auto bem = FwdBemModel::fwd_bem_load_homog_surface(data + "/subjects/sample/bem/sample-5120-bem.fif");
bem->fwd_bem_load_recompute_solution(data + "/subjects/sample/bem/sample-5120-bem-sol.fif", FWD_BEM_LINEAR_COLL, 0);
bem->fwd_bem_set_head_mri_t(FiffCoordTrans::readMriTransform(data + "/MEG/sample/all-trans.fif"));
bem->fwd_bem_specify_coils(coils.get()); // stores a FwdBemSolution per coil set in coils->user_data
VectorXf B(coils->ncoil());
FwdBemModel::fwd_bem_field(rd, Q, *coils, B, bem.get()); // T per A m
// mne.make_forward_dipole with the same BEM: |B| = 2.3646584e-4, B[0] = -7.2922803e-6
ok &= expect(coils->user_data && coils->user_data->ncoil == 306 && near(B.norm(), 2.3646584e-4, 1e-3) && near(B[0], -7.2922803e-6, 1e-2),
"FwdBemModel/FwdBemSolution: single-layer BEM field matches mne.make_forward_dipole");

Authors of this file​