get_entity_value

bidsaid.files.get_entity_value(filename, entity, return_entity_prefix=False)[source]

Gets entity value of a BIDS compliant filename.

Parameters

filenamestr or Path

Filename to extract entity from.

entitystr

The entity key (e.g. “sub”, “task”, etc).

return_entity_prefixbool, default=False

Return value with the entity (“sub-101” instead of “101”) if True.

Returns

str or None

The entity value with the entity prefix if return_entity_prefix is True.

Example

>>> from bidsaid.files import get_entity_value
>>> get_entity_value("sub-01_task-flanker_bold.nii.gz", "task")
    "flanker"