v2.0.0
Loading...
Searching...
No Matches
FWDLIB::FwdBemModel Class Reference

BEM (Boundary Element Method) model definition. More...

#include <fwd_bem_model.h>

Public Types

typedef std::unique_ptr< FwdBemModelUPtr
typedef void(* linFieldIntFunc) (const Eigen::Vector3f &dest, const Eigen::Vector3f &dir, MNELIB::MNETriangle &tri, Eigen::Vector3d &res)
 Function pointer type for linear field coefficient integration methods.

Public Member Functions

 FwdBemModel ()
 Constructs an empty BEM model.
virtual ~FwdBemModel ()
 Destroys the BEM model.
void fwd_bem_free_solution ()
 Release the potential solution matrix and associated workspace.
MNELIB::MNESurfacefwd_bem_find_surface (int kind)
 Find a surface of the given kind in this BEM model.
int fwd_bem_load_solution (const QString &name, int bem_method)
 Load a pre-computed BEM solution from a FIFF file.
int fwd_bem_set_head_mri_t (const FIFFLIB::FiffCoordTrans &t)
 Set the Head-to-MRI coordinate transform for this BEM model.
int fwd_bem_linear_collocation_solution ()
 Compute the linear-collocation BEM solution for this model.
int fwd_bem_constant_collocation_solution ()
 Compute the constant-collocation BEM solution for this model.
int fwd_bem_compute_solution (int bem_method)
 Compute the BEM solution matrix using the specified method.
int fwd_bem_load_recompute_solution (const QString &name, int bem_method, int force_recompute)
 Load a BEM solution from file, recomputing if necessary.
int fwd_bem_specify_els (FwdCoilSet *els)
 Precompute the electrode-specific BEM solution.
void fwd_bem_pot_grad_calc (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet *els, int all_surfs, Eigen::Ref< Eigen::VectorXf > xgrad, Eigen::Ref< Eigen::VectorXf > ygrad, Eigen::Ref< Eigen::VectorXf > zgrad)
 Compute the gradient of BEM potentials with respect to dipole position (constant collocation).
void fwd_bem_lin_pot_calc (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet *els, int all_surfs, Eigen::Ref< Eigen::VectorXf > pot)
 Compute BEM potentials at electrodes using linear collocation.
void fwd_bem_lin_pot_grad_calc (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet *els, int all_surfs, Eigen::Ref< Eigen::VectorXf > xgrad, Eigen::Ref< Eigen::VectorXf > ygrad, Eigen::Ref< Eigen::VectorXf > zgrad)
 Compute the gradient of BEM potentials with respect to dipole position (linear collocation).
void fwd_bem_pot_calc (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet *els, int all_surfs, Eigen::Ref< Eigen::VectorXf > pot)
 Compute BEM potentials at electrodes using constant collocation.
Eigen::MatrixXf fwd_bem_field_coeff (FwdCoilSet *coils)
 Assemble the constant-collocation magnetic field coefficient matrix.
Eigen::MatrixXf fwd_bem_lin_field_coeff (FwdCoilSet *coils, int method)
 Assemble the linear-collocation magnetic field coefficient matrix.
int fwd_bem_specify_coils (FwdCoilSet *coils)
 Precompute the coil-specific BEM solution for MEG.
void fwd_bem_lin_field_calc (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > B)
 Compute BEM magnetic fields at coils using linear collocation.
void fwd_bem_field_calc (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > B)
 Compute BEM magnetic fields at coils using constant collocation.
void fwd_bem_field_grad_calc (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > xgrad, Eigen::Ref< Eigen::VectorXf > ygrad, Eigen::Ref< Eigen::VectorXf > zgrad)
 Compute the gradient of BEM magnetic fields with respect to dipole position (constant collocation).
void fwd_bem_lin_field_grad_calc (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > xgrad, Eigen::Ref< Eigen::VectorXf > ygrad, Eigen::Ref< Eigen::VectorXf > zgrad)
 Compute the gradient of BEM magnetic fields with respect to dipole position (linear collocation).
int compute_forward_meg (std::vector< std::unique_ptr< MNELIB::MNESourceSpace > > &spaces, FwdCoilSet *coils, FwdCoilSet *comp_coils, MNELIB::MNECTFCompDataSet *comp_data, bool fixed_ori, const Eigen::Vector3f &r0, bool use_threads, FIFFLIB::FiffNamedMatrix &resp, FIFFLIB::FiffNamedMatrix &resp_grad, bool bDoGRad)
 Compute the MEG forward solution for one or more source spaces.
int compute_forward_eeg (std::vector< std::unique_ptr< MNELIB::MNESourceSpace > > &spaces, FwdCoilSet *els, bool fixed_ori, FwdEegSphereModel *eeg_model, bool use_threads, FIFFLIB::FiffNamedMatrix &resp, FIFFLIB::FiffNamedMatrix &resp_grad, bool bDoGrad)
 Compute the EEG forward solution for one or more source spaces.

Static Public Member Functions

static QString fwd_bem_make_bem_sol_name (const QString &name)
 Build a standard BEM solution file name from a model name.
static const QString & fwd_bem_explain_surface (int kind)
 Return a human-readable label for a BEM surface kind.
static const QString & fwd_bem_explain_method (int method)
 Return a human-readable label for a BEM method.
static int get_int (FIFFLIB::FiffStream::SPtr &stream, const FIFFLIB::FiffDirNode::SPtr &node, int what, int *res)
 Read an integer tag from a FIFF node.
static FwdBemModel::UPtr fwd_bem_load_surfaces (const QString &name, const std::vector< int > &kinds)
 Load BEM surfaces of specified kinds from a FIFF file.
static FwdBemModel::UPtr fwd_bem_load_homog_surface (const QString &name)
 Load a single-layer (homogeneous) BEM model from a FIFF file.
static FwdBemModel::UPtr fwd_bem_load_three_layer_surfaces (const QString &name)
 Load a three-layer BEM model (scalp, outer skull, inner skull) from a FIFF file.
static std::unique_ptr< MNELIB::MNESurfacemake_guesses (MNELIB::MNESurface *guess_surf, float guessrad, const Eigen::Vector3f &guess_r0, float grid, float exclude, float mindist)
 Generate a set of dipole guess locations inside a boundary surface.
static double calc_beta (const Eigen::Vector3d &rk, const Eigen::Vector3d &rk1)
 Compute the beta angle used in the linear collocation integration.
static void lin_pot_coeff (const Eigen::Vector3f &from, MNELIB::MNETriangle &to, Eigen::Vector3d &omega)
 Compute the linear potential coefficients for one source-destination pair.
