Skip to main content

FwdThreadArg

Namespace: FWDLIB  ·  Library: Forward Library

#include <fwd/fwd_thread_arg.h>

class FWDLIB::FwdThreadArg

Implements a Forward Thread Argument (replaces fwdThreadArg / fwdThreadArgRec from MNE-C compute_forward.c).

Per-thread work packet carrying the dipole-index range, coil set, field/grad callback and write-back view into the shared lead-field matrix — unit of work for the parallel source-space dipole loop.


Public Methods​

FwdThreadArg()​

Constructs the Forward Thread Argument.


~FwdThreadArg()​

Destroys the Forward Thread Argument.


Static Methods​

create_eeg_multi_thread_duplicate(one, bem_model)​

Create a thread-safe duplicate for EEG parallel forward computation.

Parameters:

  • one : FwdThreadArg & Template thread argument to duplicate.

  • bem_model : bool Whether to duplicate the BEM model sub-object.

Returns:

  • FwdThreadArg::UPtr — Thread-safe duplicate.

create_meg_multi_thread_duplicate(one, bem_model)​

Create a thread-safe duplicate for MEG parallel forward computation.

Parameters:

  • one : FwdThreadArg & Template thread argument to duplicate.

  • bem_model : bool Whether to duplicate the BEM model sub-object.

Returns:

  • FwdThreadArg::UPtr — Thread-safe duplicate.

Example​

No example of its own: Per-thread work item of the parallel dipole loop inside ComputeFwd; built and consumed only by FwdBemModel, never by callers.

It is exercised by:

src/examples/ex_fwd_api/main.cpp
// mne_forward_solution --meg --eeg --accurate --label V1-lh.label with sphere models instead of a BEM
const QString label = tmp.filePath("V1-lh.label"); // the hemisphere is taken from the "-lh.label" suffix
QFile::copy(data + "/subjects/sample/label/lh.V1.label", label);
auto settings = std::make_shared<ComputeFwdSettings>();
settings->include_meg = true;
settings->include_eeg = true;
settings->accurate = true;
settings->srcname = data + "/subjects/sample/bem/sample-oct-6-src.fif";
settings->measname = rawFile.fileName();
settings->mriname = data + "/MEG/sample/all-trans.fif";
settings->r0 = origin;
settings->eeg_sphere_rad = 0.09f;
settings->mindist = 0.0f;
settings->filter_spaces = false;
settings->labels = {label};
settings->nlabel = 1;
settings->solname = tmp.filePath("V1-fwd.fif");
settings->pFiffInfo = QSharedPointer<FiffInfo>::create(raw.info);
settings->checkIntegrity();
auto fwd = std::make_shared<ComputeFwd>(settings)->calculateFwd();
QFile solFile(settings->solname);
fwd->write(solFile);

From ex_fwd_api.

Authors of this file​