bids.analysis.analysis.AnalysisNode¶
-
class
AnalysisNode
(level, collection, contrasts, input_nodes=None, dummy_contrasts=None)[source]¶ A single analysis node generated within a Step.
- Parameters
level (str) – The level of the Node. Most be one of ‘run’, ‘session’, ‘subject’, or ‘dataset’.
collection (
bids.variables.kollekshuns.BIDSVariableCollection
) – The BIDSVariableCollection containing variables at this Node.contrasts (list) – A list of contrasts defined in the originating Step.
dummy_contrasts (list) – Optional dictionary specifying which conditions to create indicator contrasts for. Dictionary must include a “type” key (‘t’ or ‘FEMA’), and optionally a subset of “conditions”. This parameter is over-written by the setting in setup() if the latter is passed.
- Attributes
- contrasts
- entities
Methods
get_contrasts
(self[, names, variables])Return contrast information for the current block.
get_design_matrix
(self[, names, format, …])Get design matrix and associated information.
matches_entities
(self, entities[, strict])Determine whether current AnalysisNode matches passed entities.
-
__init__
(self, level, collection, contrasts, input_nodes=None, dummy_contrasts=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(self, level, collection, contrasts)Initialize self.
get_contrasts
(self[, names, variables])Return contrast information for the current block.
get_design_matrix
(self[, names, format, …])Get design matrix and associated information.
matches_entities
(self, entities[, strict])Determine whether current AnalysisNode matches passed entities.
Attributes
contrasts
entities
-
get_contrasts
(self, names=None, variables=None)[source]¶ Return contrast information for the current block.
- Parameters
names (list) – Optional list of names of contrasts to return. If None (default), all contrasts are returned.
variables (bool) – Optional list of strings giving the names of design matrix columns to use when generating the matrix of weights.
- Returns
A list of ContrastInfo namedtuples, one per contrast.
- Return type
list
Notes
The ‘variables’ argument take precedence over the natural process of column selection. I.e.,
if a variable shows up in a contrast, but isn’t named in variables, it will not be included in the returned
-
get_design_matrix
(self, names=None, format='long', mode='both', force=False, sampling_rate='TR', **kwargs)[source]¶ Get design matrix and associated information.
- Parameters
names (list) – Optional list of names of variables to include in the returned design matrix. If None, all variables are included.
format (str) – Whether to return the design matrix in ‘long’ or ‘wide’ format. Note that dense design matrices are always returned in ‘wide’ format.
mode (str) – Specifies whether to return variables in a sparse representation (‘sparse’), dense representation (‘dense’), or both (‘both’).
force (bool) – Indicates how to handle columns not of the type indicated by the mode argument. When False, variables of the non-selected type will be silently ignored. When True, variables will be forced to the desired representation. For example, if mode=’dense’ and force=True, sparse variables will be converted to dense variables and included in the returned design matrix in the .dense attribute. The force argument is ignored entirely if mode=’both’.
sampling_rate ({'TR', 'highest'} or float) – Sampling rate at which to generate the dense design matrix. When ‘TR’, the repetition time is used, if available, to select the sampling rate (1/TR). When ‘highest’, all variables are resampled to the highest sampling rate of any variable. The sampling rate may also be specified explicitly in Hz. Has no effect on sparse design matrices.
kwargs (dict) – Optional keyword arguments to pass onto each Variable’s to_df() call (e.g., sampling_rate, entities, timing, etc.).
- Returns
- Return type
A DesignMatrixInfo namedtuple.
-
matches_entities
(self, entities, strict=False)[source]¶ Determine whether current AnalysisNode matches passed entities.
- Parameters
entities (dict) – Dictionary of entities to match. Keys are entity names; values are single values or lists.
strict (bool) – If True, _all_ entities in the current Node must match in order to return True.