9.1.3. Pre-processing#
Provide imports for preprocess sub-package.
- class junifer.preprocess.BOLDWarper(using, reference)#
Class for warping BOLD NIfTI images.
Deprecated since version 0.0.3: BOLDWarper will be removed in v0.0.4, it is replaced by SpaceWarper because the latter works also with T1w data.
- Parameters:
- using{“fsl”, “ants”}
Implementation to use for warping:
“fsl” : Use FSL’s
applywarp
“afni” : Use ANTs’
antsApplyTransforms
- reference
str
The data type to use as reference for warping, can be either a data type like “T1w” or a template space like “MNI152NLin2009cAsym”.
- Raises:
ValueError
If
using
is invalid or ifreference
is invalid.
Notes
If you are setting
reference
to a template space like “MNI152NLin2009cAsym”, make sure ANTs is available for the transformation else it will fail during runtime. It is tricky to validate this beforehand and difficult to enforce this as a requirement, hence the heads-up.Initialize the class.
- get_output_type(input_type)#
Get output type.
- get_valid_inputs()#
Get valid data types for input.
- preprocess(input, extra_input=None)#
Preprocess.
- Parameters:
- Returns:
- Raises:
ValueError
If
extra_input
is None when transforming to native space i.e., using “T1w” as reference.RuntimeError
If warp / transformation file extension is not “.mat” or “.h5” when transforming to native space or if the BOLD data is in the correct space and does not require warping.
- class junifer.preprocess.BasePreprocessor(on=None, required_data_types=None)#
Abstract base class for all preprocessors.
For every interface that is required, one needs to provide a concrete implementation of this abstract class.
- Parameters:
- Raises:
ValueError
If required input data type(s) is(are) not found.
Initialize the class.
- abstract get_output_type(input_type)#
Get output type.
- abstract get_valid_inputs()#
Get valid data types for input.
- abstract preprocess(input, extra_input=None)#
Preprocess.
- Parameters:
- input
dict
A single input from the Junifer Data object to preprocess.
- extra_input
dict
, optional The other fields in the Junifer Data object. Useful for accessing other data kind that needs to be used in the computation. For example, the confound removers can make use of the confounds if available (default None).
- input
- Returns:
- validate_input(input)#
Validate input.
- Parameters:
- Returns:
- Raises:
ValueError
If the input does not have the required data.
- class junifer.preprocess.SpaceWarper(using, reference, on)#
Class for warping data to other template spaces.
- Parameters:
- using{“fsl”, “ants”}
Implementation to use for warping:
“fsl” : Use FSL’s
applywarp
“ants” : Use ANTs’
antsApplyTransforms
- reference
str
The data type to use as reference for warping, can be either a data type like
"T1w"
or a template space like"MNI152NLin2009cAsym"
. Use"T1w"
for native space warping and named templates for template space warping.- on{“T1w”, “T2w”, “BOLD”, “VBM_GM”, “VBM_WM”, “VBM_CSF”, “fALFF”, “GCOR”, “LCOR”} or
list
of the options The data type to warp.
- Raises:
ValueError
If
using
is invalid or ifreference
is invalid.
Initialize the class.
- get_output_type(input_type)#
Get output type.
- get_valid_inputs()#
Get valid data types for input.
- preprocess(input, extra_input=None)#
Preprocess.
- Parameters:
- Returns:
- Raises:
ValueError
If
extra_input
is None when transforming to native space i.e., using"T1w"
as reference.RuntimeError
If the data is in the correct space and does not require warping or if FSL is used for template space warping.
- class junifer.preprocess.fMRIPrepConfoundRemover(strategy=None, spike=None, detrend=True, standardize=True, low_pass=None, high_pass=None, t_r=None, masks=None)#
Class for confound removal using fMRIPrep confounds format.
Read confound files and select columns according to a pre-defined strategy.
Confound removal is based on
nilearn.image.clean_img()
.- Parameters:
- strategy
dict
, optional The strategy to use for each component. If None, will use the full strategy for all components (default None). The keys of the dictionary should correspond to names of noise components to include:
motion
wm_csf
global_signal
The values of dictionary should correspond to types of confounds extracted from each signal:
basic
: only the confounding time seriespower2
: signal + quadratic termderivatives
: signal + derivativesfull
: signal + deriv. + quadratic terms + power2 deriv.
- spike
float
, optional If None, no spike regressor is added. If spike is a float, it will add a spike regressor for every point at which framewise displacement exceeds the specified float (default None).
- detrendbool, optional
If True, detrending will be applied on timeseries, before confound removal (default True).
- standardizebool, optional
If True, returned signals are set to unit variance (default True).
- low_pass
float
, optional Low cutoff frequencies, in Hertz. If None, no filtering is applied (default None).
- high_pass
float
, optional High cutoff frequencies, in Hertz. If None, no filtering is applied (default None).
- t_r
float
, optional Repetition time, in second (sampling period). If None, it will use t_r from nifti header (default None).
- masks
str
,dict
orlist
ofdict
orstr
, optional The specification of the masks to apply to regions before extracting signals. Check Using Masks for more details. If None, will not apply any mask (default None).
- strategy
Initialize the class.
- get_output_type(input_type)#
Get output type.
- get_valid_inputs()#
Get valid data types for input.
- preprocess(input, extra_input=None)#
Preprocess.
- Parameters:
- Returns: