xcp_d.utils.utils module
Miscellaneous utility functions for xcp_d.
- xcp_d.utils.utils.denoise_with_nilearn(preprocessed_bold, confounds, voxelwise_confounds, sample_mask, low_pass, high_pass, filter_order, TR, num_threads)[source]
A wrapper to call _denoise_with_nilearn using multiprocessing
- xcp_d.utils.utils.estimate_brain_radius(mask_file, head_radius='auto')[source]
Estimate brain radius from binary brain mask file.
- Parameters:
mask_file (
str) – Binary brain mask file, in nifti format.head_radius (
floator “auto”) – Radius of the head, in millimeters, for framewise displacement calculation.xcp_d’s default head radius is 50. The recommended value for infants is 35. A value of ‘auto’ is also supported, in which case the brain radius is estimated from the preprocessed brain mask.
- Returns:
brain_radius – Estimated brain radius, in millimeters.
- Return type:
Notes
This function estimates the brain radius based on the brain volume, assuming that the brain is a sphere. This was Paul Taylor’s idea, shared in this NeuroStars post: https://neurostars.org/t/estimating-head-brain-radius-automatically/24290/2.
- xcp_d.utils.utils.fwhm2sigma(fwhm)[source]
Convert full width at half maximum to sigma.
- Parameters:
fwhm (float) – Full width at half maximum.
- Returns:
Sigma.
- Return type:
- xcp_d.utils.utils.get_bold2std_and_t1w_xfms(bold_file, template_to_anat_xfm)[source]
Find transform files in reverse order to transform BOLD to MNI152NLin2009cAsym/T1w space.
Since ANTSApplyTransforms takes in the transform files as a stack, these are applied in the reverse order of which they are specified.
NOTE: This is a Node function.
- Parameters:
bold_file (
str) – The preprocessed BOLD file.template_to_anat_xfm – The
fromfield is assumed to be the same space as the BOLD file is in. The MNI space could be MNI152NLin2009cAsym, MNI152NLin6Asym, or MNIInfant.
- Returns:
xforms_to_MNI (list of str) – A list of paths to transform files for warping to MNI152NLin2009cAsym space.
xforms_to_MNI_invert (list of bool) – A list of booleans indicating whether each transform in xforms_to_MNI indicating if each should be inverted (True) or not (False).
xforms_to_T1w (list of str) – A list of paths to transform files for warping to T1w space.
xforms_to_T1w_invert (list of bool) – A list of booleans indicating whether each transform in xforms_to_T1w indicating if each should be inverted (True) or not (False).
Notes
Only used for QCReport in init_postprocess_nifti_wf. QCReport wants MNI-space data in MNI152NLin2009cAsym.
- xcp_d.utils.utils.get_std2bold_xfms(bold_file, source_file, source_space=None)[source]
Obtain transforms to warp atlases from a source space to the same template as the BOLD.
Since ANTSApplyTransforms takes in the transform files as a stack, these are applied in the reverse order of which they are specified.
NOTE: This is a Node function.
- Parameters:
- Returns:
transforms – A list of paths to transform files.
- Return type:
Notes
Used by:
to resample dseg in init_postprocess_nifti_wf for QCReport
to warp atlases to the same space as the BOLD data in init_functional_connectivity_nifti_wf
to resample dseg to BOLD space for the executive summary plots
Does not include inversion flag output because there is no need (yet). Can easily be added in the future.