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< BIDSPathmatch () const
BIDSPathoperator= (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.

Example usage:

BIDSPath path;
path.setRoot("/data/bids_dataset");
path.setSubject("01");
path.setSession("implant01");
path.setTask("rest");
path.setDatatype("ieeg");
path.setSuffix("ieeg");
path.setExtension(".vhdr");
// Produces: sub-01_ses-implant01_task-rest_ieeg.vhdr
QString filename = path.basename();
// Produces: /data/bids_dataset/sub-01/ses-implant01/ieeg/
QString dir = path.directory();
// Produces: /data/bids_dataset/sub-01/ses-implant01/ieeg/sub-01_ses-implant01_task-rest_ieeg.vhdr
QString full = path.filePath();
void setSession(const QString &sSession)
QString filePath() const
void setSubject(const QString &sSubject)
void setDatatype(const QString &sDatatype)
QString directory() const
void setTask(const QString &sTask)
void setRoot(const QString &sRoot)
QString basename() const
void setSuffix(const QString &sSuffix)
void setExtension(const QString &sExtension)

Definition at line 91 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 95 of file bids_path.h.

◆ SPtr

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

Shared pointer type for BIDSPath.

Definition at line 94 of file bids_path.h.

Constructor & Destructor Documentation

◆ BIDSPath() [1/3]

BIDSPath::BIDSPath ( )

Constructs an empty BIDSPath.

Definition at line 60 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 66 of file bids_path.cpp.

◆ BIDSPath() [3/3]

BIDSPath::BIDSPath ( const BIDSPath & other)

Copy constructor.

Definition at line 85 of file bids_path.cpp.

◆ ~BIDSPath()

BIDSPath::~BIDSPath ( )

Destructor.

Definition at line 105 of file bids_path.cpp.

Member Function Documentation

◆ acquisition()

QString BIDSPath::acquisition ( ) const

Acquisition label.

Definition at line 136 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>][_rec-<label>][_split-<index>] [_desc-<label>]<suffix><extension>

Returns
The BIDS filename.

Definition at line 151 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 229 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 249 of file bids_path.cpp.

◆ datatype()

QString BIDSPath::datatype ( ) const

BIDS datatype string.

Definition at line 143 of file bids_path.cpp.

◆ description()

QString BIDSPath::description ( ) const

Description label.

Definition at line 142 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 192 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 236 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 262 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 277 of file bids_path.cpp.

◆ extension()

QString BIDSPath::extension ( ) const

File extension.

Definition at line 145 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 210 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 370 of file bids_path.cpp.

◆ match()

QList< BIDSPath > BIDSPath::match ( ) const

Searches the BIDS root for all files matching the current entities. Wildcards are used for unset entities.

Returns
List of matching BIDSPath objects.

Definition at line 294 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 284 of file bids_path.cpp.

◆ operator=()

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

Definition at line 383 of file bids_path.cpp.

◆ processing()

QString BIDSPath::processing ( ) const

Processing label.

Definition at line 138 of file bids_path.cpp.

◆ recording()

QString BIDSPath::recording ( ) const

Recording label.

Definition at line 140 of file bids_path.cpp.

◆ root()

QString BIDSPath::root ( ) const

BIDS dataset root path.

Definition at line 132 of file bids_path.cpp.

◆ run()

QString BIDSPath::run ( ) const

Run index.

Definition at line 137 of file bids_path.cpp.

◆ session()

QString BIDSPath::session ( ) const

Session label (without "ses-").

Definition at line 134 of file bids_path.cpp.

◆ setAcquisition()

void BIDSPath::setAcquisition ( const QString & sAcquisition)

Set the acquisition label.

Definition at line 117 of file bids_path.cpp.

◆ setDatatype()

void BIDSPath::setDatatype ( const QString & sDatatype)

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

Definition at line 124 of file bids_path.cpp.

◆ setDescription()

void BIDSPath::setDescription ( const QString & sDescription)

Set the description label.

Definition at line 123 of file bids_path.cpp.

◆ setExtension()

void BIDSPath::setExtension ( const QString & sExtension)

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

Definition at line 126 of file bids_path.cpp.

◆ setProcessing()

void BIDSPath::setProcessing ( const QString & sProcessing)

Set the processing label.

Definition at line 119 of file bids_path.cpp.

◆ setRecording()

void BIDSPath::setRecording ( const QString & sRecording)

Set the recording label.

Definition at line 121 of file bids_path.cpp.

◆ setRoot()

void BIDSPath::setRoot ( const QString & sRoot)

Set the BIDS dataset root directory.

Definition at line 113 of file bids_path.cpp.

◆ setRun()

void BIDSPath::setRun ( const QString & sRun)

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

Definition at line 118 of file bids_path.cpp.

◆ setSession()

void BIDSPath::setSession ( const QString & sSession)

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

Definition at line 115 of file bids_path.cpp.

◆ setSpace()

void BIDSPath::setSpace ( const QString & sSpace)

Set the space label.

Definition at line 120 of file bids_path.cpp.

◆ setSplit()

void BIDSPath::setSplit ( const QString & sSplit)

Set the split index.

Definition at line 122 of file bids_path.cpp.

◆ setSubject()

void BIDSPath::setSubject ( const QString & sSubject)

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

Definition at line 114 of file bids_path.cpp.

◆ setSuffix()

void BIDSPath::setSuffix ( const QString & sSuffix)

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

Definition at line 125 of file bids_path.cpp.

◆ setTask()

void BIDSPath::setTask ( const QString & sTask)

Set the task label.

Definition at line 116 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 269 of file bids_path.cpp.

◆ space()

QString BIDSPath::space ( ) const

Space label.

Definition at line 139 of file bids_path.cpp.

◆ split()

QString BIDSPath::split ( ) const

Split index.

Definition at line 141 of file bids_path.cpp.

◆ subject()

QString BIDSPath::subject ( ) const

Subject label (without "sub-").

Definition at line 133 of file bids_path.cpp.

◆ suffix()

QString BIDSPath::suffix ( ) const

Filename suffix.

Definition at line 144 of file bids_path.cpp.

◆ task()

QString BIDSPath::task ( ) const

Task label.

Definition at line 135 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 219 of file bids_path.cpp.

◆ operator==

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

Definition at line 406 of file bids_path.cpp.


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