static void correct_auto_elements (MNELIB::MNESurface &surf, Eigen::MatrixXf &mat)
 Correct the auto (self-coupling) elements of the linear collocation matrix.
static Eigen::MatrixXf fwd_bem_lin_pot_coeff (const std::vector< MNELIB::MNESurface * > &surfs)
 Assemble the full linear-collocation potential coefficient matrix.
static Eigen::MatrixXf fwd_bem_multi_solution (Eigen::MatrixXf &solids, const Eigen::MatrixXf *gamma, int nsurf, const Eigen::VectorXi &ntri)
 Compute the multi-surface BEM solution from solid-angle coefficients.
static Eigen::MatrixXf fwd_bem_homog_solution (Eigen::MatrixXf &solids, int ntri)
 Compute the homogeneous (single-layer) BEM solution.
static void fwd_bem_ip_modify_solution (Eigen::MatrixXf &solution, Eigen::MatrixXf &ip_solution, float ip_mult, int nsurf, const Eigen::VectorXi &ntri)
 Modify the BEM solution with the isolated-problem (IP) approach.
static int fwd_bem_check_solids (const Eigen::MatrixXf &angles, int ntri1, int ntri2, float desired)
 Verify that solid-angle sums match the expected value.
static Eigen::MatrixXf fwd_bem_solid_angles (const std::vector< MNELIB::MNESurface * > &surfs)
 Compute the solid-angle matrix for all BEM surfaces.
static float fwd_bem_inf_field (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, const Eigen::Vector3f &rp, const Eigen::Vector3f &dir)
 Compute the infinite-medium magnetic field at a single point.
static float fwd_bem_inf_pot (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, const Eigen::Vector3f &rp)
 Compute the infinite-medium electric potential at a single point.
static int fwd_bem_pot_els (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &els, Eigen::Ref< Eigen::VectorXf > pot, void *client)
 Callback: compute BEM potentials at electrodes for a dipole.
static int fwd_bem_pot_grad_els (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &els, Eigen::Ref< Eigen::VectorXf > pot, Eigen::Ref< Eigen::VectorXf > xgrad, Eigen::Ref< Eigen::VectorXf > ygrad, Eigen::Ref< Eigen::VectorXf > zgrad, void *client)
 Callback: compute BEM potentials and position gradients at electrodes.
static void calc_f (const Eigen::Vector3d &xx, const Eigen::Vector3d &yy, Eigen::Vector3d &f0, Eigen::Vector3d &fx, Eigen::Vector3d &fy)
 Compute the f0, fx, fy integration helper values from corner coordinates.
static void calc_magic (double u, double z, double A, double B, Eigen::Vector3d &beta, double &D)
 Compute the "magic" beta and D factors for the Urankar field integration.
static void field_integrals (const Eigen::Vector3f &from, MNELIB::MNETriangle &to, double &I1p, Eigen::Vector2d &T, Eigen::Vector2d &S1, Eigen::Vector2d &S2, Eigen::Vector3d &f0, Eigen::Vector3d &fx, Eigen::Vector3d &fy)
 Compute the geometry integrals for the magnetic field from a triangle.
static double one_field_coeff (const Eigen::Vector3f &dest, const Eigen::Vector3f &normal, MNELIB::MNETriangle &tri)
 Compute the constant-collocation magnetic field coefficient for one triangle.
static double calc_gamma (const Eigen::Vector3d &rk, const Eigen::Vector3d &rk1)
 Compute the gamma angle for the linear field integration (Ferguson).
static void fwd_bem_one_lin_field_coeff_ferg (const Eigen::Vector3f &dest, const Eigen::Vector3f &dir, MNELIB::MNETriangle &tri, Eigen::Vector3d &res)
 Compute linear field coefficients using the Ferguson method.
static void fwd_bem_one_lin_field_coeff_uran (const Eigen::Vector3f &dest, const Eigen::Vector3f &dir, MNELIB::MNETriangle &tri, Eigen::Vector3d &res)
 Compute linear field coefficients using the Urankar method.
static void fwd_bem_one_lin_field_coeff_simple (const Eigen::Vector3f &dest, const Eigen::Vector3f &normal, MNELIB::MNETriangle &source, Eigen::Vector3d &res)
 Compute linear field coefficients using the simple (direct) method.
static float fwd_bem_inf_field_der (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, const Eigen::Vector3f &rp, const Eigen::Vector3f &dir, const Eigen::Vector3f &comp)
 Compute the derivative of the infinite-medium magnetic field with respect to dipole position.
static float fwd_bem_inf_pot_der (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, const Eigen::Vector3f &rp, const Eigen::Vector3f &comp)
 Compute the derivative of the infinite-medium electric potential with respect to dipole position.
static int fwd_bem_field (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > B, void *client)
 Callback: compute BEM magnetic fields at coils for a dipole.
static int fwd_bem_field_grad (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > Bval, Eigen::Ref< Eigen::VectorXf > xgrad, Eigen::Ref< Eigen::VectorXf > ygrad, Eigen::Ref< Eigen::VectorXf > zgrad, void *client)
 Callback: compute BEM magnetic fields and position gradients at coils.
static void meg_eeg_fwd_one_source_space (FwdThreadArg *arg)
 Thread worker: compute the forward solution for one source space.
static int fwd_sphere_field (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > Bval, void *client)
 Callback: compute the spherical-model magnetic field at coils.
static int fwd_sphere_field_vec (const Eigen::Vector3f &rd, FwdCoilSet &coils, Eigen::Ref< Eigen::MatrixXf > Bval, void *client)
 Callback: compute the spherical-model vector magnetic field at coils.
static int fwd_sphere_field_grad (const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > Bval, Eigen::Ref< Eigen::VectorXf > xgrad, Eigen::Ref< Eigen::VectorXf > ygrad, Eigen::Ref< Eigen::VectorXf > zgrad, void *client)
 Callback: compute the spherical-model magnetic field and its position gradient at coils.
static int fwd_mag_dipole_field (const Eigen::Vector3f &rm, const Eigen::Vector3f &M, FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > Bval, void *client)
 Callback: compute the magnetic field of a magnetic dipole at coils.
static int fwd_mag_dipole_field_vec (const Eigen::Vector3f &rm, FwdCoilSet &coils, Eigen::Ref< Eigen::MatrixXf > Bval, void *client)
 Callback: compute the vector magnetic field of a magnetic dipole at coils.

Public Attributes

QString surf_name
std::vector< std::shared_ptr< MNELIB::MNESurface > > surfs
Eigen::VectorXi ntri
Eigen::VectorXi np
int nsurf
Eigen::VectorXf sigma
Eigen::MatrixXf gamma
Eigen::VectorXf source_mult
Eigen::VectorXf field_mult
int bem_method
QString sol_name
Eigen::MatrixXf solution
Eigen::VectorXf v0
int nsol
FIFFLIB::FiffCoordTrans head_mri_t
float ip_approach_limit
bool use_ip_approach

