niworkflows.interfaces.confounds module¶
Select terms for a confound model, and compute any requisite expansions.

class
niworkflows.interfaces.confounds.
ExpandModel
(from_file=None, resource_monitor=None, **inputs)[source]¶ Bases:
nipype.interfaces.base.core.SimpleInterface
Expand a confound model according to a specified formula.

input_spec
¶ alias of
niworkflows.interfaces.confounds._ExpandModelInputSpec

output_spec
¶ alias of
niworkflows.interfaces.confounds._ExpandModelOutputSpec


class
niworkflows.interfaces.confounds.
NormalizeMotionParams
(from_file=None, resource_monitor=None, **inputs)[source]¶ Bases:
nipype.interfaces.base.core.SimpleInterface
Convert input motion parameters into the designated convention.

input_spec
¶ alias of
niworkflows.interfaces.confounds._NormalizeMotionParamsInputSpec

output_spec
¶ alias of
niworkflows.interfaces.confounds._NormalizeMotionParamsOutputSpec


class
niworkflows.interfaces.confounds.
SpikeRegressors
(from_file=None, resource_monitor=None, **inputs)[source]¶ Bases:
nipype.interfaces.base.core.SimpleInterface
Generate spike regressors.

input_spec
¶ alias of
niworkflows.interfaces.confounds._SpikeRegressorsInputSpec

output_spec
¶ alias of
niworkflows.interfaces.confounds._SpikeRegressorsOutputSpec


niworkflows.interfaces.confounds.
exponential_terms
(order, variables, data)[source]¶ Compute exponential expansions.
 Parameters
order (
list
ofint
) – A list of exponential terms to include. For instance,[1, 2]
indicates that the first and second exponential terms should be added. To retain the original terms,1
must be included in the list.variables (
list
ofstr
) – List of variables for which exponential terms should be computed.data (
DataFrame
) – Table of values of all observations of all variables.
 Returns
variables_exp (
list
) – A list of variables to include in the final data frame after adding the specified exponential terms.data_exp (
DataFrame
) – Table of values of all observations of all variables, including any specified exponential terms.

niworkflows.interfaces.confounds.
parse_expression
(expression, parent_data)[source]¶ Parse an expression in a model formula.
 Parameters
expression (
str
) – Formula expression: either a single variable or a variable group paired with an operation (exponentiation or differentiation).parent_data (
DataFrame
) – The source data for the model expansion.
 Returns
variables (
list
) – A list of variables in the provided formula expression.data (
DataFrame
) – A tabulation of all terms in the provided formula expression.

niworkflows.interfaces.confounds.
parse_formula
(model_formula, parent_data, unscramble=False)[source]¶ Parse a confound manipulation formula.
Recursively parse a model formula by breaking it into additive atoms and tracking grouping symbol depth.
 Parameters
model_formula (
str
) – Expression for the model formula, e.g.(a + b)^^2 + dd1(c + (d + e)^3) + f
Note that any expressions to be expanded must be in parentheses, even if they include only a single variable (e.g.,(x)^2
, notx^2
). Temporal derivative options:d6(variable)
for the 6th temporal derivativedd6(variable)
for all temporal derivatives up to the 6thd46(variable)
for the 4th through 6th temporal derivatives0
must be included in the temporal derivative range for the original term to be returned when temporal derivatives are computed.
Exponential options:
(variable)^6
for the 6th power(variable)^^6
for all powers up to the 6th(variable)^46
for the 4th through 6th powers1
must be included in the powers range for the original term to be returned when exponential terms are computed.
Temporal derivatives and exponential terms are computed for all terms in the grouping symbols that they adjoin.
parent_data (
DataFrame
) – A tabulation of all values usable in the model formula. Each additive term in model_formula should correspond either to a variable in this data frame or to instructions for operating on a variable (for instance, computing temporal derivatives or exponential terms).
 Returns

niworkflows.interfaces.confounds.
spike_regressors
(data, criteria=None, header_prefix='motion_outlier', lags=None, minimum_contiguous=None, concatenate=True, output='spikes')[source]¶ Add spike regressors to a confound/nuisance matrix.
 Parameters
data (
DataFrame
) – A tabulation of observations from which spike regressors should be estimated.criteria (
dict
of (str
,'>'
or'<'
orfloat
)) – Criteria for generating a spike regressor. If, for a given frame, the value of the variable corresponding to the key exceeds the threshold indicated by the value, then a spike regressor is created for that frame. By default, the strategy from [Power2014] is implemented: any frames with FD greater than 0.5 or standardised DV greater than 1.5 are flagged for censoring.header_prefix (
str
) – The prefix used to indicate spike regressors in the output data table.lags (
list
ofint
) – A list indicating the frames to be censored relative to each flag. For instance,[0]
censors the flagged frame, while[0, 1]
censors both the flagged frame and the following frame.minimum_contiguous (
int
orNone
) – The minimum number of contiguous frames that must be unflagged for spike regression. If any series of contiguous unflagged frames is shorter than the specified minimum, then all of those frames will additionally have spike regressors implemented.concatenate (
bool
) – Indicates whether the returned object should include only spikes (if false) or all input time series and spikes (if true, default).output (
str
) – Indicates whether the output should be formatted as spike regressors (‘spikes’, a separate column for each outlier) or as a temporal mask (‘mask’, a single output column indicating the locations of outliers).
 Returns
data – The input DataFrame with a column for each spike regressor.
 Return type
DataFrame
References
 Power2014
Power JD, et al. (2014) Methods to detect, characterize, and remove motion artifact in resting state fMRI. NeuroImage. doi:10.1016/j.neuroimage.2013.08.048.

niworkflows.interfaces.confounds.
temporal_derivatives
(order, variables, data)[source]¶ Compute temporal derivative terms by the method of backwards differences.
 Parameters
order (
list
ofint
) – A list of temporal derivative terms to include. For instance,[1, 2]
indicates that the first and second derivative terms should be added. To retain the original terms,0
must be included in the list.variables (
list
ofstr
) – List of variables for which temporal derivative terms should be computed.data (
DataFrame
) – Table of values of all observations of all variables.
 Returns
variables_deriv (
list
) – A list of variables to include in the final data frame after adding the specified derivative terms.data_deriv (
DataFrame
) – Table of values of all observations of all variables, including any specified derivative terms.