frites.conn.conn_reshape_directed#

frites.conn.conn_reshape_directed(da, net=False, sep='-', order=None, axis='roi', rm_missing=False, fill_value=nan, fill_diagonal=None, to_dataframe=False, inplace=False, verbose=None)[source]#

Reshape a raveled directed array of connectivity.

This function takes a DataArray of shape (n_pairs, n_directions) or where n_pairs reflects pairs of roi (e.g ‘roi_1-roi_2’) and n_direction usually contains bidirected ‘x->y’ and ‘y->x’. At the end, this function reshape the input array so that rows contains the sources and columns the targets leading to a non-symmetric DataArray of shape (n_roi, n_roi). A typical use case for this function would be after computing the covariance based granger causality.

Parameters
daxarray.DataArray

Xarray DataArray of shape (n_pairs, n_directions) where actually the roi dimension contains the pairs (roi_1-roi_2, roi_1-roi_3 etc.). The dimension n_directions should contains the dimensions ‘x->y’ and ‘y->x’

seppython:str | ‘-’

Separator used to separate the pairs of roi names.

orderpython:list | python:None

List of roi names to reorder the output.

axispython:str | ‘roi’

Name of the spatial dimension to use for reshaping

rm_missingbool | python:False

When reordering the connectivity array, choose if you prefer to reindex even if there’s missing regions (rm_missing=False) or if missing regions should be removed (rm_missing=True)

fill_valuepython:float | numpy.nan

Value to use for filling missing pairs (e.g diagonal)

fill_diagonalpython:float | python:None

Value to use in order to fill the diagonal. If None, the diagonal is untouched

to_dataframebool | python:False

Dataframe conversion. Only possible if the da input does not contains a time axis.

Returns
da_outxarray.DataArray

DataArray of shape (n_roi, n_roi)

See also

conn_covgc

Examples using frites.conn.conn_reshape_directed#

Estimate the covariance-based Granger Causality

Estimate the covariance-based Granger Causality