v2.0.0
Loading...
Searching...
No Matches
mne_named_vector.cpp
Go to the documentation of this file.
1//=============================================================================================================
34
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
39#include "mne_named_vector.h"
40
41//=============================================================================================================
42// USED NAMESPACES
43//=============================================================================================================
44
45using namespace Eigen;
46using namespace MNELIB;
47
48constexpr int FAIL = -1;
49constexpr int OK = 0;
50
51//=============================================================================================================
52// DEFINE MEMBER METHODS
53//=============================================================================================================
54
55int MNENamedVector::pick(const QStringList& pick_names, int nnames, bool require_all, Eigen::Ref<Eigen::VectorXf> res) const
56{
57 int found;
58 int k,p;
59
60 if (names.size() == 0) {
61 qCritical("No names present in vector. Cannot pick.");
62 return FAIL;
63 }
64
65 for (k = 0; k < nnames; k++)
66 res[k] = 0.0;
67
68 for (k = 0; k < nnames; k++) {
69 found = 0;
70 for (p = 0; p < nvec; p++) {
71 if (QString::compare(names[p],pick_names[k]) == 0) {
72 res[k] = data[p];
73 found = true;
74 break;
75 }
76 }
77 if (!found && require_all) {
78 qCritical("All required elements not found in named vector.");
79 return FAIL;
80 }
81 }
82 return OK;
83}
constexpr int FAIL
constexpr int OK
MNENamedVector class declaration.
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