Static Public Attributes

static constexpr double MAG_FACTOR = 1e-7

Detailed Description

BEM (Boundary Element Method) model definition.

Holds the BEM model surfaces, conductivity parameters, and potential solution matrix used in MEG/EEG forward computations. Surfaces are stored from outermost to innermost and owned by this object.

Refactored from the MNE-C fwdBemModel / fwdBemModelRec struct (fwd_types.h). Raw C-style arrays replaced with Eigen types; surface ownership managed through std::unique_ptr.

Definition at line 128 of file fwd_bem_model.h.

Member Typedef Documentation

◆ linFieldIntFunc

typedef void(* FWDLIB::FwdBemModel::linFieldIntFunc) (const Eigen::Vector3f &dest, const Eigen::Vector3f &dir, MNELIB::MNETriangle &tri, Eigen::Vector3d &res)

Function pointer type for linear field coefficient integration methods.

Definition at line 721 of file fwd_bem_model.h.

◆ UPtr

typedef std::unique_ptr<FwdBemModel> FWDLIB::FwdBemModel::UPtr

Unique pointer type for FwdBemModel.

Definition at line 131 of file fwd_bem_model.h.

Constructor & Destructor Documentation

◆ FwdBemModel()

FwdBemModel::FwdBemModel ( )
explicit

Constructs an empty BEM model.

All Eigen containers are left at size zero; scalar members are set to safe defaults (nsurf = 0, nsol = 0, bem_method = FWD_BEM_UNKNOWN).

Definition at line 184 of file fwd_bem_model.cpp.

◆ ~FwdBemModel()

FwdBemModel::~FwdBemModel ( )
virtual

Destroys the BEM model.

FsSurface ownership is released automatically via std::unique_ptr. The solution matrix is freed by fwd_bem_free_solution().

Definition at line 196 of file fwd_bem_model.cpp.

Member Function Documentation

◆ calc_beta()

double FwdBemModel::calc_beta ( const Eigen::Vector3d & rk,
const Eigen::Vector3d & rk1 )
static

Compute the beta angle used in the linear collocation integration.

Parameters
[in]rkPosition vector of vertex k.
[in]rk1Position vector of vertex k+1.
Returns
The beta angle value.

Definition at line 538 of file fwd_bem_model.cpp.

◆ calc_f()

void FwdBemModel::calc_f ( const Eigen::Vector3d & xx,
const Eigen::Vector3d & yy,
Eigen::Vector3d & f0,
Eigen::Vector3d & fx,
Eigen::Vector3d & fy )
static

Compute the f0, fx, fy integration helper values from corner coordinates.

Parameters
[in]xxCorner x-coordinates.
[in]yyCorner y-coordinates.
[out]f0Integral f0.
[out]fxIntegral fx.
[out]fyIntegral fy.

Definition at line 1539 of file fwd_bem_model.cpp.

◆ calc_gamma()

double FwdBemModel::calc_gamma ( const Eigen::Vector3d & rk,
const Eigen::Vector3d & rk1 )
static

Compute the gamma angle for the linear field integration (Ferguson).

Parameters
[in]rkPosition vector of vertex k.
[in]rk1Position vector of vertex k+1.
Returns
The gamma angle value.

Definition at line 1783 of file fwd_bem_model.cpp.

◆ calc_magic()

void FwdBemModel::calc_magic ( double u,
double z,
double A,
double B,
Eigen::Vector3d & beta,
double & D )
static

Compute the "magic" beta and D factors for the Urankar field integration.

Parameters
[in]uCoordinate u.
[in]zCoordinate z.
[in]AParameter A.
[in]BParameter B.
[out]betaOutput beta factor.
[out]DOutput D factor.

Definition at line 1563 of file fwd_bem_model.cpp.

◆ compute_forward_eeg()

int FwdBemModel::compute_forward_eeg ( std::vector< std::unique_ptr< MNELIB::MNESourceSpace > > & spaces,
FwdCoilSet * els,
bool fixed_ori,
FwdEegSphereModel * eeg_model,
bool use_threads,
FIFFLIB::FiffNamedMatrix & resp,
FIFFLIB::FiffNamedMatrix & resp_grad,
bool bDoGrad )

Compute the EEG forward solution for one or more source spaces.

Parameters
[in]spacesSource spaces.
[in]elsElectrode locations.
[in]fixed_oriIf true, use fixed-orientation dipoles.
[in]eeg_modelSphere model definition.
[in]use_threadsIf true, parallelize across source spaces.
[out]respForward solution matrix.
[out]resp_gradGradient forward solution matrix.
[in]bDoGradIf true, also compute the gradient solution.
Returns
OK on success, FAIL on error.

Definition at line 2815 of file fwd_bem_model.cpp.

◆ compute_forward_meg()

int FwdBemModel::compute_forward_meg ( std::vector< std::unique_ptr< MNELIB::MNESourceSpace > > & spaces,
FwdCoilSet * coils,
FwdCoilSet * comp_coils,
MNELIB::MNECTFCompDataSet * comp_data,
bool fixed_ori,
const Eigen::Vector3f & r0,
bool use_threads,
FIFFLIB::FiffNamedMatrix & resp,
FIFFLIB::FiffNamedMatrix & resp_grad,
bool bDoGRad )

Compute the MEG forward solution for one or more source spaces.

Parameters
[in]spacesSource spaces.
[in]coilsMEG coil set.
[in]comp_coilsCompensator coil set (may be nullptr).
[in]comp_dataCTF compensation data (may be nullptr).
[in]fixed_oriIf true, use fixed-orientation dipoles.
[in]r0Sphere model origin.
[in]use_threadsIf true, parallelize across source spaces.
[out]respForward solution matrix.
[out]resp_gradGradient forward solution matrix.
[in]bDoGRadIf true, also compute the gradient solution.
Returns
OK on success, FAIL on error.

Definition at line 2577 of file fwd_bem_model.cpp.

◆ correct_auto_elements()

void FwdBemModel::correct_auto_elements ( MNELIB::MNESurface & surf,
Eigen::MatrixXf & mat )
static

Correct the auto (self-coupling) elements of the linear collocation matrix.

Parameters
[in]surfThe BEM surface.
[in,out]matThe coefficient matrix to correct (modified in-place).

Definition at line 645 of file fwd_bem_model.cpp.

◆ field_integrals()

