utils
construct_attributes_dict(df, labels, id_column)
Function to construct a dictionary of nodes’ attributes from a DataFrame.
Parameters
df : Pandas DataFrame containing nodes’ attributes.
labels : List of labels to add as nodes’ attributes.
id_column : Name of the column containing the subject’s ID tag.
Returns
attributes_dict : Dictionary of nodes’ attributes.
extract_subject_percentile(mat, percentile)
Function to extract subjects that are above the Xth percentile.
Parameters
mat : Fuzzy C-partitioned membership matrix.
percentile : Percentile value.
Returns
label_dict : Dictionary of binary arrays for each clusters.
fetch_attributes_df(G, attributes=None)
Function to fetch nodes’ attributes from a graph as a DataFrame.
Parameters
G : NetworkX Graph object.
attributes : List of attributes to fetch.
Returns
DataFrame : Pandas DataFrame containing nodes’ attributes.
fetch_edge_data(G, weight=‘membership’)
Function to fetch edge’s data from a graph as a DataFrame. This method works only if the graph as been created via this package.
Parameters
G : NetworkX Graph object.
weight : Name of the column containing the edge weight. Default is ‘membership’.
Returns
DataFrame : Pandas DataFrame containing edges’ data.
filter_node_centroids(n)
Function to filter cluster nodes from subject’s nodes.
Parameters
n : Node label.
Returns
bool : True or False
filter_node_subjects(n)
Function to filter subject nodes from cluster’s nodes.
Parameters
n : Node label.
Returns
bool : True or False
get_nodes_and_edges(df)
Function to generate a dataframe containing edges’ data.
Parameters
df : Pandas DataFrame containing edges data and ids (membership matrix from clustering results).
Returns
DataFrame : Pandas DataFrame of starting node, target node and edge weights.