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
48#ifndef FAIL
49#define FAIL -1
50#endif
51
52#ifndef OK
53#define OK 0
54#endif
55
56//=============================================================================================================
57// DEFINE MEMBER METHODS
58//=============================================================================================================
59
60int MNENamedVector::pick(const QStringList& pick_names, int nnames, bool require_all, Eigen::Ref<Eigen::VectorXf> res) const
61{
62 int found;
63 int k,p;
64
65 if (names.size() == 0) {
66 qCritical("No names present in vector. Cannot pick.");
67 return FAIL;
68 }
69
70 for (k = 0; k < nnames; k++)
71 res[k] = 0.0;
72
73 for (k = 0; k < nnames; k++) {
74 found = 0;
75 for (p = 0; p < nvec; p++) {
76 if (QString::compare(names[p],pick_names[k]) == 0) {
77 res[k] = data[p];
78 found = true;
79 break;
80 }
81 }
82 if (!found && require_all) {
83 qCritical("All required elements not found in named vector.");
84 return FAIL;
85 }
86 }
87 return OK;
88}
#define OK
#define FAIL
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