void FwdBemModel::field_integrals ( const Eigen::Vector3f & from,
MNELIB::MNETriangle & to,
double & I1p,
Eigen::Vector2d & T,
Eigen::Vector2d & S1,
Eigen::Vector2d & S2,
Eigen::Vector3d & f0,
Eigen::Vector3d & fx,
Eigen::Vector3d & fy )
static

Compute the geometry integrals for the magnetic field from a triangle.

Parameters
[in]fromSource point.
[in]toDestination triangle.
[out]I1pMonopolar integral.
[out]TIntegral T.
[out]S1Integral S1.
[out]S2Integral S2.
[out]f0Integral f0.
[out]fxIntegral fx.
[out]fyIntegral fy.

Definition at line 1575 of file fwd_bem_model.cpp.

◆ fwd_bem_check_solids()

int FwdBemModel::fwd_bem_check_solids ( const Eigen::MatrixXf & angles,
int ntri1,
int ntri2,
float desired )
static

Verify that solid-angle sums match the expected value.

Parameters
[in]anglesSolid-angle matrix.
[in]ntri1Row count.
[in]ntri2Column count.
[in]desiredExpected solid-angle sum per row.
Returns
OK if all rows match within tolerance, FAIL otherwise.

Definition at line 959 of file fwd_bem_model.cpp.

◆ fwd_bem_compute_solution()

int FwdBemModel::fwd_bem_compute_solution ( int bem_method)

Compute the BEM solution matrix using the specified method.

Parameters
[in]bem_methodBEM method (FWD_BEM_CONSTANT_COLL or FWD_BEM_LINEAR_COLL).
Returns
OK on success, FAIL on error.

Definition at line 1112 of file fwd_bem_model.cpp.

◆ fwd_bem_constant_collocation_solution()

int FwdBemModel::fwd_bem_constant_collocation_solution ( )

Compute the constant-collocation BEM solution for this model.

Returns
OK on success, FAIL on error.

Definition at line 1044 of file fwd_bem_model.cpp.

◆ fwd_bem_explain_method()

const QString & FwdBemModel::fwd_bem_explain_method ( int method)
static

Return a human-readable label for a BEM method.

Parameters
[in]methodBEM method constant (FWD_BEM_CONSTANT_COLL / FWD_BEM_LINEAR_COLL).
Returns
Reference to a static string label.

Definition at line 244 of file fwd_bem_model.cpp.

◆ fwd_bem_explain_surface()

const QString & FwdBemModel::fwd_bem_explain_surface ( int kind)
static

Return a human-readable label for a BEM surface kind.

Parameters
[in]kindFIFF surface ID (e.g. FIFFV_BEM_SURF_ID_BRAIN).
Returns
Reference to a static string label.

Definition at line 231 of file fwd_bem_model.cpp.

◆ fwd_bem_field()

int FwdBemModel::fwd_bem_field ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > B,
void * client )
static

Callback: compute BEM magnetic fields at coils for a dipole.

Dispatches to fwd_bem_field_calc or fwd_bem_lin_field_calc based on the current BEM method. Matches the fwdFieldFunc signature.

Parameters
[in]rdDipole position (3-element array).
[in]QDipole orientation (3-element array).
[in]coilsMEG coil descriptors.
[out]BOutput magnetic fields.
[in]clientOpaque pointer to the FwdBemModel instance.
Returns
OK on success, FAIL on error.

Definition at line 2344 of file fwd_bem_model.cpp.

◆ fwd_bem_field_calc()

void FwdBemModel::fwd_bem_field_calc ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > B )

Compute BEM magnetic fields at coils using constant collocation.

Parameters
[in]rdDipole position.
[in]QDipole orientation.
[in]coilsMEG coil set.
[out]BOutput magnetic fields (one value per coil).

Definition at line 2090 of file fwd_bem_model.cpp.

◆ fwd_bem_field_coeff()

Eigen::MatrixXf FwdBemModel::fwd_bem_field_coeff ( FwdCoilSet * coils)

Assemble the constant-collocation magnetic field coefficient matrix.

Parameters
[in]coilsMEG coil set.
Returns
Coefficient matrix, or empty matrix on error.

Definition at line 1716 of file fwd_bem_model.cpp.

◆ fwd_bem_field_grad()

int FwdBemModel::fwd_bem_field_grad ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > Bval,
Eigen::Ref< Eigen::VectorXf > xgrad,
Eigen::Ref< Eigen::VectorXf > ygrad,
Eigen::Ref< Eigen::VectorXf > zgrad,
void * client )
static

Callback: compute BEM magnetic fields and position gradients at coils.

Matches the fwdFieldGradFunc signature for use in forward computation threads.

Parameters
[in]rdDipole position (3-element array).
[in]QDipole orientation (3-element array).
[in]coilsMEG coil definitions.
[out]BvalOutput magnetic fields.
[out]xgradGradient with respect to x.
[out]ygradGradient with respect to y.
[out]zgradGradient with respect to z.
[in]clientOpaque pointer to the FwdBemModel instance.
Returns
OK on success, FAIL on error.

Definition at line 2377 of file fwd_bem_model.cpp.

◆ fwd_bem_field_grad_calc()

void FwdBemModel::fwd_bem_field_grad_calc ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > xgrad,
Eigen::Ref< Eigen::VectorXf > ygrad,
Eigen::Ref< Eigen::VectorXf > zgrad )

Compute the gradient of BEM magnetic fields with respect to dipole position (constant collocation).

Parameters
[in]rdDipole position.
[in]QDipole orientation.
[in]coilsMEG coil set.
[out]xgradGradient with respect to x (one value per coil).
[out]ygradGradient with respect to y.
[out]zgradGradient with respect to z.

Definition at line 2154 of file fwd_bem_model.cpp.

◆ fwd_bem_find_surface()

MNESurface * FwdBemModel::fwd_bem_find_surface ( int kind)

Find a surface of the given kind in this BEM model.

Parameters
[in]kindFsSurface ID to look for.
Returns
Non-owning pointer to the surface, or nullptr if not found.

Definition at line 277 of file fwd_bem_model.cpp.

◆ fwd_bem_free_solution()

void FwdBemModel::fwd_bem_free_solution ( )

Release the potential solution matrix and associated workspace.

Resets solution, v0, sol_name, nsol, and bem_method to their default (empty / unknown) state.

Definition at line 204 of file fwd_bem_model.cpp.

◆ fwd_bem_homog_solution()

Eigen::MatrixXf FwdBemModel::fwd_bem_homog_solution ( Eigen::MatrixXf & solids,
int ntri )
static

Compute the homogeneous (single-layer) BEM solution.

Parameters
[in]solidsSolid-angle coefficient matrix.
[in]ntriNumber of triangles.
Returns
Solution matrix, or empty matrix on error.

