Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a8bd78b
Issue #188: design for network plot and animation features
jeremymanning Nov 22, 2026
06a4750
Issue #188: implementation plan for network plot and animation features
jeremymanning Nov 22, 2026
8d3a641
Issue #188: public content_box crop helper
jeremymanning Nov 22, 2026
f9e2ea6
Issue #188: content_box accepts any sequence, validates margin and em…
jeremymanning Nov 22, 2026
a46ed90
Issue #188: crf and faststart options in write_animation
jeremymanning Nov 22, 2026
de0ab01
Issue #188: per-node colors, replaceable node spheres and supersample…
jeremymanning Nov 22, 2026
32c1e07
Issue #188: test write_animation default against the 0.1.0 writer; te…
jeremymanning Nov 22, 2026
3bd5f87
Issue #188: set_nodes rejects non-finite radii before changing the sc…
jeremymanning Nov 22, 2026
5ff4b74
Issue #188: per-frame sizes and colors in animate_network; connectivi…
jeremymanning Nov 22, 2026
067fecf
Issue #188: views, legend and frame_size in plot_network and animate_…
jeremymanning Nov 22, 2026
e56fe08
Issue #188: reject empty time axes in animate_network; stronger mass,…
jeremymanning Nov 22, 2026
4f50082
Issue #188: annotate_pair keeps its header for empty titles; edge-fre…
jeremymanning Nov 22, 2026
0f425e7
Issue #188: natural-width frames widen to hold the widest legend row;…
jeremymanning Nov 22, 2026
fcd9abc
Issue #188: compose= callable on animate_network replaces the layout …
jeremymanning Nov 22, 2026
3f4e0a2
Issue #188: n_jobs parallel frame rendering with blank-render restart…
jeremymanning Nov 22, 2026
b7a7d57
Issue #188: test the blank-render restart with a real over-black render
jeremymanning Nov 22, 2026
dbfae72
Issue #188: compose must be callable; compose and frame-size errors n…
jeremymanning Nov 22, 2026
1860099
Issue #188: blank-render rule needs a black corner; frame-folder clea…
jeremymanning Nov 22, 2026
69f3cd3
Issue #188: version 0.2.0, docstrings for the new arguments, changelo…
jeremymanning Nov 22, 2026
8b45463
Issue #188: a frame-folder cleanup failure during a rendering error j…
jeremymanning Nov 22, 2026
d254a40
Issue #188: plot_network sizes docs match the code; changelog notes s…
jeremymanning Nov 22, 2026
1eb327a
Issue #188: tutorials 10 and 11 show per-node and per-window colors a…
jeremymanning Nov 22, 2026
6539e50
Issue #188: tutorial 10 says the joint radius scaling covers the wind…
jeremymanning Nov 22, 2026
eed0a6b
Issue #188: on macOS, scenes release their render windows through a C…
jeremymanning Nov 22, 2026
2b820f5
Issue #188: tutorials 10 and 11 write their temporary files to a Temp…
jeremymanning Nov 22, 2026
ccc2ca8
Issue #188: tutorial 10's compose section says "window center"
jeremymanning Nov 22, 2026
5adf645
Issue #188: a wrong number of sizes in plot_network names (K,) only; …
jeremymanning Nov 22, 2026
ee27403
Issue #188: the n_jobs docstring states the measured start-up cost, t…
jeremymanning Nov 22, 2026
7ab2387
Issue #188: test_fitted_count_and_scoring asserts the ConvergenceWarn…
jeremymanning Nov 22, 2026
64ea99d
Issue #188: the Cocoa autorelease pool is scoped to the call that bui…
jeremymanning Nov 22, 2026
390d6e1
Issue #188: content_box, annotate_pair and montage on a white backgro…
jeremymanning Nov 22, 2026
50aa26c
Issue #188: a movie's crop comes from opaque nodes in one contrasting…
jeremymanning Nov 22, 2026
0cb0496
Issue #188: any positive frame_size is kept exactly; only an mp4 reje…
jeremymanning Nov 22, 2026
e126361
Issue #188: only a dead worker or a blank render restarts the pool; w…
jeremymanning Nov 22, 2026
78ddae2
Issue #188: tests check each spinning panel, legend mark shapes, colo…
jeremymanning Nov 22, 2026
0e6c82a
Issue #188: document that legend and title fonts follow the frame_siz…
jeremymanning Nov 22, 2026
c3da7bf
Issue #188: tutorial 10 re-executed; its layout movie changes by a fe…
jeremymanning Nov 22, 2026
e409e0e
Issue #188: reflow the two amended spec paragraphs
jeremymanning Nov 22, 2026
667fa9f
Issue #188: the pool-class test follows the installed VTK; the failin…
jeremymanning Nov 22, 2026
f42aa68
Issue #188: session notes for the network-plot work
jeremymanning Nov 22, 2026
93e465f
Issue #188: color nodes and edges by point, not cell, rgb scalars
jeremymanning Nov 22, 2026
1dfaff0
Issue #188: worker-pool scenarios check liveness and log records corr…
jeremymanning Nov 22, 2026
2a208d8
Issue #188: test_fitted_count_and_scoring allows numpy 2.2.6's spurio…
jeremymanning Nov 22, 2026
59a1e15
Issue #188: changelog names the per-point color change; notes on the …
jeremymanning Nov 22, 2026
a97b137
Issue #188: test records are written whole or not at all, so a termin…
jeremymanning Nov 22, 2026
fd55f59
Issue #188: tutorial 10's new movies render 15 frames at 320 x 200 pe…
jeremymanning Nov 22, 2026
42846c2
Issue #188: notes on CI round 3 and the candidate workflow's time limit
jeremymanning Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,41 @@ Use `groups=False` to ignore folder-derived grouping, or pass explicit `groups`
to define the experimental hierarchy yourself. Each file remains one subject;
repeated runs from one person are not independent subjects.

