v2.0.0
Loading...
Searching...
No Matches
BIDSLIB::BIDSPath Class Reference

BIDS-compliant path and filename construction. More...

#include <bids_path.h>

Public Types

using SPtr = QSharedPointer<BIDSPath>
using ConstSPtr = QSharedPointer<const BIDSPath>

Public Member Functions

 BIDSPath ()
 BIDSPath (const QString &sRoot, const QString &sSubject, const QString &sSession=QString(), const QString &sTask=QString(), const QString &sDatatype=QString(), const QString &sSuffix=QString(), const QString &sExtension=QString())
 BIDSPath (const BIDSPath &other)
 ~BIDSPath ()
void setRoot (const QString &sRoot)
void setSubject (const QString &sSubject)
void setSession (const QString &sSession)
void setTask (const QString &sTask)
void setAcquisition (const QString &sAcquisition)
void setRun (const QString &sRun)
void setProcessing (const QString &sProcessing)
void setSpace (const QString &sSpace)
void setRecording (const QString &sRecording)
void setSplit (const QString &sSplit)
void setDescription (const QString &sDescription)
void setDatatype (const QString &sDatatype)
void setSuffix (const QString &sSuffix)
void setExtension (const QString &sExtension)
QString root () const
QString subject () const
QString session () const
QString task () const
QString acquisition () const
QString run () const
QString processing () const
QString space () const
QString recording () const
QString split () const
QString description () const
QString datatype () const
QString suffix () const
QString extension () const
QString basename () const
QString directory () const
QString filePath () const
BIDSPath withSuffix (const QString &sSuffix, const QString &sExtension) const
BIDSPath channelsTsvPath () const
BIDSPath electrodesTsvPath () const
BIDSPath coordsystemJsonPath () const
BIDSPath eventsTsvPath () const
BIDSPath sidecarJsonPath () const
bool exists () const
bool mkdirs () const
QList< BIDSPath > match () const
BIDSPath & operator= (const BIDSPath &other)

Static Public Member Functions

static bool isValidEntityValue (const QString &sValue)

Friends

bool operator== (const BIDSPath &a, const BIDSPath &b)

Detailed Description

BIDS-compliant path and filename construction.

Manages BIDS-compliant file paths.

A BIDSPath encodes the BIDS entities (subject, session, task, acquisition, run, etc.) together with a datatype, suffix, extension, and root directory to produce fully qualified file paths that conform to the BIDS specification.

Definition at line 73 of file bids_path.h.

Member Typedef Documentation

◆ ConstSPtr

using BIDSLIB::BIDSPath::ConstSPtr = QSharedPointer<const BIDSPath>

Const shared pointer type for BIDSPath.

Definition at line 77 of file bids_path.h.

◆ SPtr

using BIDSLIB::BIDSPath::SPtr = QSharedPointer<BIDSPath>

Shared pointer type for BIDSPath.

Definition at line 76 of file bids_path.h.

Constructor & Destructor Documentation

◆ BIDSPath() [1/3]

BIDSPath::BIDSPath ( )

Constructs an empty BIDSPath.

Definition at line 40 of file bids_path.cpp.

◆ BIDSPath() [2/3]

BIDSPath::BIDSPath ( const QString & sRoot,
const QString & sSubject,
const QString & sSession = QString(),
const QString & sTask = QString(),
const QString & sDatatype = QString(),
const QString & sSuffix = QString(),
const QString & sExtension = QString() )

Constructs a BIDSPath with the most common entities.

Parameters
[in]sRootRoot directory of the BIDS dataset.
[in]sSubjectSubject label (without "sub-" prefix).
[in]sSessionSession label (without "ses-" prefix). Can be empty.
[in]sTaskTask label. Can be empty.
[in]sDatatypeBIDS datatype (e.g. "ieeg", "eeg", "meg", "anat").
[in]sSuffixFilename suffix (e.g. "ieeg", "channels", "electrodes").
[in]sExtensionFile extension including dot (e.g. ".vhdr", ".tsv", ".json").

Definition at line 46 of file bids_path.cpp.

◆ BIDSPath() [3/3]

BIDSPath::BIDSPath ( const BIDSPath & other)

Copy constructor.

Parameters
[in]otherBIDSPath to copy.

Definition at line 65 of file bids_path.cpp.

◆ ~BIDSPath()

BIDSPath::~BIDSPath ( )

Destructor.

Definition at line 85 of file bids_path.cpp.

Member Function Documentation

◆ acquisition()

QString BIDSPath::acquisition ( ) const
Returns
Acquisition label, or an empty string if unset. Acquisition label.

Definition at line 170 of file bids_path.cpp.

◆ basename()

QString BIDSPath::basename ( ) const

Constructs the BIDS-compliant filename (without directory).

Format: sub-<label>[_ses-<label>][_task-<label>][_acq-<label>][_run-<index>] [_proc-<label>][_space-<label>][_recording-<label>][_split-<index>] [_desc-<label>]_<suffix><extension>