Definition at line 889 of file fwd_bem_model.cpp.

◆ fwd_bem_inf_field()

float FwdBemModel::fwd_bem_inf_field ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
const Eigen::Vector3f & rp,
const Eigen::Vector3f & dir )
static

Compute the infinite-medium magnetic field at a single point.

Returns the component of the magnetic field along the given direction, without the mu_0 / (4 pi) prefactor.

Parameters
[in]rdDipole position.
[in]QDipole moment.
[in]rpField point.
[in]dirField direction of interest (unit vector).
Returns
The infinite-medium magnetic field component.

Definition at line 1160 of file fwd_bem_model.cpp.

◆ fwd_bem_inf_field_der()

float FwdBemModel::fwd_bem_inf_field_der ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
const Eigen::Vector3f & rp,
const Eigen::Vector3f & dir,
const Eigen::Vector3f & comp )
static

Compute the derivative of the infinite-medium magnetic field with respect to dipole position.

Returns the field derivative without the mu_0 / (4 pi) prefactor.

Parameters
[in]rdDipole position.
[in]QDipole moment.
[in]rpField point.
[in]dirField direction of interest (unit vector).
[in]compGradient component direction (unit vector).
Returns
The field derivative value.

Definition at line 2232 of file fwd_bem_model.cpp.

◆ fwd_bem_inf_pot()

float FwdBemModel::fwd_bem_inf_pot ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
const Eigen::Vector3f & rp )
static

Compute the infinite-medium electric potential at a single point.

Returns the potential without the 1 / (4 pi sigma) prefactor.

Parameters
[in]rdDipole position.
[in]QDipole moment.
[in]rpPotential evaluation point.
Returns
The infinite-medium electric potential.

Definition at line 1175 of file fwd_bem_model.cpp.

◆ fwd_bem_inf_pot_der()

float FwdBemModel::fwd_bem_inf_pot_der ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
const Eigen::Vector3f & rp,
const Eigen::Vector3f & comp )
static

Compute the derivative of the infinite-medium electric potential with respect to dipole position.

Parameters
[in]rdDipole position.
[in]QDipole moment.
[in]rpPotential evaluation point.
[in]compGradient component direction (unit vector).
Returns
The potential derivative value.

Definition at line 2250 of file fwd_bem_model.cpp.

◆ fwd_bem_ip_modify_solution()

void FwdBemModel::fwd_bem_ip_modify_solution ( Eigen::MatrixXf & solution,
Eigen::MatrixXf & ip_solution,
float ip_mult,
int nsurf,
const Eigen::VectorXi & ntri )
static

Modify the BEM solution with the isolated-problem (IP) approach.

Applies the correction for the innermost surface conductivity jump (the "isolated problem" approach of Hamalainen and Sarvas, 1989).

Parameters
[in,out]solutionThe original solution matrix (modified in-place).
[in]ip_solutionThe isolated-problem solution matrix.
[in]ip_multConductivity ratio for the IP correction.
[in]nsurfNumber of surfaces.
[in]ntriTriangle or node count per surface.

Definition at line 902 of file fwd_bem_model.cpp.

◆ fwd_bem_lin_field_calc()

void FwdBemModel::fwd_bem_lin_field_calc ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > B )

Compute BEM magnetic fields at coils using linear collocation.

Parameters
[in]rdDipole position.
[in]QDipole orientation.
[in]coilsMEG coil set.
[out]BOutput magnetic fields (one value per coil).

Definition at line 2028 of file fwd_bem_model.cpp.

◆ fwd_bem_lin_field_coeff()

Eigen::MatrixXf FwdBemModel::fwd_bem_lin_field_coeff ( FwdCoilSet * coils,
int method )

Assemble the linear-collocation magnetic field coefficient matrix.

Parameters
[in]coilsMEG coil set.
[in]methodIntegration method (FWD_BEM_LIN_FIELD_SIMPLE, _FERGUSON, or _URANKAR).
Returns
Coefficient matrix, or empty matrix on error.

Definition at line 1900 of file fwd_bem_model.cpp.

◆ fwd_bem_lin_field_grad_calc()

void FwdBemModel::fwd_bem_lin_field_grad_calc ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > xgrad,
Eigen::Ref< Eigen::VectorXf > ygrad,
Eigen::Ref< Eigen::VectorXf > zgrad )

Compute the gradient of BEM magnetic fields with respect to dipole position (linear collocation).

Parameters
[in]rdDipole position.
[in]QDipole orientation.
[in]coilsMEG coil set.
[out]xgradGradient with respect to x (one value per coil).
[out]ygradGradient with respect to y.
[out]zgradGradient with respect to z.

Definition at line 2267 of file fwd_bem_model.cpp.

◆ fwd_bem_lin_pot_calc()

void FwdBemModel::fwd_bem_lin_pot_calc ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet * els,
int all_surfs,
Eigen::Ref< Eigen::VectorXf > pot )

Compute BEM potentials at electrodes using linear collocation.

Parameters
[in]rdDipole position.
[in]QDipole orientation.
[in]elsElectrode set.
[in]all_surfsIf non-zero, compute on all surfaces.
[out]potOutput potentials (one value per electrode).

Definition at line 1324 of file fwd_bem_model.cpp.

◆ fwd_bem_lin_pot_coeff()

Eigen::MatrixXf FwdBemModel::fwd_bem_lin_pot_coeff ( const std::vector< MNELIB::MNESurface * > & surfs)
static

Assemble the full linear-collocation potential coefficient matrix.

Parameters
[in]surfsVector of BEM surfaces.
Returns
Coefficient matrix (rows = nodes, columns = nodes).

Definition at line 713 of file fwd_bem_model.cpp.

◆ fwd_bem_lin_pot_grad_calc()

void FwdBemModel::fwd_bem_lin_pot_grad_calc ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet * els,
int all_surfs,
Eigen::Ref< Eigen::VectorXf > xgrad,
Eigen::Ref< Eigen::VectorXf > ygrad,
Eigen::Ref< Eigen::VectorXf > zgrad )

Compute the gradient of BEM potentials with respect to dipole position (linear collocation).

Parameters
[in]rdDipole position.
[in]QDipole orientation.
[in]elsElectrode set.
[in]all_surfsIf non-zero, compute on all surfaces.
[out]xgradGradient with respect to x (one value per electrode).
[out]ygradGradient with respect to y.
[out]zgradGradient with respect to z.

Definition at line 1367 of file fwd_bem_model.cpp.

◆ fwd_bem_linear_collocation_solution()

int FwdBemModel::fwd_bem_linear_collocation_solution ( )

Compute the linear-collocation BEM solution for this model.

