bids.variables.entities¶
Data classes for internal BIDS data hierarchy.
Classes
|
Base class for objects that represent a single object in the BIDS hierarchy. |
Represents the top level in a BIDS hierarchy. |
|
A namedtuple storing run-related information. |
|
alias of |
|
|
Represents a single Run in a BIDS project. |
-
class
Node
(level, entities)[source]¶ Base class for objects that represent a single object in the BIDS hierarchy.
- Parameters
id (int or str) – A value uniquely identifying this node. Typically the entity value extracted from the filename via layout.
Methods
add_variable
(self, variable)Adds a BIDSVariable to the current Node’s list.
-
add_variable
(self, variable)[source]¶ Adds a BIDSVariable to the current Node’s list.
- Parameters
variable (BIDSVariable) – The Variable to add to the list.
-
class
NodeIndex
[source]¶ Represents the top level in a BIDS hierarchy.
Methods
create_node
(self, level, entities, \*args, …)Creates a new child Node.
get_collections
(self, unit[, names, merge, …])Retrieve variable data for a specified level in the Dataset.
get_nodes
(self[, level, entities, strict])Retrieves all nodes that match the specified criteria.
get_or_create_node
(self, level, entities, …)Retrieves a child Node based on the specified criteria, creating a new Node if necessary.
-
create_node
(self, level, entities, *args, **kwargs)[source]¶ Creates a new child Node.
- Parameters
level (str) – The level of analysis of the new Node.
entities (dict) – Dictionary of entities belonging to Node.
kwargs (args,) – Optional positional or named arguments to pass on to class-specific initializers. These arguments are only used if a Node that matches the passed entities doesn’t already exist, and a new one must be created.
- Returns
- Return type
A Node instance.
-
get_collections
(self, unit, names=None, merge=False, sampling_rate=None, **entities)[source]¶ Retrieve variable data for a specified level in the Dataset.
- Parameters
unit (str) – The unit of analysis to return variables for. Must be one of ‘run’, ‘session’, ‘subject’, or ‘dataset’.
names (list) – Optional list of variables names to return. If None, all available variables are returned.
merge (bool) – If True, variables are merged across all observations of the current unit. E.g., if unit=’subject’ and return_type= ‘collection’, variables from all subjects will be merged into a single collection. If False, each observation is handled separately, and the result is returned as a list.
sampling_rate (int or str) – If unit=’run’, the sampling rate to pass onto the returned BIDSRunVariableCollection.
entities (dict) – Optional constraints used to limit what gets returned.
- Returns
A list of BIDSVariableCollections if merge=False; a single
BIDSVariableCollection if merge=True.
-
get_nodes
(self, level=None, entities=None, strict=False)[source]¶ Retrieves all nodes that match the specified criteria.
- Parameters
level (str) – The level of analysis of nodes to return.
entities (dict) – Entities to filter on. All nodes must have matching values on all defined keys to be included.
strict (bool) – If True, an exception will be raised if the entities dict contains any keys that aren’t contained in the current index.
- Returns
- Return type
A list of Node instances.
-
get_or_create_node
(self, level, entities, *args, **kwargs)[source]¶ Retrieves a child Node based on the specified criteria, creating a new Node if necessary.
- Parameters
level (str) – The level of analysis of the Node.
entities (dict) – Dictionary of entities to include in newly-created Nodes or filter existing ones.
kwargs (args,) – Optional positional or named arguments to pass on to class-specific initializers. These arguments are only used if a Node that matches the passed entities doesn’t already exist, and a new one must be created.
- Returns
- Return type
A Node instance.
-
-
class
RunInfo
[source]¶ A namedtuple storing run-related information.
Properties include ‘entities’, ‘duration’, ‘tr’, and ‘image’.
- Attributes
- duration
Alias for field number 1
- entities
Alias for field number 0
- image
Alias for field number 3
- tr
Alias for field number 2
Methods
count
(self, value, /)Return number of occurrences of value.
index
(self, value[, start, stop])Return first index of value.
-
count
(self, value, /)¶ Return number of occurrences of value.
-
duration
¶ Alias for field number 1
-
entities
¶ Alias for field number 0
-
image
¶ Alias for field number 3
-
index
(self, value, start=0, stop=2147483647, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
tr
¶ Alias for field number 2
-
RunInfo_
¶ alias of
bids.variables.entities.RunInfo
-
class
RunNode
(entities, image_file, duration, repetition_time)[source]¶ Represents a single Run in a BIDS project.
- Parameters
id (int) – The index of the run.
entities (dict) – Dictionary of entities for this Node.
image_file (str) – The full path to the corresponding nifti image.
duration (float) – Duration of the run, in seconds.
repetition_time (float) – TR for the run.
task (str) – The task name for this run.
Methods
add_variable
(self, variable)Adds a BIDSVariable to the current Node’s list.
get_info
-
add_variable
(self, variable)¶ Adds a BIDSVariable to the current Node’s list.
- Parameters
variable (BIDSVariable) – The Variable to add to the list.