56static const QString NA = QStringLiteral(
"n/a");
58QString naToEmpty(
const QString& s)
60 return (s == NA) ? QString() : s;
73 QList<BidsElectrode> electrodes;
74 electrodes.reserve(rawRows.size());
76 for(
const auto& row : rawRows) {
78 elec.
name = row.value(QStringLiteral(
"name"));
79 elec.
x = row.value(QStringLiteral(
"x"), NA);
80 elec.
y = row.value(QStringLiteral(
"y"), NA);
81 elec.
z = row.value(QStringLiteral(
"z"), NA);
82 elec.
size = naToEmpty(row.value(QStringLiteral(
"size")));
83 elec.
type = naToEmpty(row.value(QStringLiteral(
"type")));
84 elec.
material = naToEmpty(row.value(QStringLiteral(
"material")));
85 elec.
impedance = naToEmpty(row.value(QStringLiteral(
"impedance")));
86 electrodes.append(elec);
95 const QList<BidsElectrode>& electrodes)
97 QStringList headers = {
98 QStringLiteral(
"name"),
102 QStringLiteral(
"size"),
103 QStringLiteral(
"type"),
104 QStringLiteral(
"material"),
105 QStringLiteral(
"impedance"),
108 QList<BidsTsvRow> rows;
109 rows.reserve(electrodes.size());
111 for(
const auto& elec : electrodes) {
113 row[QStringLiteral(
"name")] = elec.name;
114 row[QStringLiteral(
"x")] = elec.x;
115 row[QStringLiteral(
"y")] = elec.y;
116 row[QStringLiteral(
"z")] = elec.z;
117 row[QStringLiteral(
"size")] = elec.size;
118 row[QStringLiteral(
"type")] = elec.type;
119 row[QStringLiteral(
"material")] = elec.material;
120 row[QStringLiteral(
"impedance")] = elec.impedance;
130 const QList<BidsElectrode>& electrodes,
138 const bool hasTransform = (trans.
from != 0 || trans.
to != 0);
142 bool xOk =
false, yOk =
false, zOk =
false;
143 float xVal = elec.x.toFloat(&xOk);
144 float yVal = elec.y.toFloat(&yOk);
145 float zVal = elec.z.toFloat(&zOk);
147 if (!xOk || !yOk || !zOk) {
153 point.
ident = ident++;
160 Eigen::Vector3f pos(point.
r[0], point.
r[1], point.
r[2]);
161 Eigen::Vector3f transformed = (trans.
trans.block<3,3>(0,0).cast<
float>() * pos
162 + trans.
trans.block<3,1>(0,3).cast<
float>());
163 point.
r[0] = transformed(0);
164 point.
r[1] = transformed(1);
165 point.
r[2] = transformed(2);
BidsElectrode struct — electrode position from *_electrodes.tsv.
BidsTsv class declaration — generic BIDS TSV file reading and writing.
BIDS dataset reading, writing, path construction, and sidecar metadata handling for iEEG/EEG/MEG.
QMap< QString, QString > BidsTsvRow
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
Electrode position record corresponding to one row in *_electrodes.tsv.
static bool writeTsv(const QString &sFilePath, const QList< BidsElectrode > &electrodes)
Write a BIDS *_electrodes.tsv file.
static QList< BidsElectrode > readTsv(const QString &sFilePath)
Read a BIDS *_electrodes.tsv file.
static FIFFLIB::FiffDigPointSet toFiffDigPoints(const QList< BidsElectrode > &electrodes, const FIFFLIB::FiffCoordTrans &trans=FIFFLIB::FiffCoordTrans())
Convert a list of BIDS electrodes to a FIFF digitizer point set.
static QList< BidsTsvRow > readTsv(const QString &sFilePath, QStringList &headers)
static bool writeTsv(const QString &sFilePath, const QStringList &headers, const QList< BidsTsvRow > &rows)
Coordinate transformation description.
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > trans
Digitization point description.
Holds a set of digitizer points.