Returns
OK on success, FAIL on error.

Definition at line 779 of file fwd_bem_model.cpp.

◆ fwd_bem_load_homog_surface()

FwdBemModel::UPtr FwdBemModel::fwd_bem_load_homog_surface ( const QString & name)
static

Load a single-layer (homogeneous) BEM model from a FIFF file.

Convenience wrapper that loads only the inner skull surface.

Parameters
[in]namePath to the BEM FIFF file.
Returns
BEM model, or nullptr on failure.

Definition at line 356 of file fwd_bem_model.cpp.

◆ fwd_bem_load_recompute_solution()

int FwdBemModel::fwd_bem_load_recompute_solution ( const QString & name,
int bem_method,
int force_recompute )

Load a BEM solution from file, recomputing if necessary.

Attempts to read the pre-computed solution; if it is missing or force_recompute is set, computes a fresh solution.

Parameters
[in]namePath to the BEM model file.
[in]bem_methodRequired BEM method.
[in]force_recomputeIf non-zero, always recompute the solution.
Returns
OK on success, FAIL on error.

Definition at line 1132 of file fwd_bem_model.cpp.

◆ fwd_bem_load_solution()

int FwdBemModel::fwd_bem_load_solution ( const QString & name,
int bem_method )

Load a pre-computed BEM solution from a FIFF file.

Reads the solution matrix from disk and stores it in this model. The solution must match the requested BEM method.

Parameters
[in]namePath to the solution FIFF file.
[in]bem_methodRequired BEM method (FWD_BEM_CONSTANT_COLL or FWD_BEM_LINEAR_COLL).
Returns
true if loaded, false if not found, FAIL on error.

Definition at line 376 of file fwd_bem_model.cpp.

◆ fwd_bem_load_surfaces()

FwdBemModel::UPtr FwdBemModel::fwd_bem_load_surfaces ( const QString & name,
const std::vector< int > & kinds )
static

Load BEM surfaces of specified kinds from a FIFF file.

Parameters
[in]namePath to the BEM FIFF file.
[in]kindsFsSurface IDs to load (e.g. FIFFV_BEM_SURF_ID_BRAIN).
Returns
BEM model containing the requested surfaces, or nullptr on failure.

Definition at line 288 of file fwd_bem_model.cpp.

◆ fwd_bem_load_three_layer_surfaces()

FwdBemModel::UPtr FwdBemModel::fwd_bem_load_three_layer_surfaces ( const QString & name)
static

Load a three-layer BEM model (scalp, outer skull, inner skull) from a FIFF file.

Parameters
[in]namePath to the BEM FIFF file.
Returns
BEM model, or nullptr on failure.

Definition at line 366 of file fwd_bem_model.cpp.

◆ fwd_bem_make_bem_sol_name()

QString FwdBemModel::fwd_bem_make_bem_sol_name ( const QString & name)
static

Build a standard BEM solution file name from a model name.

Parameters
[in]nameBase BEM file name.
Returns
The derived solution file name.

Definition at line 215 of file fwd_bem_model.cpp.

◆ fwd_bem_multi_solution()

Eigen::MatrixXf FwdBemModel::fwd_bem_multi_solution ( Eigen::MatrixXf & solids,
const Eigen::MatrixXf * gamma,
int nsurf,
const Eigen::VectorXi & ntri )
static

Compute the multi-surface BEM solution from solid-angle coefficients.

Applies the deflation technique and LU decomposition to produce the final BEM solution matrix for a multi-compartment model.

Parameters
[in]solidsSolid-angle coefficient matrix.
[in]gammaConductivity-ratio coupling matrix (nullptr for homogeneous).
[in]nsurfNumber of surfaces.
[in]ntriTriangle or node count per surface.
Returns
Solution matrix, or empty matrix on error.

Definition at line 848 of file fwd_bem_model.cpp.

◆ fwd_bem_one_lin_field_coeff_ferg()

void FwdBemModel::fwd_bem_one_lin_field_coeff_ferg ( const Eigen::Vector3f & dest,
const Eigen::Vector3f & dir,
MNELIB::MNETriangle & tri,
Eigen::Vector3d & res )
static

Compute linear field coefficients using the Ferguson method.

Parameters
[in]destField point.
[in]dirField direction of interest (unit vector).
[in]triDestination triangle.
[out]resOutput coefficients for the three triangle vertices.

Definition at line 1794 of file fwd_bem_model.cpp.

◆ fwd_bem_one_lin_field_coeff_simple()

void FwdBemModel::fwd_bem_one_lin_field_coeff_simple ( const Eigen::Vector3f & dest,
const Eigen::Vector3f & normal,
MNELIB::MNETriangle & source,
Eigen::Vector3d & res )
static

Compute linear field coefficients using the simple (direct) method.

Parameters
[in]destDestination field point.
[in]normalField direction of interest (unit vector).
[in]sourceSource triangle.
[out]resOutput coefficients for the three triangle vertices.

Definition at line 1884 of file fwd_bem_model.cpp.

◆ fwd_bem_one_lin_field_coeff_uran()

void FwdBemModel::fwd_bem_one_lin_field_coeff_uran ( const Eigen::Vector3f & dest,
const Eigen::Vector3f & dir,
MNELIB::MNETriangle & tri,
Eigen::Vector3d & res )
static

Compute linear field coefficients using the Urankar method.

Parameters
[in]destField point.
[in]dirField direction of interest (unit vector).
[in]triDestination triangle.
[out]resOutput coefficients for the three triangle vertices.

Definition at line 1856 of file fwd_bem_model.cpp.

◆ fwd_bem_pot_calc()

void FwdBemModel::fwd_bem_pot_calc ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet * els,
int all_surfs,
Eigen::Ref< Eigen::VectorXf > pot )

Compute BEM potentials at electrodes using constant collocation.

Parameters
[in]rdDipole position.
[in]QDipole orientation.
[in]elsElectrode set.
[in]all_surfsIf non-zero, compute on all surfaces.
[out]potOutput potentials (one value per electrode).

Definition at line 1420 of file fwd_bem_model.cpp.

◆ fwd_bem_pot_els()

int FwdBemModel::fwd_bem_pot_els ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & els,
Eigen::Ref< Eigen::VectorXf > pot,
void * client )
static

Callback: compute BEM potentials at electrodes for a dipole.

Matches the fwdFieldFunc signature for use in forward computation threads.

Parameters
[in]rdDipole position (3-element array).
[in]QDipole orientation (3-element array).
[in]elsElectrode descriptors.
[out]potOutput potentials.
[in]clientOpaque pointer to the FwdBemModel instance.
Returns
OK on success, FAIL on error.

