You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use bct.randomize_graph_partial_und to shuffle my connectivity matrix while keeping the diagonal untouched. However, the algorithm does not seems to converge (?). Instead, I wrote my own function that does this job. Did I do something wrong?
# -*- coding: utf-8 -*-"""Created on Thu Jul 29 14:30:02 2021@author: Johannes.Wiesner"""importnumpyasnpimportbct# initialize inputsnp.random.seed(42)
A=np.random.rand(5,5)
np.fill_diagonal(A,0, wrap=False)
B=np.eye(5,dtype=bool)
defshuffle_array(A):
A_copy=A.copy()
m=~np.eye(len(A), dtype=bool) # mask of non-diagonal elements# Extract non-diagonal elements as a new array and shuffle in-placeAm=A[m]
np.random.shuffle(Am)
# Assign back the shuffled values into non-diag positions of inputA_copy[m] =AmreturnA_copyA_shuffled=shuffle_array(A)
# this does not work# A_shuffled_bct = bct.randomize_graph_partial_und(A,B,maxswap=2)
The text was updated successfully, but these errors were encountered:
I wanted to use
bct.randomize_graph_partial_und
to shuffle my connectivity matrix while keeping the diagonal untouched. However, the algorithm does not seems to converge (?). Instead, I wrote my own function that does this job. Did I do something wrong?The text was updated successfully, but these errors were encountered: