32static const QString NA = QStringLiteral(
"n/a");
34QString naToEmpty(
const QString& s)
36 return (s == NA) ? QString() : s;
49 QList<BidsChannel> channels;
50 channels.reserve(rawRows.size());
52 for(
const auto& row : rawRows) {
54 ch.
name = row.value(QStringLiteral(
"name"));
55 ch.
type = row.value(QStringLiteral(
"type"));
56 ch.
units = row.value(QStringLiteral(
"units"));
57 ch.
samplingFreq = naToEmpty(row.value(QStringLiteral(
"sampling_frequency")));
58 ch.
lowCutoff = naToEmpty(row.value(QStringLiteral(
"low_cutoff")));
59 ch.
highCutoff = naToEmpty(row.value(QStringLiteral(
"high_cutoff")));
60 ch.
notch = naToEmpty(row.value(QStringLiteral(
"notch")));
61 ch.
status = naToEmpty(row.value(QStringLiteral(
"status")));
62 ch.
description = naToEmpty(row.value(QStringLiteral(
"description")));
72 const QList<BidsChannel>& channels)
74 QStringList headers = {
75 QStringLiteral(
"name"),
76 QStringLiteral(
"type"),
77 QStringLiteral(
"units"),
78 QStringLiteral(
"sampling_frequency"),
79 QStringLiteral(
"low_cutoff"),
80 QStringLiteral(
"high_cutoff"),
81 QStringLiteral(
"notch"),
82 QStringLiteral(
"status"),
83 QStringLiteral(
"description"),
86 QList<BidsTsvRow> rows;
87 rows.reserve(channels.size());
89 for(
const auto& ch : channels) {
91 row[QStringLiteral(
"name")] = ch.name;
92 row[QStringLiteral(
"type")] = ch.type;
93 row[QStringLiteral(
"units")] = ch.units;
94 row[QStringLiteral(
"sampling_frequency")] = ch.samplingFreq;
95 row[QStringLiteral(
"low_cutoff")] = ch.lowCutoff;
96 row[QStringLiteral(
"high_cutoff")] = ch.highCutoff;
97 row[QStringLiteral(
"notch")] = ch.notch;
98 row[QStringLiteral(
"status")] = ch.status;
99 row[QStringLiteral(
"description")] = ch.description;
Generic tab-separated-value reader/writer for BIDS sidecars (UTF-8, LF, n/a for missing values,...
Reader/writer for the BIDS _channels.tsv sidecar — one record per recorded channel.
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)