Definition at line 1463 of file fwd_bem_model.cpp.

◆ fwd_bem_pot_grad_calc()

void FwdBemModel::fwd_bem_pot_grad_calc ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet * els,
int all_surfs,
Eigen::Ref< Eigen::VectorXf > xgrad,
Eigen::Ref< Eigen::VectorXf > ygrad,
Eigen::Ref< Eigen::VectorXf > zgrad )

Compute the gradient of BEM potentials with respect to dipole position (constant collocation).

Parameters
[in]rdDipole position.
[in]QDipole orientation.
[in]elsElectrode set.
[in]all_surfsIf non-zero, compute on all surfaces.
[out]xgradGradient with respect to x (one value per electrode).
[out]ygradGradient with respect to y.
[out]zgradGradient with respect to z.

Definition at line 1270 of file fwd_bem_model.cpp.

◆ fwd_bem_pot_grad_els()

int FwdBemModel::fwd_bem_pot_grad_els ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & els,
Eigen::Ref< Eigen::VectorXf > pot,
Eigen::Ref< Eigen::VectorXf > xgrad,
Eigen::Ref< Eigen::VectorXf > ygrad,
Eigen::Ref< Eigen::VectorXf > zgrad,
void * client )
static

Callback: compute BEM potentials and position gradients at electrodes.

Matches the fwdFieldGradFunc signature for use in forward computation threads.

Parameters
[in]rdDipole position (3-element array).
[in]QDipole orientation (3-element array).
[in]elsElectrode descriptors.
[out]potOutput potentials.
[out]xgradGradient with respect to x.
[out]ygradGradient with respect to y.
[out]zgradGradient with respect to z.
[in]clientOpaque pointer to the FwdBemModel instance.
Returns
OK on success, FAIL on error.

Definition at line 1498 of file fwd_bem_model.cpp.

◆ fwd_bem_set_head_mri_t()

int FwdBemModel::fwd_bem_set_head_mri_t ( const FIFFLIB::FiffCoordTrans & t)

Set the Head-to-MRI coordinate transform for this BEM model.

Parameters
[in]tThe head-to-MRI coordinate transformation.
Returns
OK on success, FAIL on error.

Definition at line 467 of file fwd_bem_model.cpp.

◆ fwd_bem_solid_angles()

Eigen::MatrixXf FwdBemModel::fwd_bem_solid_angles ( const std::vector< MNELIB::MNESurface * > & surfs)
static

Compute the solid-angle matrix for all BEM surfaces.

Parameters
[in]surfsVector of BEM surfaces.
Returns
Solid-angle matrix, or empty matrix on error.

Definition at line 993 of file fwd_bem_model.cpp.

◆ fwd_bem_specify_coils()

int FwdBemModel::fwd_bem_specify_coils ( FwdCoilSet * coils)

Precompute the coil-specific BEM solution for MEG.

Builds the coil-specific solution matrix by multiplying the BEM solution with the field coefficients.

Parameters
[in]coilsMEG coil set to prepare.
Returns
OK on success, FAIL on error.

Definition at line 1990 of file fwd_bem_model.cpp.

◆ fwd_bem_specify_els()

int FwdBemModel::fwd_bem_specify_els ( FwdCoilSet * els)

Precompute the electrode-specific BEM solution.

Builds the coil-specific solution matrix for EEG electrodes by multiplying the BEM solution with infinite-medium potentials.

Parameters
[in]elsElectrode (coil) set to prepare.
Returns
OK on success, FAIL on error.

Definition at line 1187 of file fwd_bem_model.cpp.

◆ fwd_mag_dipole_field()

int FwdBemModel::fwd_mag_dipole_field ( const Eigen::Vector3f & rm,
const Eigen::Vector3f & M,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > Bval,
void * client )
static

Callback: compute the magnetic field of a magnetic dipole at coils.

Parameters
[in]rmDipole position (in the same coordinate system as the coils).
[in]MDipole moment components (xyz).
[in]coilsMEG coil definitions.
[out]BvalOutput magnetic fields.
[in]clientOpaque pointer to client data (unused, may be nullptr).
Returns
OK on success, FAIL on error.

Definition at line 3338 of file fwd_bem_model.cpp.

◆ fwd_mag_dipole_field_vec()

int FwdBemModel::fwd_mag_dipole_field_vec ( const Eigen::Vector3f & rm,
FwdCoilSet & coils,
Eigen::Ref< Eigen::MatrixXf > Bval,
void * client )
static

Callback: compute the vector magnetic field of a magnetic dipole at coils.

Returns one row per cardinal dipole direction (x, y, z).

Parameters
[in]rmDipole position (3-element array).
[in]coilsMEG coil definitions.
[out]BvalOutput fields (3 x ncoil matrix, row-major).
[in]clientOpaque pointer to client data (unused, may be nullptr).
Returns
OK on success, FAIL on error.

Definition at line 3375 of file fwd_bem_model.cpp.

◆ fwd_sphere_field()

int FwdBemModel::fwd_sphere_field ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > Bval,
void * client )
static

Callback: compute the spherical-model magnetic field at coils.

Matches the fwdFieldFunc signature.

Parameters
[in]rdDipole position (3-element array).
[in]QDipole components (xyz).
[in]coilsMEG coil definitions.
[out]BvalOutput magnetic fields.
[in]clientOpaque pointer to client data (sphere model origin).
Returns
OK on success, FAIL on error.

Definition at line 3006 of file fwd_bem_model.cpp.

◆ fwd_sphere_field_grad()

int FwdBemModel::fwd_sphere_field_grad ( const Eigen::Vector3f & rd,
const Eigen::Vector3f & Q,
FwdCoilSet & coils,
Eigen::Ref< Eigen::VectorXf > Bval,
Eigen::Ref< Eigen::VectorXf > xgrad,
Eigen::Ref< Eigen::VectorXf > ygrad,
Eigen::Ref< Eigen::VectorXf > zgrad,
void * client )
static

Callback: compute the spherical-model magnetic field and its position gradient at coils.

Matches the fwdFieldGradFunc signature.

Parameters
[in]rdDipole position (3-element array).
[in]QDipole components (xyz).
[in]coilsMEG coil definitions.
[out]BvalOutput magnetic fields.
[out]xgradGradient with respect to x.
[out]ygradGradient with respect to y.
[out]zgradGradient with respect to z.
[in]clientOpaque pointer to client data.
Returns
OK on success, FAIL on error.

Definition at line 3206 of file fwd_bem_model.cpp.

◆ fwd_sphere_field_vec()

int FwdBemModel::fwd_sphere_field_vec ( const Eigen::Vector3f & rd,
FwdCoilSet & coils,
Eigen::Ref< Eigen::MatrixXf > Bval,
void * client )
static

