nws_tools.
thresh_nws
(nws, userdens=None, percval=0.0, force_den=False, span_tree=False)[source]¶Threshold networks based on connection density
Parameters: | nws : NumPy 3darray
userdens : int
percval : float
force_den : bool
span_tree : bool
|
---|---|
Returns: | Dictionary holding computed quantities. The fields of the dictionary depend upon the values of the optional keyword arguments userdens and span_tree. res : dict
|
See also
get_meannw
backbone_wu
Notes
This routine uses either a relative thresholding strategy or a maximum spanning tree approach to decrease the density of a given set of input networks.
During relative thresholding (span_tree = False) edges are discarded based on their value relative to the maximum edge weight found across all networks beginning with the weakest links. By default, the thresholding algorithm uses the lowest common connection density across all input networks before a node is disconnected as target edge density. That means, if networks A, B and C can be thresholded down to 40%, 50% and 60% density, respectively, without disconnecting any nodes, then the lowest common density for thresholding A, B and C together is 60%. In this case the raw network A already has a density of 60% or lower, which is thus excluded from thresholding and the original network is copied into th_nws. If a density level is provided by the user, then the code tries to use it unless it violates connectedness of all thresholded networks - in this case the lowest common density of all networks is used, unless force_den = True which causes the code to employ the user-provided density level for thresholding, disconnecting nodes from the networks in the process.
The maximum spanning tree approach (span_tree = True) can be interpreted as the inverse of relative thresholding. Instead of chipping away weak edges in the input networks until a target density is met (or nodes disconnect), a minimal backbone of the network is calculated and then populated with the strongest connections found in the original network until a desired edge density level is reached. The backbone of the network is calculated by computing the graph’s maximum spanning tree, that connects all nodes with the minimum number of maximum-weight edges. Note, that unless each edge has a distinct unique weight value a graph has numerous different maximum spanning trees. Thus, the spanning trees computed by this routine are usually not unique, and consequently the thresholded networks may not be unique either (particularly for low density levels, for which the computed populated networks are very similar to the underlying spanning trees). Thus, in contrast to the more common relative thresholding strategy, this bottom-up approach allows to reduce a given network’s density to an almost arbitrary level (>= density of the maximum spanning tree) without disconnecting nodes. However, unlike relative thresholding, the computed sparse networks are not necessarily unique and strongly depend on the intial maximum spanning tree. Note that if userdens is None, only maximum spanning trees will be computed.
The code below relies on the routine get_meannw in this module to compute the group-averaged network. Futher, maximum spanning trees are calculated using backbone_wu.m from the Brain Connectivity Toolbox (BCT) for MATLAB via Octave. Thus, it requires Octave to be installed with the BCT in its search path. Further, oct2py is needed to launch an Octave instance from within Python.