54static const QString NA = QStringLiteral(
"n/a");
56QString naToEmpty(
const QString& s)
58 return (s == NA) ? QString() : s;
71 QList<BidsChannel> channels;
72 channels.reserve(rawRows.size());
74 for(
const auto& row : rawRows) {
76 ch.
name = row.value(QStringLiteral(
"name"));
77 ch.
type = row.value(QStringLiteral(
"type"));
78 ch.
units = row.value(QStringLiteral(
"units"));
79 ch.
samplingFreq = naToEmpty(row.value(QStringLiteral(
"sampling_frequency")));
80 ch.
lowCutoff = naToEmpty(row.value(QStringLiteral(
"low_cutoff")));
81 ch.
highCutoff = naToEmpty(row.value(QStringLiteral(
"high_cutoff")));
82 ch.
notch = naToEmpty(row.value(QStringLiteral(
"notch")));
83 ch.
status = naToEmpty(row.value(QStringLiteral(
"status")));
84 ch.
description = naToEmpty(row.value(QStringLiteral(
"description")));
94 const QList<BidsChannel>& channels)
96 QStringList headers = {
97 QStringLiteral(
"name"),
98 QStringLiteral(
"type"),
99 QStringLiteral(
"units"),
100 QStringLiteral(
"sampling_frequency"),
101 QStringLiteral(
"low_cutoff"),
102 QStringLiteral(
"high_cutoff"),
103 QStringLiteral(
"notch"),
104 QStringLiteral(
"status"),
105 QStringLiteral(
"description"),
108 QList<BidsTsvRow> rows;
109 rows.reserve(channels.size());
111 for(
const auto& ch : channels) {
113 row[QStringLiteral(
"name")] = ch.name;
114 row[QStringLiteral(
"type")] = ch.type;
115 row[QStringLiteral(
"units")] = ch.units;
116 row[QStringLiteral(
"sampling_frequency")] = ch.samplingFreq;
117 row[QStringLiteral(
"low_cutoff")] = ch.lowCutoff;
118 row[QStringLiteral(
"high_cutoff")] = ch.highCutoff;
119 row[QStringLiteral(
"notch")] = ch.notch;
120 row[QStringLiteral(
"status")] = ch.status;
121 row[QStringLiteral(
"description")] = ch.description;
BidsTsv class declaration — generic BIDS TSV file reading and writing.
BidsChannel struct — channel metadata from *_channels.tsv.
BIDS dataset reading, writing, path construction, and sidecar metadata handling for iEEG/EEG/MEG.
QMap< QString, QString > BidsTsvRow
Channel metadata record corresponding to one row in *_channels.tsv.
static QList< BidsChannel > readTsv(const QString &sFilePath)
Read a BIDS *_channels.tsv file.
static bool writeTsv(const QString &sFilePath, const QList< BidsChannel > &channels)
Write a BIDS *_channels.tsv file.
static QList< BidsTsvRow > readTsv(const QString &sFilePath, QStringList &headers)
static bool writeTsv(const QString &sFilePath, const QStringList &headers, const QList< BidsTsvRow > &rows)