Returns
The BIDS filename.

Definition at line 215 of file bids_path.cpp.

◆ channelsTsvPath()

BIDSPath BIDSPath::channelsTsvPath ( ) const

Returns the path for the channels.tsv sidecar.

Returns
BIDSPath pointing to the *_channels.tsv file.

Definition at line 293 of file bids_path.cpp.

◆ coordsystemJsonPath()

BIDSPath BIDSPath::coordsystemJsonPath ( ) const

Returns the path for the coordsystem.json sidecar.

Returns
BIDSPath pointing to the *_coordsystem.json file.

Definition at line 313 of file bids_path.cpp.

◆ datatype()

QString BIDSPath::datatype ( ) const
Returns
BIDS datatype (e.g. "ieeg"), or an empty string if unset. BIDS datatype string.

Definition at line 198 of file bids_path.cpp.

◆ description()

QString BIDSPath::description ( ) const
Returns
Description label, or an empty string if unset. Description label.

Definition at line 194 of file bids_path.cpp.

◆ directory()

QString BIDSPath::directory ( ) const

Constructs the directory path for this entity combination.

Format: <root>/sub-<label>[/ses-<label>]/<datatype>/

Returns
The BIDS directory path (with trailing separator).

Definition at line 256 of file bids_path.cpp.

◆ electrodesTsvPath()

BIDSPath BIDSPath::electrodesTsvPath ( ) const

Returns the path for the electrodes.tsv sidecar.

Returns
BIDSPath pointing to the *_electrodes.tsv file.

Definition at line 300 of file bids_path.cpp.

◆ eventsTsvPath()

BIDSPath BIDSPath::eventsTsvPath ( ) const

Returns the path for the events.tsv sidecar.

Returns
BIDSPath pointing to the *_events.tsv file.

Definition at line 326 of file bids_path.cpp.

◆ exists()

bool BIDSPath::exists ( ) const

Checks whether the file at filePath() exists on disk.

Returns
true if the file exists.

Definition at line 341 of file bids_path.cpp.

◆ extension()

QString BIDSPath::extension ( ) const
Returns
File extension including the leading dot, or an empty string if unset. File extension.

Definition at line 206 of file bids_path.cpp.

◆ filePath()

QString BIDSPath::filePath ( ) const

Constructs the full file path: directory() + basename().

Returns
The complete file path.

Definition at line 274 of file bids_path.cpp.

◆ isValidEntityValue()

bool BIDSPath::isValidEntityValue ( const QString & sValue)
static

Validates entity values (no forbidden characters: -, _, /).

Parameters
[in]sValueEntity value to validate.
Returns
true if the value is valid.

Definition at line 430 of file bids_path.cpp.

◆ match()

QList< BIDSPath > BIDSPath::match ( ) const

Searches the BIDS root (all subject, session and datatype folders) for files whose entities, datatype, suffix and extension equal the ones set here; unset ones match anything, as in mne_bids.BIDSPath.match.

Returns
Matching paths, sorted by file path.

Definition at line 358 of file bids_path.cpp.

◆ mkdirs()

bool BIDSPath::mkdirs ( ) const

Creates the directory structure for this path (mkdir -p).

Returns
true if the directory exists or was created successfully.

Definition at line 348 of file bids_path.cpp.

◆ operator=()

BIDSPath & BIDSPath::operator= ( const BIDSPath & other)

Definition at line 443 of file bids_path.cpp.

◆ processing()

QString BIDSPath::processing ( ) const
Returns
Processing label, or an empty string if unset. Processing label.

Definition at line 178 of file bids_path.cpp.

◆ recording()

QString BIDSPath::recording ( ) const
Returns
Recording label, or an empty string if unset. Recording label.

Definition at line 186 of file bids_path.cpp.

◆ root()

QString BIDSPath::root ( ) const
Returns
Root directory of the BIDS dataset, or an empty string if unset. BIDS dataset root path.

Definition at line 154 of file bids_path.cpp.

◆ run()

QString BIDSPath::run ( ) const
Returns
Zero-padded run index, or an empty string if unset. Run index.

Definition at line 174 of file bids_path.cpp.

◆ session()

QString BIDSPath::session ( ) const
Returns
Session label without the "ses-" prefix, or an empty string if unset. Session label (without "ses-").

Definition at line 162 of file bids_path.cpp.

◆ setAcquisition()

void BIDSPath::setAcquisition ( const QString & sAcquisition)

Set the acquisition label.

Parameters
[in]sAcquisitionAcquisition label; empty to omit the entity.

Definition at line 109 of file bids_path.cpp.

◆ setDatatype()

void BIDSPath::setDatatype ( const QString & sDatatype)

Set the BIDS datatype (e.g. "ieeg", "eeg", "meg", "anat").

Parameters
[in]sDatatypeBIDS datatype, used as the innermost directory name.

Definition at line 137 of file bids_path.cpp.

