bids.layout.Entity

class Entity(name, pattern=None, mandatory=False, directory=None, dtype='str')[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.

Attributes:
directory
mandatory
name
pattern
tags

Methods

count([files])

Return a count of unique values or files.

match_file(f)

Determine whether the passed file matches the Entity.

unique()

Return all unique values/levels for the current entity.

__init__(name, pattern=None, mandatory=False, directory=None, dtype='str')

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

Methods

__init__(name[, pattern, mandatory, ...])

A simple constructor that allows initialization from kwargs.

count([files])

Return a count of unique values or files.

match_file(f)

Determine whether the passed file matches the Entity.

unique()

Return all unique values/levels for the current entity.

Attributes

directory

files

mandatory

metadata

name

pattern

registry

tags