v2.0.0
Loading...
Searching...
No Matches
mne_named_vector.cpp
Go to the documentation of this file.
1//=============================================================================================================
16
17//=============================================================================================================
18// INCLUDES
19//=============================================================================================================
20
21#include "mne_named_vector.h"
22
23//=============================================================================================================
24// USED NAMESPACES
25//=============================================================================================================
26
27using namespace Eigen;
28using namespace MNELIB;
29
30constexpr int FAIL = -1;
31constexpr int OK = 0;
32
33//=============================================================================================================
34// DEFINE MEMBER METHODS
35//=============================================================================================================
36
37int MNENamedVector::pick(const QStringList& pick_names, int nnames, bool require_all, Eigen::Ref<Eigen::VectorXf> res) const
38{
39 int found;
40 int k,p;
41
42 if (names.size() == 0) {
43 qCritical("No names present in vector. Cannot pick.");
44 return FAIL;
45 }
46
47 for (k = 0; k < nnames; k++)
48 res[k] = 0.0;
49
50 for (k = 0; k < nnames; k++) {
51 found = 0;
52 for (p = 0; p < nvec; p++) {
53 if (QString::compare(names[p],pick_names[k]) == 0) {
54 res[k] = data[p];
55 found = true;
56 break;
57 }
58 }
59 if (!found && require_all) {
60 qCritical("All required elements not found in named vector.");
61 return FAIL;
62 }
63 }
64 return OK;
65}
constexpr int FAIL
constexpr int OK
Named one-dimensional counterpart of MNELIB::MNENamedMatrix.
Core MNE data structures (source spaces, source estimates, hemispheres).
int pick(const QStringList &names, int nnames, bool require_all, Eigen::Ref< Eigen::VectorXf > res) const