frites.conn.conn_reshape_undirected#

frites.conn.conn_reshape_undirected(da, 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 undirected array of connectivity.

This function reshapes a DataArray of connectivity values into a symmetric matrix. For example, a DataArray of shape (n_pairs,) where n_pairs reflects pairs of roi (e.g ‘roi_1-roi_2’) is going to be reshaped into a symmetric DataArray of shape (n_roi, n_roi). Similarly, a DataArray of shape (n_pairs, n_times) is going to be reshaped into a symmetric DataArray of shape (n_roi, n_roi, n_times).

Parameters
daxarray.DataArray

Flatten DataArray of connectivity values to be reshaped

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

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, n_times)

See also

conn_dfc

Examples using frites.conn.conn_reshape_undirected#

Estimate the covariance-based Granger Causality

Estimate the covariance-based Granger Causality