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 auto comp = std::make_shared<FwdCompData>();
91 *comp = *orig;
92 comp->comp_coils = nullptr; /* Non-owning: shared with original, prevent ~FwdCompData from deleting */
93 comp->set = nullptr; /* Will be replaced below; prevent dtor from deleting orig's copy */
94 comp->work.resize(0);
95 comp->vec_work.resize(0, 0);
96
97 std::shared_ptr<MNECTFCompDataSet> set_guard(
98 orig->set ? new MNECTFCompDataSet(*(orig->set)) : nullptr);
99 comp->set = set_guard.get();
100
101 res->client = comp.get();
102
103 if (bem_model) {
104 auto bem = std::make_shared<FwdBemModel>();
105 *bem = *static_cast<FwdBemModel*>(comp->client);
106 bem->v0.resize(0);
107 comp->client = bem.get();
108 /* shared_ptrs release their objects when client_free is destroyed */
109 res->client_free = [comp, set_guard, bem]() {
110 comp->set = nullptr; /* Prevent ~FwdCompData double-free; set_guard owns it */
111 };
112 } else {
113 res->client_free = [comp, set_guard]() {
114 comp->set = nullptr; /* Prevent ~FwdCompData double-free; set_guard owns it */
115 };
116 }
117 return res;
118}
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...
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
Collection of CTF third-order gradient compensation operators.