Callback: compute the spherical-model vector magnetic field at coils.

Returns one row per cardinal dipole direction (x, y, z). Matches the fwdVecFieldFunc signature.

Parameters
[in]rdDipole position (3-element array).
[in]coilsMEG coil definitions.
[out]BvalOutput fields (3 x ncoil matrix, row-major).
[in]clientOpaque pointer to client data.
Returns
OK on success, FAIL on error.

Definition at line 3102 of file fwd_bem_model.cpp.

◆ get_int()

int FwdBemModel::get_int ( FIFFLIB::FiffStream::SPtr & stream,
const FIFFLIB::FiffDirNode::SPtr & node,
int what,
int * res )
static

Read an integer tag from a FIFF node.

Definition at line 258 of file fwd_bem_model.cpp.

◆ lin_pot_coeff()

void FwdBemModel::lin_pot_coeff ( const Eigen::Vector3f & from,
MNELIB::MNETriangle & to,
Eigen::Vector3d & omega )
static

Compute the linear potential coefficients for one source-destination pair.

Parameters
[in]fromSource point.
[in]toDestination triangle.
[out]omegaOutput coefficients for the three triangle vertices.

Definition at line 550 of file fwd_bem_model.cpp.

◆ make_guesses()

MNESurface::UPtr FwdBemModel::make_guesses ( MNELIB::MNESurface * guess_surf,
float guessrad,
const Eigen::Vector3f & guess_r0,
float grid,
float exclude,
float mindist )
static

Generate a set of dipole guess locations inside a boundary surface.

Creates an evenly-spaced grid of candidate source locations, optionally excluding points too close to the center of mass or outside the boundary.

Parameters
[in]guess_surfPredefined boundary surface for the guesses (may be nullptr).
[in]guessradRadius for a spherical boundary if guess_surf is nullptr.
[in]guess_r0Origin for the spherical boundary.
[in]gridSpacing between guess points (meters).
[in]excludeExclude points closer than this to the CM of the boundary.
[in]mindistMinimum distance from the boundary surface.
Returns
FsSurface containing the guess locations, or nullptr on failure.

Definition at line 488 of file fwd_bem_model.cpp.

◆ meg_eeg_fwd_one_source_space()

void FwdBemModel::meg_eeg_fwd_one_source_space ( FwdThreadArg * arg)
static

Thread worker: compute the forward solution for one source space.

Used as a thread entry point; the argument is cast to the appropriate worker struct internally.

Parameters
[in]argPer-thread work descriptor.

Definition at line 2419 of file fwd_bem_model.cpp.

◆ one_field_coeff()

double FwdBemModel::one_field_coeff ( const Eigen::Vector3f & dest,
const Eigen::Vector3f & normal,
MNELIB::MNETriangle & tri )
static

Compute the constant-collocation magnetic field coefficient for one triangle.

Parameters
[in]destDestination field point.
[in]normalField direction of interest (unit vector).
[in]triSource triangle.
Returns
The field coefficient.

Definition at line 1691 of file fwd_bem_model.cpp.

Member Data Documentation

◆ bem_method

int FWDLIB::FwdBemModel::bem_method

Approximation method (FWD_BEM_CONSTANT_COLL or FWD_BEM_LINEAR_COLL).

Definition at line 1037 of file fwd_bem_model.h.

◆ field_mult

Eigen::VectorXf FWDLIB::FwdBemModel::field_mult

Magnetic-field multipliers (length nsurf).

Definition at line 1035 of file fwd_bem_model.h.

◆ gamma

Eigen::MatrixXf FWDLIB::FwdBemModel::gamma

Conductivity-ratio coupling matrix (nsurf x nsurf).

Definition at line 1033 of file fwd_bem_model.h.

◆ head_mri_t

FIFFLIB::FiffCoordTrans FWDLIB::FwdBemModel::head_mri_t

Head-to-MRI coordinate transform.

Definition at line 1044 of file fwd_bem_model.h.

◆ ip_approach_limit

float FWDLIB::FwdBemModel::ip_approach_limit

Threshold for isolated-problem approach.

Definition at line 1046 of file fwd_bem_model.h.

◆ MAG_FACTOR

double FWDLIB::FwdBemModel::MAG_FACTOR = 1e-7
staticconstexpr

Magnetic constant mu_0 / (4 * pi).

Definition at line 746 of file fwd_bem_model.h.

◆ np

Eigen::VectorXi FWDLIB::FwdBemModel::np

Vertex count per surface (length nsurf).

Definition at line 1029 of file fwd_bem_model.h.

◆ nsol

int FWDLIB::FwdBemModel::nsol

Dimension of the solution matrix.

Definition at line 1042 of file fwd_bem_model.h.

◆ nsurf

int FWDLIB::FwdBemModel::nsurf

Number of interface surfaces.

Definition at line 1030 of file fwd_bem_model.h.

◆ ntri

Eigen::VectorXi FWDLIB::FwdBemModel::ntri

Triangle count per surface (length nsurf).

Definition at line 1028 of file fwd_bem_model.h.

◆ sigma

Eigen::VectorXf FWDLIB::FwdBemModel::sigma

Conductivity of each layer (length nsurf).

Definition at line 1032 of file fwd_bem_model.h.

◆ sol_name

QString FWDLIB::FwdBemModel::sol_name

File from which the solution was loaded.

Definition at line 1038 of file fwd_bem_model.h.

◆ solution

Eigen::MatrixXf FWDLIB::FwdBemModel::solution

Potential solution matrix (nsol x nsol).

Definition at line 1040 of file fwd_bem_model.h.

◆ source_mult

Eigen::VectorXf FWDLIB::FwdBemModel::source_mult

Infinite-medium potential multipliers (length nsurf).

Definition at line 1034 of file fwd_bem_model.h.

◆ surf_name

QString FWDLIB::FwdBemModel::surf_name

File from which surfaces were loaded.

Definition at line 1024 of file fwd_bem_model.h.

◆ surfs

std::vector<std::shared_ptr<MNELIB::MNESurface> > FWDLIB::FwdBemModel::surfs

Interface surfaces, outermost first.

Definition at line 1026 of file fwd_bem_model.h.

◆ use_ip_approach

bool FWDLIB::FwdBemModel::use_ip_approach

Whether the isolated-problem approach is active.

Definition at line 1047 of file fwd_bem_model.h.

◆ v0

Eigen::VectorXf FWDLIB::FwdBemModel::v0

Workspace for infinite-medium potentials (length nsol).

Definition at line 1041 of file fwd_bem_model.h.


The documentation for this class was generated from the following files: