52 QStringList& channelNames,
53 QList<QVector<float>>& location3D,
54 QList<QVector<float>>& location2D,
58 if (!path.contains(
".elc"))
62 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
63 qDebug() <<
"Error opening elc file";
68 double numberElectrodes;
69 QTextStream in(&file);
73 QString line = in.readLine();
75 QStringList fields = line.split(QRegularExpression(
"\\s+"));
78 if (fields.at(fields.size() - 1) ==
"")
81 if (!line.contains(
"#"))
84 if (line.contains(
"NumberPositions"))
85 numberElectrodes = fields.at(1).toDouble();
88 if (line.contains(
"UnitPosition"))
92 if (line.contains(
"Positions2D"))
95 if (line.contains(
":") && !read2D)
97 channelNames.push_back(fields.at(0));
98 QVector<float> posTemp;
100 posTemp.push_back(fields.at(fields.size() - 3).toDouble());
101 posTemp.push_back(fields.at(fields.size() - 2).toDouble());
102 posTemp.push_back(fields.at(fields.size() - 1).toDouble());
104 location3D.append(posTemp);
107 if (line.contains(
":") && read2D)
109 QVector<float> posTemp;
110 posTemp.push_back(fields.at(fields.size() - 2).toDouble());
111 posTemp.push_back(fields.at(fields.size() - 1).toDouble());
112 location2D.append(posTemp);
116 if (line.contains(
"Labels")) {
117 line = in.readLine();
118 fields = line.split(QRegularExpression(
"\\s+"));
121 if (fields.at(fields.size() - 1) ==
"")
124 channelNames = fields;
129 Q_UNUSED(numberElectrodes);
139 std::vector<std::string>& channelNames,
140 std::vector<std::vector<float>>& location3D,
141 std::vector<std::vector<float>>& location2D,
144 if (path.find(
".elc") == std::string::npos) {
148 std::ifstream inFile(path);
150 if (!inFile.is_open()) {
151 qDebug() <<
"Error opening elc file";
156 double numberElectrodes;
161 while (std::getline(inFile, line)) {
162 if (line.find(
'#') == std::string::npos) {
163 std::vector<std::string> elements;
164 std::stringstream stream{line};
168 while (stream >> element) {
169 elements.push_back(std::move(element));
174 if (line.find(
"NumberPositions") != std::string::npos)
175 numberElectrodes = std::stod(elements.at(1));
178 if (line.find(
"UnitPosition") != std::string::npos)
179 unit = elements.at(1);
182 if (line.find(
"Positions2D") != std::string::npos)
185 if (line.find(
':') != std::string::npos && !read2D)
187 channelNames.push_back(elements.at(0));
188 std::vector<float> posTemp;
190 posTemp.push_back(std::stod(elements.at(elements.size() - 3)));
191 posTemp.push_back(std::stod(elements.at(elements.size() - 2)));
192 posTemp.push_back(std::stod(elements.at(elements.size() - 1)));
194 location3D.push_back(std::move(posTemp));
197 if (line.find(
":") != std::string::npos && read2D)
199 std::vector<float> posTemp;
200 posTemp.push_back(std::stod(elements.at(elements.size() - 2)));
201 posTemp.push_back(std::stod(elements.at(elements.size() - 1)));
202 location2D.push_back(std::move(posTemp));
206 if (line.find(
"Labels") != std::string::npos) {
207 std::getline(inFile, line);
208 std::stringstream channels{line};
209 std::vector<std::string> listOfNames;
211 std::string channelName;
214 while (channels >> channelName) {
215 listOfNames.push_back(std::move(channelName));
219 channelNames = std::move(listOfNames);
224 Q_UNUSED(numberElectrodes);