◆ setDescription()

void BIDSPath::setDescription ( const QString & sDescription)

Set the description label.

Parameters
[in]sDescriptionDescription label; empty to omit the entity.

Definition at line 133 of file bids_path.cpp.

◆ setExtension()

void BIDSPath::setExtension ( const QString & sExtension)

Set the file extension including dot (e.g. ".vhdr", ".tsv", ".json").

Parameters
[in]sExtensionFile extension including the leading dot.

Definition at line 145 of file bids_path.cpp.

◆ setProcessing()

void BIDSPath::setProcessing ( const QString & sProcessing)

Set the processing label.

Parameters
[in]sProcessingProcessing label; empty to omit the entity.

Definition at line 117 of file bids_path.cpp.

◆ setRecording()

void BIDSPath::setRecording ( const QString & sRecording)

Set the recording label.

Parameters
[in]sRecordingRecording label; empty to omit the entity.

Definition at line 125 of file bids_path.cpp.

◆ setRoot()

void BIDSPath::setRoot ( const QString & sRoot)

Set the BIDS dataset root directory.

Parameters
[in]sRootRoot directory of the BIDS dataset.

Definition at line 93 of file bids_path.cpp.

◆ setRun()

void BIDSPath::setRun ( const QString & sRun)

Set the run index (will be zero-padded to 2 digits).

Parameters
[in]sRunRun index as a numeric string (e.g. "1" becomes "01"); empty to omit the entity.

Definition at line 113 of file bids_path.cpp.

◆ setSession()

void BIDSPath::setSession ( const QString & sSession)

Set the session label (without "ses-" prefix).

Parameters
[in]sSessionSession label without the "ses-" prefix; empty to omit the entity.

Definition at line 101 of file bids_path.cpp.

◆ setSpace()

void BIDSPath::setSpace ( const QString & sSpace)

Set the space label.

Parameters
[in]sSpaceSpace label (e.g. a coordinate system name); empty to omit the entity.

Definition at line 121 of file bids_path.cpp.

◆ setSplit()

void BIDSPath::setSplit ( const QString & sSplit)

Set the split index.

Parameters
[in]sSplitSplit index as a numeric string, zero-padded to 2 digits; empty to omit the entity.

Definition at line 129 of file bids_path.cpp.

◆ setSubject()

void BIDSPath::setSubject ( const QString & sSubject)

Set the subject label (without "sub-" prefix).

Parameters
[in]sSubjectSubject label without the "sub-" prefix.

Definition at line 97 of file bids_path.cpp.

◆ setSuffix()

void BIDSPath::setSuffix ( const QString & sSuffix)

Set the filename suffix (e.g. "ieeg", "channels", "electrodes", "coordsystem").

Parameters
[in]sSuffixFilename suffix appended after the entities.

Definition at line 141 of file bids_path.cpp.

◆ setTask()

void BIDSPath::setTask ( const QString & sTask)

Set the task label.

Parameters
[in]sTaskTask label; empty to omit the entity.

Definition at line 105 of file bids_path.cpp.

◆ sidecarJsonPath()

BIDSPath BIDSPath::sidecarJsonPath ( ) const

Returns the path for the sidecar JSON metadata file (e.g. *_ieeg.json, *_eeg.json).

Returns
BIDSPath pointing to the sidecar JSON file.

Definition at line 333 of file bids_path.cpp.

◆ space()

QString BIDSPath::space ( ) const
Returns
Space label, or an empty string if unset. Space label.

Definition at line 182 of file bids_path.cpp.

◆ split()

QString BIDSPath::split ( ) const
Returns
Zero-padded split index, or an empty string if unset. Split index.

Definition at line 190 of file bids_path.cpp.

◆ subject()

QString BIDSPath::subject ( ) const
Returns
Subject label without the "sub-" prefix, or an empty string if unset. Subject label (without "sub-").

Definition at line 158 of file bids_path.cpp.

◆ suffix()

QString BIDSPath::suffix ( ) const
Returns
Filename suffix, or an empty string if unset. Filename suffix.

Definition at line 202 of file bids_path.cpp.

◆ task()

QString BIDSPath::task ( ) const
Returns
Task label, or an empty string if unset. Task label.

Definition at line 166 of file bids_path.cpp.

◆ withSuffix()

BIDSPath BIDSPath::withSuffix ( const QString & sSuffix,
const QString & sExtension ) const

Returns a copy of this BIDSPath with updated suffix and extension. Useful for deriving sidecar paths from a data path.

Parameters
[in]sSuffixNew suffix (e.g. "channels", "electrodes", "coordsystem").
[in]sExtensionNew extension (e.g. ".tsv", ".json").
Returns
A new BIDSPath with the updated suffix and extension.

Definition at line 283 of file bids_path.cpp.

◆ operator==

bool operator== ( const BIDSPath & a,
const BIDSPath & b )
friend

Definition at line 392 of file bids_path.h.


The documentation for this class was generated from the following files: