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
- da
xarray.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’
- sep
python:str
| ‘-’ Separator used to separate the pairs of roi names.
- order
python:list
|python:None
List of roi names to reorder the output.
- axis
python: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_value
python:float
|numpy.nan
Value to use for filling missing pairs (e.g diagonal)
- fill_diagonal
python: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.
- da
- Returns
- da_out
xarray.DataArray
DataArray of shape (n_roi, n_roi)
- da_out
See also
Examples using frites.conn.conn_reshape_directed
#
Estimate the covariance-based Granger Causality