Functional Preprocessing¶
Ingress¶
Motion¶
Functions for calculating motion parameters.
NodeBlockFunction: calc_motion_stats
- CPAC.func_preproc.func_motion.calc_motion_stats(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Calculate motion statistics for motion parameters.
- CPAC.func_preproc.func_motion.estimate_reference_image(in_file)[source]¶
fMRIPrep-style BOLD reference.
Generate a reference 3D map from BOLD and SBRef EPI images for BOLD datasets.
Given a 4D BOLD file[…], estimate a reference image for subsequent motion estimation and coregistration steps. For the case of BOLD datasets, it estimates a number of T1w saturated volumes (non-steady state at the beginning of the scan) and calculates the median across them. Otherwise (SBRefs or detected zero non-steady state frames), a median of of a subset of motion corrected volumes is used.
Ref: https://github.com/nipreps/niworkflows/blob/6d4f2b5/niworkflows/interfaces/registration.py#L446-L549
NodeBlockFunction: motion_correction
NodeBlockFunction: motion_correction_only
- CPAC.func_preproc.func_motion.func_motion_correct_only(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
NodeBlockFunction: motion_estimates
- CPAC.func_preproc.func_motion.func_motion_estimates(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Calculate motion estimates using 3dVolReg or MCFLIRT.
NodeBlockFunction: get_motion_ref
- CPAC.func_preproc.func_motion.motion_correct_3dvolreg(wf, cfg, strat_pool, pipe_num)[source]¶
Calculate motion parameters with 3dvolreg.
- CPAC.func_preproc.func_motion.motion_correct_connections(wf, cfg, strat_pool, pipe_num, opt)[source]¶
Check opt for valid option, then connect that option.
- CPAC.func_preproc.func_motion.motion_correct_mcflirt(wf, cfg, strat_pool, pipe_num)[source]¶
Calculate motion parameters with MCFLIRT.
NodeBlockFunction: motion_estimate_filter
- CPAC.func_preproc.func_motion.motion_estimate_filter(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Filter motion parameters.
Changed in version 1.8.6: Beginning with version 1.8.6, C-PAC outputs both the unfiltered and the filtered motion parameters and uses the unfiltered parameters in QC. Previous versions only reported the filtered parameters and used the filtered parameters for QC.
Preprocessing¶
Functional preprocessing.
- CPAC.func_preproc.func_preproc.anat_based_mask(wf_name='bold_mask')[source]¶
Generate a functional mask from anatomical data.
Reference DCAN lab BOLD mask.
- CPAC.func_preproc.func_preproc.anat_refined_mask(init_bold_mask=True, wf_name='init_bold_mask')[source]¶
Generate an anatomically refined mask.
NodeBlockFunction: bold_mask_afni
- CPAC.func_preproc.func_preproc.bold_mask_afni(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate a functional mask with AFNI.
NodeBlockFunction: bold_mask_anatomical_based
- CPAC.func_preproc.func_preproc.bold_mask_anatomical_based(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate the BOLD mask by basing it off of the anatomical brain mask.
Adapted from DCAN Lab’s BOLD mask method from the ABCD pipeline.
NodeBlockFunction: bold_mask_anatomical_refined
- CPAC.func_preproc.func_preproc.bold_mask_anatomical_refined(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate the BOLD mask by basing it off of the refined anatomical brain mask.
NodeBlockFunction: bold_mask_anatomical_resampled
- CPAC.func_preproc.func_preproc.bold_mask_anatomical_resampled(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Resample anatomical brain mask to get BOLD brain mask in standard space.
Adapted from DCAN Lab’s BOLD mask method from the ABCD pipeline.
NodeBlockFunction: bold_mask_ccs
- CPAC.func_preproc.func_preproc.bold_mask_ccs(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate the BOLD mask by basing it off of the anatomical brain.
Adapted from the BOLD mask method from the CCS pipeline.
NodeBlockFunction: bold_mask_fsl
- CPAC.func_preproc.func_preproc.bold_mask_fsl(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate functional mask with FSL.
NodeBlockFunction: bold_mask_fsl_afni
- CPAC.func_preproc.func_preproc.bold_mask_fsl_afni(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
fMRIPrep-style BOLD mask.
Enhance and run brain extraction on a BOLD EPI image.
This workflow takes in a BOLD fMRI average/summary (e.g., a reference image averaging non-steady-state timepoints), and sharpens the histogram with the application of the N4 algorithm for removing the INU bias field and calculates a signal mask.
Steps of this workflow are:
[1]. Binary dilation of the tentative mask with a sphere of 3mm diameter. [2]. Run ANTs’
N4BiasFieldCorrection
on the inputBOLD average, using the mask generated in 1) instead of the internal Otsu thresholding.
- [3]. Calculate a loose mask using FSL’s
bet
, with one mathematical morphology dilation of one iteration and a sphere of 6mm as structuring element.
- [4]. Mask the INU-corrected image
with the latest mask calculated in 3), then use AFNI’s
3dUnifize
to standardize the T2* contrast distribution.- [5]. Calculate a mask using AFNI’s
3dAutomask
after the contrast enhancement of 4).
[6]. Calculate a final mask as the intersection of 4) and 6). [7]. Apply final mask on the enhanced reference.
Ref.
- [3]. Calculate a loose mask using FSL’s
NodeBlockFunction: bold_masking
- CPAC.func_preproc.func_preproc.bold_masking(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate a functional brain mask.
- CPAC.func_preproc.func_preproc.create_scale_func_wf(scaling_factor, wf_name='scale_func')[source]¶
Workflow to scale func data.
- Workflow Inputs::
- inputspec.funcfunc file or a list of func/rest nifti file
User input functional(T2*) Image
- Workflow Outputs::
- outputspec.scaled_funcstr (nifti file)
Path to Output image with scaled data
Order of commands: - Scale the size of the dataset voxels by the factor ‘fac’. For details see 3dcalc:
3drefit -xyzscale fac rest.nii.gz
- CPAC.func_preproc.func_preproc.create_wf_edit_func(wf_name='edit_func')[source]¶
Workflow to edit the scan to the proscribed TRs.
Workflow Inputs:
inputspec.func : func file or a list of func/rest nifti file User input functional(T2*) Image inputspec.start_idx : str Starting volume/slice of the functional image (optional) inputspec.stop_idx : str Last volume/slice of the functional image (optional)
Workflow Outputs:
outputspec.edited_func : str (nifti file) Path to Output image with the initial few slices dropped
Order of commands:
Get the start and the end volume index of the functional run. If not defined by the user, return the first and last volume.
get_idx(in_files, stop_idx, start_idx)
Dropping the initial TRs. For details see 3dcalc:
3dcalc -a rest.nii.gz[4..299] -expr 'a' -prefix rest_3dc.nii.gz
NodeBlockFunction: func_despike
- CPAC.func_preproc.func_preproc.func_despike(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate de-spiked functional timeseries in native space with AFNI.
NodeBlockFunction: func_despike_template
- CPAC.func_preproc.func_preproc.func_despike_template(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate de-spiked functional timeseries in template space with AFNI.
NodeBlockFunction: func_mask_normalize
- CPAC.func_preproc.func_preproc.func_mask_normalize(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Normalize a functional mask.
NodeBlockFunction: func_mean
- CPAC.func_preproc.func_preproc.func_mean(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Generate a mean functional image.
NodeBlockFunction: func_normalize
- CPAC.func_preproc.func_preproc.func_normalize(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Normalize a functional image.
NodeBlockFunction: func_reorient
- CPAC.func_preproc.func_preproc.func_reorient(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Reorient functional timeseries.
NodeBlockFunction: func_scaling
- CPAC.func_preproc.func_preproc.func_scaling(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Scale functional timeseries.
NodeBlockFunction: func_slice_time
- CPAC.func_preproc.func_preproc.func_slice_time(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Genetare slice-time correctied timeseries.
NodeBlockFunction: func_truncate
- CPAC.func_preproc.func_preproc.func_truncate(wf, cfg, strat_pool, pipe_num, opt=None)[source]¶
Truncate functional timeseries.
- CPAC.func_preproc.func_preproc.get_idx(in_files, stop_idx=None, start_idx=None)[source]¶
Get the first and the last slice for the functional run.
Verify the user specified first and last slice. If the values are not valid, calculate and return the very first and the last slice.
- Parameters:
in_file (
str (nifti file)
) – Path to input functional runstop_idx (
int
) – Last volume to be considered, specified by user in the configuration filestop_idx – First volume to be considered, specified by user in the configuration file
- Returns: