Multivariate Distance Matrix Regression (MDMR)

CPAC.cwas.create_cwas(name='cwas', working_dir=None, crash_dir=None)[source]

Connectome Wide Association Studies

This workflow performs CWAS on a group of subjects.


name (string, optional) – Name of the workflow.


cwas – CWAS workflow.

Return type:



Workflow Inputs:

inputspec.subjects : dict (subject id: nifti files)
    4-D timeseries of a group of subjects normalized to MNI space
inputspec.roi : string (nifti file)
    Mask of region(s) of interest
inputspec.regressor : list (float)
    Corresponding list of the regressor variable of shape (`N`) or (`N`,`1`), `N` subjects
inputspec.cols : list (int)
inputspec.f_samples : int
    Number of permutation samples to draw from the pseudo F distribution
inputspec.parallel_nodes : integer
    Number of nodes to create and potentially parallelize over

Workflow Outputs:

outputspec.F_map : string (nifti file)
    Pseudo F values of CWAS
outputspec.p_map : string (nifti file)
    Significance p values calculated from permutation tests
outputspec.z_map : string (nifti file)
    Significance p values converted to z-scores

CWAS Procedure:

  1. Calculate spatial correlation of a voxel

  2. Correlate spatial z-score maps for every subject pair

  3. Convert matrix to distance matrix, 1-r

  4. Calculate MDMR statistics for the voxel

  5. Determine significance of MDMR statistics with permutation tests

Workflow Graph:


Detailed Workflow Graph:



CPAC.cwas.joint_mask(subjects, mask_file=None)[source]

Creates a joint mask (intersection) common to all the subjects in a provided list and a provided mask

  • subjects (dict of strings) – A length N list of file paths of the nifti files of subjects

  • mask_file (string) – Path to a mask file in nifti format


joint_mask – Path to joint mask file in nifti format

Return type:


CPAC.cwas.nifti_cwas(subjects, mask_file, regressor_file, participant_column, columns_string, permutations, voxel_range)[source]

Performs CWAS for a group of subjects

  • subjects (dict of strings:strings) – A length N dict of id and file paths of the nifti files of subjects

  • mask_file (string) – Path to a mask file in nifti format

  • regressor_file (string) – file path to regressor CSV or TSV file (phenotypic info)

  • columns_string (string) – comma-separated string of regressor labels

  • permutations (integer) – Number of pseudo f values to sample using a random permutation test

  • voxel_range (ndarray) – Indexes from range of voxels (inside the mask) to perform cwas on. Index ordering is based on the np.where(mask) command


  • F_file (string) – .npy file of pseudo-F statistic calculated for every voxel

  • p_file (string) – .npy file of significance probabilities of pseudo-F values

  • voxel_range (tuple) – Passed on by the voxel_range provided in parameters, used to make parallelization easier