Skip to content

Commit c0b4ce8

Browse files
committed
added weight option for struct consensus
1 parent c907953 commit c0b4ce8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

netneurotools/networks.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _ecdf(data):
138138
return prob, quantiles
139139

140140

141-
def struct_consensus(data, distance, hemiid):
141+
def struct_consensus(data, distance, hemiid, weighted=False):
142142
"""
143143
Calculates distance-dependent group consensus structural connectivity graph
144144
@@ -178,11 +178,14 @@ def struct_consensus(data, distance, hemiid):
178178
hemiid : (N, 1) array_like
179179
Hemisphere designation for `N` nodes where a value of 0/1 indicates
180180
node `N_{i}` is in the right/left hemisphere, respectively
181+
weighted : bool
182+
Flag indicating whether or not to return a weighted consensus map. If
183+
`True`, the consensus will be multiplied by the mean of `data`.
181184
182185
Returns
183186
-------
184187
consensus : (N, N) numpy.ndarray
185-
Binary, group-level connectivity matrix
188+
Binary (default) or mean-weighted group-level connectivity matrix
186189
187190
References
188191
----------
@@ -272,6 +275,8 @@ def struct_consensus(data, distance, hemiid):
272275
consensus = consensus.sum(axis=2)
273276
consensus = np.logical_or(consensus, consensus.T).astype(int)
274277

278+
if weighted:
279+
consensus = consensus * np.mean(data, axis=2)
275280
return consensus
276281

277282

0 commit comments

Comments
 (0)