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
- da
xarray.DataArray
Flatten DataArray of connectivity values to be reshaped
- 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
- 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, n_times)
- da_out
See also
Examples using frites.conn.conn_reshape_undirected
#
Estimate the covariance-based Granger Causality