def distances_to_roi(network,inputc,roi):
"""
Returns a list of shortest path lengths from each
input-receiving cell to all measured cells.
Args:
network: networkx graph
inputc: MxN array, nonzero positions are treated as 'input receiving'
inputc: MxN array, nonzero positions are treated as 'measured'
"""
inputnodes = [tuple(ind) for ind in np.transpose(inputc.nonzero())]
roinodes = [tuple(ind) for ind in np.transpose(roi.nonzero())]
lengths = [nx.shortest_path_length(network,src,trg) for src in inputnodes for trg in roinodes]
return lengths
评论列表
文章目录