xcp_d.interfaces.connectivity module

Handling functional connectivity.

class xcp_d.interfaces.connectivity.CiftiMask(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Mask a CIFTI file by replacing masked values with NaNs.

I (TS) created this interface because I couldn’t find a way to do this with wb_command -cifti-math.

Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – CIFTI file to mask.

  • mask (a pathlike object or string representing an existing file) – Mask pscalar or dscalar to apply to in_file.

Outputs:

out_file (a pathlike object or string representing an existing file) – Masked CIFTI file.

class xcp_d.interfaces.connectivity.CiftiToTSV(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Extract data from a parcellated CIFTI file into a TSV file.

Mandatory Inputs:
  • atlas_labels (a pathlike object or string representing an existing file) – Atlas labels file.

  • in_file (a pathlike object or string representing an existing file) – Parcellated CIFTI file to extract into a TSV.

Outputs:

out_file (a pathlike object or string representing an existing file) – Parcellated data TSV file.

class xcp_d.interfaces.connectivity.CiftiVertexMask(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Create a vertex-wise mask.

Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – CIFTI file to mask.

Outputs:

mask_file (a pathlike object or string representing an existing file) – CIFTI mask.

class xcp_d.interfaces.connectivity.ConnectPlot(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Extract timeseries and compute connectivity matrices.

Mandatory Inputs:
  • atlas_tsvs (a list of items which are a string) – The dseg.tsv associated with each atlas.

  • atlases (a list of items which are a string) – List of atlases. Aligned with the list of time series in time_series_tsv.

  • correlations_tsv (a list of items which are a pathlike object or string representing an existing file) – List of TSV file with correlation matrices. Aligned with the list of atlases in ‘atlases’.

Outputs:

connectplot (a pathlike object or string representing an existing file) – Path to SVG file with four correlation heat maps.

plot_matrix(corr_mat, network_labels, ax)[source]

Plot matrix in subplot Axes.

class xcp_d.interfaces.connectivity.NiftiParcellate(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Extract timeseries and compute connectivity matrices.

Write out time series using Nilearn’s NiftiLabelMasker Then write out functional correlation matrix of timeseries using numpy.

Mandatory Inputs:
  • atlas (a pathlike object or string representing an existing file) – Atlas file.

  • atlas_labels (a pathlike object or string representing an existing file) – Atlas labels file.

  • filtered_file (a pathlike object or string representing an existing file) – Filtered file.

  • mask (a pathlike object or string representing an existing file) – Brain mask file.

Optional Inputs:

min_coverage (a float) – Coverage threshold to apply to parcels. Any parcels with lower coverage than the threshold will be replaced with NaNs. Must be a value between zero and one. Default is 0.5. (Nipype default value: 0.5)

Outputs:
  • coverage (a pathlike object or string representing an existing file) – Parcel-wise coverage file.

  • timeseries (a pathlike object or string representing an existing file) – Parcellated time series file.

class xcp_d.interfaces.connectivity.TSVConnect(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Extract timeseries and compute connectivity matrices.

Write out time series using Nilearn’s NiftiLabelMasker Then write out functional correlation matrix of timeseries using numpy.

Optional Inputs:
  • temporal_mask (a pathlike object or string representing an existing file) – Temporal mask, after dummy scan removal.

  • timeseries (a pathlike object or string representing an existing file) – Parcellated time series TSV file.

Outputs:
  • correlations (a pathlike object or string representing an existing file) – Correlation matrix file.

  • correlations_exact (a list of items which are a pathlike object or string representing an existing file or None) – Correlation matrix files limited to an exact number of volumes.

xcp_d.interfaces.connectivity.correlate_timeseries(timeseries, temporal_mask)[source]

Correlate timeseries stored in a TSV file.