def get_by_graphs_instantiated_features(graphs, features): # Needs to be imported locally to avoid circular dependencies from catmaid.control.classification import graphs_instanciate_features matrix = np.zeros((len(graphs),len(features)), dtype=np.int) graphs_instanciate_features(graphs, features, matrix) # Find features that are instantiated used_features = set() for ng,g in enumerate(graphs): for nf,f in enumerate(features): if 1 == matrix[ng][nf]: used_features.add(f) return list(used_features)
def create_binary_matrix(graphs, features): """ Creates a binary matrix for the graphs passed.""" matrix = np.zeros((len(graphs),len(features)), dtype=np.int) return graphs_instanciate_features(graphs, features, matrix)
def create_binary_matrix(graphs, features): """ Creates a binary matrix for the graphs passed.""" matrix = np.zeros((len(graphs), len(features)), dtype=np.int) return graphs_instanciate_features(graphs, features, matrix)