htfa.plot_network¶
- htfa.plot_network(nodes, connectivity=None, *, sizes=None, widths=None, subject='global', mesh='ch2', snap=True, mask=None, scale_by_mass=False, fade_by_mass=False, node_mode='auto', lobe_level=0.05, lobe_negative_color='teal', out=None, jpeg_quality=None, **style)[source]¶
Render nodes and thresholded edges BrainNet Viewer-style.
- Parameters:
- nodesHTFAResults, TFA, HTFA or array of shape (K, 3)
Node centers in MNI mm. For a fit, the centers of
subjectare used and its widths set the node sizes.- connectivityarray of shape (K, K), optional
Edge weights (upper triangle used).
Nonedraws nodes only.- sizesarray of shape (K,), optional
Node sizes; mapped linearly onto 2-7 mm radii (
node_radius; see theradius_*style options). Defaults to the (effective, withsnap) widths, or equal sizes (4 mm) when no widths are known.- widthsarray of shape (K,), optional
RBF widths of array
nodes(a fit’s own widths are used otherwise).- subject“global” or int
Which centers to use when
nodesis a fit.- meshstr, path, (vertices, faces) or None
Brain surface; see
load_mesh. Default"ch2".- snapbool
Draw each node as its in-brain part (
effective_nodes): the RBF-weighted centroid of the mask voxels, with widthlambda_eff. DefaultTrue;Falsedraws the fitted centers and widths as they are. The fit itself is never changed, andeffective_nodes(orhtfa.HTFAResults.display_nodes) returns the drawn values. Nodes without widths (a bare array withoutwidths) are points: they stay if inside the mask and otherwise move to the nearest mask voxel.- maskarray of shape (V, 3), NIfTI image or (volume, affine), optional
The in-brain voxels for
snap. Default: for an HTFAResults, the subject’s voxel coordinates (all subjects’ for"global"); otherwise nilearn’s 2 mm MNI152 brain mask (mni_mask), because the BrainNet meshes are in MNI space. RaisesImportErrorif that needs nilearn and nilearn cannot be installed.- scale_by_massbool
Multiply the node sizes by the in-mask RBF mass fraction before they are mapped to radii (needs widths and
snap).- fade_by_massbool or float
Node opacity
floor + (1 - floor) * mass_fractionwith floor 0.15 (True) or the given floor, so nodes mostly outside the brain stay faintly visible (needs widths andsnap).- node_mode{‘auto’, ‘components’, ‘summary’}
'auto'draws non-RBF kernels and mixtures as spatial component lobes; single RBFs retain the sphere view.'components'always draws lobes. Every component is an edge anchor: each factor edge is repeated, unchanged, between all pairs of its components and those of the other factor. No within-factor edges are added.'summary'draws one sphere per factor at its effective centroid.- lobe_levelfloat
Isosurface level as a fraction of the component’s unmasked peak (default 0.05); both positive and negative surfaces are drawn where they intersect
mask. Lobes use fitted spatial dimensions, not theradius_*scaling of summary spheres. Mixing weights control opacity (0.2 + 0.6 times the weight; negative shells use 35% of that opacity so the positive core remains visible), never the edge value.snapchanges edge anchors only; it does not move the component field.- lobe_negative_colorcolor
Color of negative component surfaces (default teal); positive surfaces use
node_color. This sign is spatial loading, distinct from positive/negative connectivity colors.- outpath, optional
Save the image there: PNG, or JPEG for a
.jpg/.jpegsuffix (qualityjpeg_quality, default 75, 4:2:0 chroma, like MATLAB’s export).- jpeg_qualityint, optional
If given, the image is JPEG-compressed at this quality before it is returned or saved. JPEG at 75 makes thin edges paler.
- **style
threshold(0.25; edges with|E| > thresholdare drawn),view("lateral"="left","right","dorsal","ventral","anterior","posterior"),size((1600, 1000) pixels),edge_style("intensity": diameter|E|mm at opacity 0.7;"flat": 0.5 mm, opaque),positive_color(“red”),negative_color(“blue”),node_color(0.502 gray),mesh_color(0.95 gray),mesh_opacity(0.2),background(“white”),radius_range((2, 7) mm: radii of the smallest and largest size),radius_kb(a fixed(k, b): radiusk * size + bmm, comparable across plots),radius_clip((min, max)mm applied to the radii); seenode_radius. See alsoconfig_style.
- Returns:
- PIL.Image.Image
The RGB image.