90 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
91 qWarning() <<
"[InvSourceEstimateIO::readCsv] Cannot open:" << sPath;
95 QTextStream in(&file);
96 const QString delim(QChar::fromLatin1(cDelim));
99 QString header = in.readLine();
100 QStringList headerParts = header.split(delim, Qt::SkipEmptyParts);
101 if (headerParts.size() < 2) {
102 qWarning() <<
"[InvSourceEstimateIO::readCsv] Invalid header.";
107 int nVertices = headerParts.size() - 1;
108 VectorXi vertices(nVertices);
109 for (
int v = 0; v < nVertices; ++v) {
110 vertices(v) = headerParts[v + 1].toInt();
114 QList<VectorXd> timePoints;
117 while (!in.atEnd()) {
118 QString line = in.readLine().trimmed();
119 if (line.isEmpty())
continue;
121 QStringList parts = line.split(delim, Qt::SkipEmptyParts);
122 if (parts.size() < nVertices + 1)
continue;
124 times.append(parts[0].toDouble());
125 VectorXd row(nVertices);
126 for (
int v = 0; v < nVertices; ++v) {
127 row(v) = parts[v + 1].toDouble();
129 timePoints.append(row);
134 if (timePoints.isEmpty()) {
139 MatrixXd data(nVertices, timePoints.size());
140 for (
int t = 0; t < timePoints.size(); ++t) {
141 data.col(t) = timePoints[t];
144 float tmin =
static_cast<float>(times[0]);
145 float tstep = (times.size() > 1)
146 ?
static_cast<float>(times[1] - times[0])