Skip to main content

BidsTsv

Namespace: BIDSLIB  ·  Library: BIDS Library

#include <bids/bids_tsv.h>

class BIDSLIB::BidsTsv

Generic BIDS TSV file reader/writer.

BIDS TSV files are tab-separated value files with:

  • A mandatory header row defining column names.
  • "n/a" for missing values.
  • UTF-8 encoding, LF line endings.

Domain-specific TSV I/O (channels, electrodes, events) is handled by BidsChannel, BidsElectrode, and BidsEvent respectively.

Generic BIDS TSV file I/O.

src/examples/ex_bids/main.cpp
QStringList headers;
const QList<BidsTsvRow> rows = BidsTsv::readTsv(ieeg.eventsTsvPath().filePath(), headers);
// each row maps column name -> cell text, e.g. rows[1]["trial_type"] == "response"

Public Methods​

BidsTsv()​


~BidsTsv()​


Static Methods​

readTsv(sFilePath, headers)​

Reads a TSV file into an ordered list of row maps.

Parameters:

  • sFilePath : const QString & Path to the TSV file.

  • headers : QStringList & Column names from the header row.

Returns:

  • QList< BidsTsvRow > — List of rows, each row a map of column-name → value.

writeTsv(sFilePath, headers, rows)​

Writes rows to a TSV file.

Parameters:

  • sFilePath : const QString & Output file path.

  • headers : const QStringList & Column names (determines column order).

  • rows : const QList< BidsTsvRow > & Data rows.

Returns:

  • bool — true on success, false on I/O error.

Example​

Used in examples​

ex_bids​

BIDS library: paths, sidecar TSVs, BrainVision/EDF readers and a raw-data round trip.

src/examples/ex_bids/main.cpp, line 101
QStringList headers;
const QList<BidsTsvRow> rows = BidsTsv::readTsv(ieeg.eventsTsvPath().filePath(), headers);
// each row maps column name -> cell text, e.g. rows[1]["trial_type"] == "response"
ok &= expect(headers == QStringList({"onset", "duration", "sample", "value", "trial_type"}) && rows.size() == 4 && rows[1]["trial_type"] == "response" && rows[3]["onset"] == "5.250000",
"BidsTsv reads the 5 event columns and 4 rows");

Authors of this file​