bids.layout.Entity¶
-
class
Entity
(name, pattern=None, mandatory=False, directory=None, dtype='str', is_metadata=False)[source]¶ Represents a single entity defined in the JSON config.
- Parameters
name (str) – The name of the entity (e.g., ‘subject’, ‘run’, etc.)
pattern (str) – A regex pattern used to match against file names. Must define at least one group, and only the first group is kept as the match.
mandatory (bool) – If True, every File _must_ match this entity.
directory (str) – Optional pattern defining a directory associated with the entity.
dtype (str) – The optional data type of the Entity values. Must be one of ‘int’, ‘float’, ‘bool’, or ‘str’. If None, no type enforcement will be attempted, which means the dtype of the value may be unpredictable.
is_metadata (bool) – Indicates whether or not the Entity is derived from JSON sidecars (True) or is a predefined Entity from a config (False).
- Attributes
- directory
- is_metadata
- mandatory
- name
- pattern
- tags
Methods
count
(self[, files])Return a count of unique values or files.
match_file
(self, f)Determine whether the passed file matches the Entity.
unique
(self)Return all unique values/levels for the current entity.
-
__init__
(self, name, pattern=None, mandatory=False, directory=None, dtype='str', is_metadata=False)¶
Methods
__init__
(self, name[, pattern, mandatory, …])count
(self[, files])Return a count of unique values or files.
match_file
(self, f)Determine whether the passed file matches the Entity.
unique
(self)Return all unique values/levels for the current entity.
Attributes
directory
files
is_metadata
mandatory
metadata
name
pattern
tags
-
count
(self, files=False)[source]¶ Return a count of unique values or files.
- Parameters
files (bool) – When True, counts all files mapped to the Entity. When False, counts all unique values.
- Returns
Count of unique values or files.
- Return type
int