Functional Preprocessing#

Ingress#

CPAC.func_preproc.func_ingress.connect_func_ingress(workflow, strat_list, c, sub_dict, subject_id, input_creds_path, unique_id=None)[source]#

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.

Parameters:
Returns:

CPAC.func_preproc.func_motion.estimate_reference_image(in_file)[source]#

fMRIPrep-style BOLD reference Ref: https://github.com/nipreps/niworkflows/blob/maint/1.3.x/niworkflows/interfaces/registration.py#L446-L549

NodeBlockFunction: motion_correction

CPAC.func_preproc.func_motion.func_motion_correct(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

NodeBlockFunction: motion_correction_only

CPAC.func_preproc.func_motion.func_motion_correct_only(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

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.

Parameters:
Returns:

CPAC.func_preproc.func_motion.get_mcflirt_rms_abs(rms_files)[source]#

NodeBlockFunction: get_motion_ref

CPAC.func_preproc.func_motion.get_motion_ref(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

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.

Parameters:
Returns:

CPAC.func_preproc.func_motion.normalize_motion_parameters(in_file)[source]#

Convert FSL mcflirt motion parameters to AFNI space

Preprocessing#

Functional preprocessing

CPAC.func_preproc.func_preproc.anat_based_mask(wf_name='bold_mask')[source]#

reference DCAN lab BOLD mask

CPAC.func_preproc.func_preproc.anat_refined_mask(init_bold_mask=True, wf_name='init_bold_mask')[source]#

NodeBlockFunction: bold_mask_afni

CPAC.func_preproc.func_preproc.bold_mask_afni(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

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.

Parameters:
Returns:

NodeBlockFunction: bold_mask_anatomical_refined

CPAC.func_preproc.func_preproc.bold_mask_anatomical_refined(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

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 in standard space to get BOLD brain mask in standard space

Adapted from DCAN Lab’s BOLD mask method from the ABCD pipeline.

Parameters:
Returns:

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.

Parameters:
Returns:

NodeBlockFunction: bold_mask_fsl

CPAC.func_preproc.func_preproc.bold_mask_fsl(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

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

Ref

Parameters:
Returns:

NodeBlockFunction: bold_masking

CPAC.func_preproc.func_preproc.bold_masking(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

CPAC.func_preproc.func_preproc.collect_arguments(*args)[source]#
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
Parameters:
  • scaling_factor (float) – Scale the size of the dataset voxels by the factor.

  • wf_name (str) – name of the workflow

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]#
Parameters:
Returns:

NodeBlockFunction: func_despike_template

CPAC.func_preproc.func_preproc.func_despike_template(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

NodeBlockFunction: func_mask_normalize

CPAC.func_preproc.func_preproc.func_mask_normalize(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

NodeBlockFunction: func_mean

CPAC.func_preproc.func_preproc.func_mean(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

NodeBlockFunction: func_normalize

CPAC.func_preproc.func_preproc.func_normalize(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

NodeBlockFunction: func_reorient

CPAC.func_preproc.func_preproc.func_reorient(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

NodeBlockFunction: func_scaling

CPAC.func_preproc.func_preproc.func_scaling(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

NodeBlockFunction: func_slice_time

CPAC.func_preproc.func_preproc.func_slice_time(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

NodeBlockFunction: func_truncate

CPAC.func_preproc.func_preproc.func_truncate(wf, cfg, strat_pool, pipe_num, opt=None)[source]#
Parameters:
Returns:

CPAC.func_preproc.func_preproc.get_idx(in_files, stop_idx=None, start_idx=None)[source]#

Method to get the first and the last slice for the functional run. It verifies the user specified first and last slice. If the values are not valid, it calculates and returns the very first and the last slice

Parameters:
  • in_file (str (nifti file)) – Path to input functional run

  • stop_idx (int) – Last volume to be considered, specified by user in the configuration file

  • stop_idx – First volume to be considered, specified by user in the configuration file

Returns:

  • stop_idx (int) – Value of first slice to consider for the functional run

  • start_idx (int) – Value of last slice to consider for the functional run

CPAC.func_preproc.func_preproc.slice_timing_wf(name='slice_timing', tpattern=None, tzero=None)[source]#

Utilities#

CPAC.func_preproc.utils.chunk_ts(func_file, n_chunks=None, chunk_size=None)[source]#
CPAC.func_preproc.utils.degrees_to_mm(degrees, head_radius)[source]#
CPAC.func_preproc.utils.mm_to_degrees(mm, head_radius)[source]#
CPAC.func_preproc.utils.notch_filter_motion(motion_params, filter_type, TR, fc_RR_min=None, fc_RR_max=None, center_freq=None, freq_bw=None, lowpass_cutoff=None, filter_order=4)[source]#
CPAC.func_preproc.utils.nullify(value, function=None)[source]#
CPAC.func_preproc.utils.oned_text_concat(in_files)[source]#
CPAC.func_preproc.utils.split_ts_chunks(func_file, tr_ranges)[source]#