Network Centrality#

CPAC.network_centrality.network_centrality.create_centrality_wf(wf_name: str, method_option: str, weight_options: list[str], threshold_option: str, threshold: float, num_threads: int | None = 1, memory_gb: float | None = 1.0, base_dir: Path | str | None = None) Workflow[source]#

Function to create the afni-based centrality workflow.

Parameters:
  • wf_name (string) – the name of the workflow

  • method_option (string) – one of [‘degree_centrality’, ‘eigenvector_centrality’, ‘local_functional_connectivity_density’]

  • weight_options (list) – one or more of [‘Binarized’, ‘Weighted’]

  • threshold_option (string) – one of [‘Significance threshold’, ‘Sparsity threshold’, ‘Correlation threshold’]

  • threshold (float) – the threshold value for thresholding the similarity matrix

  • num_threads (integer, optional) – the number of threads to utilize for centrality computation; default=1

  • memory_gb (float,optional) – the amount of memory the centrality calculation will take (GB); default=1.0

  • base_dir (path or str, optional) – the base directory for the workflow; default=None

Returns:

centrality_wf – the initialized nipype workflow for the afni centrality command

Return type:

nipype Workflow

Notes

Workflow Inputs:

inputspec.in_file : string
    path to input functional data NIfTI file

inputspec.template : string
    path to input mask template NIfTI file

inputspec.threshold : float
    threshold value for thresholding the similarity matrix

Workflow Outputs:

outputspec.outfile_list : list of strings
    list of paths to output files (binarized and weighted)
CPAC.network_centrality.pipeline.connect_centrality_workflow(workflow, c, resample_functional_to_template, template_node, template_out, merge_node, method_option, pipe_num)[source]#

High Level Workflow Graph:

images/generated/network_centrality.png

Detailed Workflow Graph:

images/generated/network_centrality_detailed.png

NodeBlockFunction: network_centrality

CPAC.network_centrality.pipeline.network_centrality(wf, cfg, strat_pool, pipe_num, opt=None)[source]#

Run Network Centrality.

Parameters:
Returns:

exception CPAC.network_centrality.utils.MethodOptionError(method_option)[source]#

Raised when a selected centrality method option is not supported.

__init__(method_option)[source]#
exception CPAC.network_centrality.utils.ThresholdError(threshold_option, threshold)[source]#

Raised when a selected threshold value is not supported for a selected threshold option.

__init__(threshold_option, threshold)[source]#
exception CPAC.network_centrality.utils.ThresholdOptionError(threshold_option, method_option=None)[source]#

Raised when a selected threshold option is not supported for a selected centrality measure.

__init__(threshold_option, method_option=None)[source]#
CPAC.network_centrality.utils.check_centrality_params(method_option, threshold_option, threshold)[source]#

Function to check the centrality parameters.

Parameters:
  • method_option (str or int) – one of [‘degree_centrality’, ‘eigenvector_centrality’, ‘local_functional_connectivity_density’] or index of option

  • threshold_option (str) – one of [‘Significance threshold’, ‘Sparsity threshold’, ‘Correlation threshold’] or index of option

  • threshold (float) –

Returns:

  • method_option (str) – one of [‘degree_centrality’, ‘eigenvector_centrality’, ‘local_functional_connectivity_density’]

  • threshold_option (str) – one of [‘Significance threshold’, ‘Sparsity threshold’, ‘Correlation threshold’]

CPAC.network_centrality.utils.convert_pvalue_to_r(datafile, p_value, two_tailed=False)[source]#

Method to calculate correlation threshold from p_value

Parameters:
  • datafile (string) – filepath to dataset to extract number of time pts from

  • p_value (float) – significance threshold p-value

  • two_tailed (boolean (optional); default=False) – flag to indicate whether to calculate the two-tailed t-test threshold for the returned correlation value

Returns:

r_value – correlation threshold value

Return type:

float

CPAC.network_centrality.utils.create_merge_node(pipe_num: int) Node[source]#

Create a Function Node to merge lists for the centrality workflow

Parameters:

pipe_num (int) –

Returns:

a Function Node to merge lists for the centrality workflow

Return type:

Node

Notes

Node Inputs:

deg_list : list of strings
    list of paths to degree centrality outputs

eig_list : list of strings
    list of paths to eigenvector centrality outputs

lfcd_list : list of strings
    list of paths to local functional connectivity density outputs

Node Outputs:

degree_weighted : string
    path to weighted degree centrality output

degree_binarized : string
    path to binarized degree centrality output

eigen_weighted : string
    path to weighted eigenvector centrality output

eigen_binarized : string
    path to binarized eigenvector centrality output

lfcd_weighted : string
    path to weighted local functional connectivity density output

lfcd_binarized : string
    path to binarized local functional connectivity density output
CPAC.network_centrality.utils.merge_lists(deg_list: list[str] | None = None, eig_list: list[str] | None = None, lfcd_list: list[str] | None = None)[source]#

Function to actually do the list merging.

Parameters:
  • deg_list (list of str, optional) – list of paths to degree centrality outputs

  • eig_list (list of str, optional) – list of paths to eigenvector centrality outputs

  • lfcd_list (list of str, optional) – list of paths to local functional connectivity density outputs

Returns:

  • degree_weighted (str) – path to weighted degree centrality output

  • degree_binarized (str) – path to binarized degree centrality output

  • eigen_weighted (str) – path to weighted eigenvector centrality output

  • eigen_binarized (str) – path to binarized eigenvector centrality output

  • lfcd_weighted (str) – path to weighted local functional connectivity density output

  • lfcd_binarized (str) – path to binarized local functional connectivity density output

CPAC.network_centrality.utils.sep_nifti_subbriks(nifti_file: Path | str, out_names: Iterable[str]) list[str][source]#

Separate sub-briks of niftis and save specified out

Parameters:
  • nifti_file (Path or str) – path to NIfTI output of an AFNI centrality tool

  • out_names (iterable of str) – an iterable of strings, each ending with one of (‘Binarized’, ‘Weighted’)

Returns:

paths to each of the specified outputs as its own file

Return type:

list of str