With the `brain3d` extra, `htfa.plot_network` and `htfa.animate_network` draw nodes in MNI coordinates (mm) and edges above a threshold. This example draws four nodes with one color each, two views, a legend and an exact frame size, then an mp4 with per-frame node sizes drawn by two worker processes:

```python
import numpy as np
import htfa

rng = np.random.default_rng(0)
centers = np.array([[-40, -20, 10], [40, -20, 10], [0, 40, 20], [0, -60, 30]], float)
E = rng.uniform(-1, 1, (6, 4, 4)) # six windows of 4 x 4 connectivity
E = (E + E.transpose(0, 2, 1)) / 2
legend = [("red", "positive", "line"), ("blue", "negative", "line")]

img = htfa.plot_network(
centers,
E[0],
node_color=["red", "green", "blue", "gray"],
views=["left", "right"],
legend=legend,
frame_size=(640, 400),
size=(320, 200),
)
htfa.animate_network(
centers,
E,
"network.mp4",
sizes=rng.uniform(1, 5, (6, 4)),
views=["left", "right"],
legend=legend,
frame_size=(640, 400),
size=(320, 200),
n_jobs=2,
crf=18,
)
```

The inputs `htfa.fit` accepts, its parameters and the results object are described in the [documentation](https://htfa.readthedocs.io/en/latest/) and in [docs/API.md](https://github.com/ContextLab/htfa/blob/main/docs/API.md).

## Installation
Expand Down
Binary file added docs/_static/tutorials/10_isfc_nodes.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ anchors but does not move or resize the spatial fields.

htfa.plot_network
htfa.animate_network
htfa.content_box
htfa.plot_timecourse
htfa.brainnet.read_node
htfa.brainnet.write_node
Expand Down
47 changes: 47 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
Release overview
================

0.2.0
-----

0.2.0 adds options to the BrainNet Viewer-style network plots and animations in
``htfa.brainnet``. Existing calls are unchanged: a call that passes none of the
new arguments takes the 0.1.0 code path and gives the same images.

Network plots and animations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``node_color`` accepts one color per node: a sequence of K color specs, or an
array of shape (K, 3) or (K, 4). In :func:`htfa.animate_network` it also
accepts per-frame colors, (T, K) color specs or an array of shape (T, K, 3)
or (T, K, 4); each frame uses the colors of the nearest window. A flat
sequence of 3 or 4 numbers is still one color.
- :func:`htfa.animate_network` accepts ``sizes`` of shape (T, K). Radii are
scaled jointly over all frames and follow ``interpolation`` between windows.
``connectivity=None`` draws no edges when ``sizes`` or ``node_color`` has a
time axis. In :meth:`htfa.HTFAResults.animate_network`, ``connectivity=None``
still computes ISFC.
- ``views`` draws several views side by side, ``legend`` adds rows of colored
dots and lines with labels, and ``frame_size`` sets the exact frame size.
One crop box serves every view and frame; with ``spin`` the views are not
cropped. Passing any of the three selects the layout path. A call that uses
none of the new options gives the same output as in 0.1.0.
- :func:`htfa.animate_network` accepts ``compose``, a callable
``compose(images, t)`` that builds each frame from the per-view images, and
``n_jobs``, which draws frames in worker processes. With ``n_jobs`` other
than 1, a blank (black) render or a dead worker restarts the pool, up to 5
times.
- ``crf`` and ``faststart`` set the x264 constant rate factor and move the mp4
index to the start of the file, in :func:`htfa.animate_network` and
:func:`htfa.brainnet.write_animation`. With ``crf=None`` the encoding is as
in 0.1.0.
- The style key ``supersample`` sets the rendering multiple used for
anti-aliasing (default 2).
- :func:`htfa.content_box` returns the bounding box of the non-background
content of one or more images.
- On macOS, network plots and animations release their closed render windows.
In 0.1.0 each render kept its window in memory (5 to 9 MB per render with
the ch2 mesh), and after about 40 renders in one process macOS printed
"Context leak detected". This uses VTK's ``vtkCocoaAutoreleasePool`` (VTK
9.5 and later); with an older VTK, rendering runs as in 0.1.0.
- Edges and per-node colors are stored as per-point instead of per-cell
colors. With Mesa 26's software renderer (Ubuntu 26.04), 0.1.0 drew no
edges at all, because actors colored by cell data were not drawn there.

0.1.0
-----

Expand Down
Loading
Loading