Skip to content

neurostatx.network.viz

Classes

NameDescription
NetworkLayoutNetworkX layout names used when placing graph nodes.

Functions

NameDescription
create_cmap_from_listMap per-subject values to node colors.
creating_node_colormapMap each node to a color from its highest percentile cluster.
membership_distributionWrite histograms of top membership values and their delta.

NetworkLayoutclass#

class NetworkLayout(StrEnum, Enum)

Bases: StrEnum, Enum

NetworkX layout names used when placing graph nodes.

KamadaKawaiattributeclass attributeinstance attribute#

KamadaKawai = ('kamada_kawai_layout')

Spectralattributeclass attributeinstance attribute#

Spectral = ('spectral_layout')

Springattributeclass attributeinstance attribute#

Spring = 'spring_layout'

create_cmap_from_listfunction#

def create_cmap_from_list(array)

Map per-subject values to node colors.

Integer zeros are drawn as "darkgrey"; other integers use tab10. Float arrays are ranked and mapped through plasma.

Parameters

NameTypeDescription
arraynp.arrayPer-subject values. Integers are treated as discrete conditions; floats are treated as a continuous scale.

Returns

nodes_cmaplist
Color for each subject.

Examples

>>> import numpy as np
>>> from neurostatx.network.viz import create_cmap_from_list
>>> colors = create_cmap_from_list(np.array([0, 1, 2]))
>>> colors[0]
'darkgrey'

creating_node_colormapfunction#

def creating_node_colormap(percentile_dict)

Map each node to a color from its highest percentile cluster.

Parameters

NameTypeDescription
percentile_dictdictMapping of cluster keys to per-node percentile arrays.

Returns

nodes_cmaplist
Color for each node. Nodes with a max of 0 are "black".

Examples

>>> from neurostatx.network.viz import creating_node_colormap
>>> colors = creating_node_colormap({"c1": [0, 1], "c2": [0, 0]})
>>> colors[0]
'black'

membership_distributionfunction#

def membership_distribution(mat, output='./membership_distribution.png')

Write histograms of top membership values and their delta.

Parameters

NameTypeDefaultDescription
matarrayrequiredFuzzy membership matrix with one row per subject.
outputstr'./membership_distribution.png'Output filename. Defaults to "./membership_distribution.png".

Examples

>>> import numpy as np
>>> from neurostatx.network.viz import membership_distribution
>>> mat = np.array([[0.8, 0.2], [0.3, 0.7]])
>>> membership_distribution(mat, output="membership.png")