v2.0.0
Loading...
Searching...
No Matches
fwd_thread_arg.cpp
Go to the documentation of this file.
1//=============================================================================================================
14
15//=============================================================================================================
16// INCLUDES
17//=============================================================================================================
18
19#include "fwd_thread_arg.h"
21#include "fwd_coil_set.h"
22#include "fwd_bem_model.h"
23#include "fwd_comp_data.h"
24
25//=============================================================================================================
26// USED NAMESPACES
27//=============================================================================================================
28
29using namespace Eigen;
30using namespace FWDLIB;
31using namespace MNELIB;
32
33//=============================================================================================================
34// DEFINE MEMBER METHODS
35//=============================================================================================================
36
38: res(nullptr)
39, res_grad(nullptr)
40, off(0)
41, field_pot(nullptr)
42, vec_field_pot(nullptr)
43, field_pot_grad(nullptr)
44, coils_els(nullptr)
45, client(nullptr)
46, s(nullptr)
47, fixed_ori(false)
48, comp(-1)
49, stat(-1)
50{
51}
52
53//=============================================================================================================
54
60
61//=============================================================================================================
62
64{
65 auto res = std::make_unique<FwdThreadArg>();
66
67 *res = one;
68 res->client_free = nullptr; /* Don't copy the source's deleter */
69 if (bem_model) {
70 auto bem = std::make_shared<FwdBemModel>();
71 *bem = *static_cast<FwdBemModel*>(res->client);
72 bem->v0.resize(0);
73 res->client = bem.get();
74 res->client_free = [bem]() {
75 }; /* shared_ptr releases FwdBemModel on destruction */
76 }
77 return res;
78}
79
80//=============================================================================================================
81
83{
84 auto res = std::make_unique<FwdThreadArg>();
85 FwdCompData* orig = static_cast<FwdCompData*>(one.client);
86
87 *res = one;
88 res->client_free = nullptr; /* Don't copy the source's deleter */
89
90 // Each thread gets its own compensation set (it is mutated while applying)
91 // and work buffers; the compensation coils are read-only and shared.
92 auto comp = std::make_shared<FwdCompData>(*orig);
93 comp->set = orig->set ? std::make_shared<MNECTFCompDataSet>(*orig->set) : nullptr;
94 comp->work.resize(0);
95 comp->vec_work.resize(0, 0);
96
97 res->client = comp.get();
98
99 if (bem_model) {
100 auto bem = std::make_shared<FwdBemModel>();
101 *bem = *static_cast<FwdBemModel*>(comp->client);
102 bem->v0.resize(0);
103 comp->client = bem.get();
104 /* shared_ptrs release their objects when client_free is destroyed */
105 res->client_free = [comp, bem]() {
106 };
107 } else {
108 res->client_free = [comp]() {
109 };
110 }
111 return res;
112}
Per-thread work packet (dipole range, coil set, output column) consumed by the parallel forward-solut...
Software-gradiometer compensation wrapper that subtracts the reference-channel contribution from the ...
Container of FwdCoil instances representing either a sensor-type template database or a concrete per-...
Boundary Element Method (BEM) volume-conductor model — layered triangulated surfaces,...
Single-hemisphere source space (cortical surface or volume grid) loaded from FIFF.
Core MNE data structures (source spaces, source estimates, hemispheres).
Forward modelling — BEM solver, spherical models, sensor/coil definitions and the lead-field assembly...
Definition compute_fwd.h:85
Layered triangulated volume-conductor model (scalp/skull/inner-skull surfaces, per-compartment conduc...
Eigen::VectorXf v0
CTF / 4D software-gradiometer wrapper that re-evaluates the primary field callback on a separate refe...
std::shared_ptr< MNELIB::MNECTFCompDataSet > set
fwdFieldGradFunc field_pot_grad
std::unique_ptr< FwdThreadArg > UPtr
static FwdThreadArg::UPtr create_eeg_multi_thread_duplicate(FwdThreadArg &one, bool bem_model)
std::function< void()> client_free
Eigen::MatrixXf * res_grad
Eigen::MatrixXf * res
fwdVecFieldFunc vec_field_pot
static FwdThreadArg::UPtr create_meg_multi_thread_duplicate(FwdThreadArg &one, bool bem_model)
MNELIB::MNESourceSpace * s