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,stat (-1)
49,comp (-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]() {}; /* shared_ptr releases FwdBemModel on destruction */
75 }
76 return res;
77}
78
79//=============================================================================================================
80
82{
83 auto res = std::make_unique<FwdThreadArg>();
84 FwdCompData* orig = static_cast<FwdCompData*>(one.client);
85
86 *res = one;
87 res->client_free = nullptr; /* Don't copy the source's deleter */
88
89 auto comp = std::make_shared<FwdCompData>();
90 *comp = *orig;
91 comp->comp_coils = nullptr; /* Non-owning: shared with original, prevent ~FwdCompData from deleting */
92 comp->set = nullptr; /* Will be replaced below; prevent dtor from deleting orig's copy */
93 comp->work.resize(0);
94 comp->vec_work.resize(0, 0);
95
96 std::shared_ptr<MNECTFCompDataSet> set_guard(
97 orig->set ? new MNECTFCompDataSet(*(orig->set)) : nullptr);
98 comp->set = set_guard.get();
99
100 res->client = comp.get();
101
102 if (bem_model) {
103 auto bem = std::make_shared<FwdBemModel>();
104 *bem = *static_cast<FwdBemModel*>(comp->client);
105 bem->v0.resize(0);
106 comp->client = bem.get();
107 /* shared_ptrs release their objects when client_free is destroyed */
108 res->client_free = [comp, set_guard, bem]() {
109 comp->set = nullptr; /* Prevent ~FwdCompData double-free; set_guard owns it */
110 };
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 ...
Boundary Element Method (BEM) volume-conductor model — layered triangulated surfaces,...
Container of FwdCoil instances representing either a sensor-type template database or a concrete per-...
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:83
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.