Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
{'bbox_inches': None}` (the same 600 x 450 picture as the PNG they wrote
to a buffer before).
- `htfa_network_animations`, `stocks` and `trajectories` load their data
with `tc.datasets`, write their videos with `tc.render_video` (frames in
a temporary folder; before: under `$TIMECORR_DATA`) into `tc.media_dir()`
and show them with `tc.show_video`. `stocks` keeps the two `Siccodes`
with `tc.datasets`, write their videos into `tc.media_dir()` and show
them with `tc.show_video`; `stocks` draws its frames with
`tc.render_video` (frames in a temporary folder; before: under
`$TIMECORR_DATA`). `stocks` keeps the two `Siccodes`
text files of the library in the cache (before: their zip archives).
- `htfa_network_animations` and `stocks` read the communities from the
`"labels"` of `return_info` and no longer run `tc.features` a second
Expand All @@ -94,6 +95,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
header. Without one the documentation server answered HTTP 403, so the
notebook reported that no full-quality video was online.

- Tutorials on the toolboxes' own animation calls (the `tutorials` extra now
needs `htfa[plot,brain3d]>=0.2.0` and `hypertools>=1.2`):
`htfa_network_animations.ipynb` draws each video with one
`htfa.animate_network` call (per-node colors, per-frame radii, two views,
caption, legend rows, parallel frames; x264's preset `slow`) in place of
its own scene, frame composition and retry code, and its stills with
`plot_network(..., views=, legend=, caption=)`; the layout of the videos is
that of the earlier ones (brains and legend rows within 5 pixels).
`trajectories.ipynb` draws each video with one
`hyp.plot(..., panels=..., animate=True)` call; the videos show the line up
to the current sample faint and the last 30 samples solid, without the head
marker, the thicker tail and the one-second hold of the earlier videos, and
the notebook no longer filters hypertools' messages (fixed in hypertools
1.2).
- Tutorial `docs/tutorial/trajectories.ipynb`: the trajectories are drawn in
hypertools' own cubes with `hyp.plot(..., panels=...)`, after reducing each
order to three dimensions with `hyp.reduce` and rescaling each component to
Expand Down
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ The estimator (`wcorr`) is a kernel-weighted Pearson correlation; a true delta k
- Sphinx with numpydoc, autosummary and nbsphinx; source in `docs/`; theme: Furo with the Contextual Dynamics Lab look shared with the htfa and hypertools documentation (Nunito Sans, lowercase light headings, green brand colors set in `html_theme_options` in `docs/conf.py`, rules in `docs/_static/custom.css`)
- API pages: `docs/api.rst` (autosummary stubs in `docs/generated/`)
- Gallery: the tutorials are the gallery. `docs/tutorials.rst` holds an nbsphinx `nbgallery` of the notebooks in `docs/tutorial/` (quickstart first); each card shows the image output of the notebook's one code cell tagged `nbsphinx-thumbnail` (a 4:3 picture without text, drawn from the notebook's own data by a cell near its end, after a one-line caption) and opens the notebook (card styles in `docs/_static/custom.css`, light and dark). `tests/test_docs_tutorials.py` checks that the gallery and the notebooks match, the thumbnail cell, the Colab badge, no error outputs, that relative links name tutorial notebooks (links to other doc pages are absolute `https://timecorr.readthedocs.io/en/latest/...` URLs, which also work on Colab), and that every public name is used (as `tc.<name>`, imported or called; comments and strings do not count) in a tutorial's code cell
- Tutorial notebooks: `docs/tutorial/` (`quickstart`, `kernels`, `subjects`, `reduce`, `simulate`, `higher_order`, `events`, `decoding`, `htfa_network_animations`, `stocks`, `trajectories`; rendered without execution; execute them with nbconvert (needs jupyter) before committing, except the three real-data notebooks, which take minutes to tens of minutes and download data). Each starts with a Colab badge and a title cell; its first code cell installs, on Google Colab only, what the notebook imports: `timecorr` (`timecorr[segment]` for `events`, plus named packages such as polars where imported; the real-data notebooks install `timecorr[tutorials]` and `bottleneck>=1.5`, since pandas 3 warns about Colab's older bottleneck), with one shell line, `!pip install -q "timecorr>=0.3.1" ... || pip install -q "timecorr @ git+https://github.com/ContextLab/timecorr.git@master" ...`: release 0.3.1 or later (the first with the helpers the notebooks call) from PyPI, or git master when pip cannot install that (the cell prints nothing of its own; pip's error about PyPI shows before the fallback), and every notebook must run top to bottom in a fresh Colab runtime from that cell alone (the Colab badge is the way to run a tutorial; the docs give no other run instructions); text before a code cell is at most 3 short sentences, and numbers computed by the code are printed, not typed in the text. Code shared by notebooks lives in the package, not in the notebooks: the plot style of the eight simulated-data notebooks (`plt.style.use('timecorr.tutorial')`, with `COLORS` read from its color cycle), the data of the three real-data notebooks (`tc.datasets.story_listening`, `tc.datasets.industry_returns`, `tc.datasets.fetch`), their videos (`tc.render_video` calls the notebook's function that draws a run of frames; files go to `tc.media_dir()` and are shown with `tc.show_video`), community labels and constant columns (the `"labels"` and `"constant_columns"` entries of `return_info`). A thumbnail cell sets `%config InlineBackend.print_figure_kwargs = {'bbox_inches': None}` and shows a 4 x 3 inch figure made with `dpi=150` (600 x 450 pixels). `higher_order.ipynb` holds the PCA event-contrast measurement that `simulate_data`'s order >= 3 warning cites. `htfa_network_animations.ipynb` downloads the HTFA fit of the story-listening data of Owen, Chang & Manning (2021) (460 MB archive, cached under `$TIMECORR_DATA`, default `~/timecorr_data`) and draws the features of orders 1 to 4 on the brain with the htfa toolbox; it writes its four 1920 x 1080, 30 fps H.264 movies (frames rendered in parallel by `tc.render_video` with `retries=50`, since an off-screen view can come back black when GPU memory runs short, each worker keeping one pyvista scene per view for a run of frames and replacing only spheres and edges; encoded at CRF 23 with `+faststart`; one frame per timepoint, 300 frames, 10 s; `QUALITY = 'full'`, chosen with 4 or more usable cores; with fewer, as on Colab, `'preview'` draws 960 x 540 frames of every 8th timepoint and also shows the full-quality videos of the online docs when reachable) to `docs/_static/tutorial_media/htfa_order{1..4}.mp4` (committed; at most about 8 MB each) and links them with `<video>` tags (relative path `../_static/tutorial_media/...`) instead of embedding them; outside `docs/tutorial` it writes them to `./htfa_videos` (`tc.media_dir('htfa_videos')`) and embeds them. `stocks.ipynb` downloads the daily returns of the 49 Industry Portfolios of the Kenneth R. French Data Library (cached under `$TIMECORR_DATA/french`; never committed) and writes `docs/_static/tutorial_media/stocks_network.mp4` (the market as a network, 42 s, CRF 27); the two `Siccodes` files of its sectors are fetched with `tc.datasets.fetch(..., member=...)`. `trajectories.ipynb` uses the HTFA archive of the HTFA tutorial, the French library returns and trial 86_02 of the CMU Motion Capture Database (fetched over http with `tc.datasets.fetch`, checked by SHA-256, cached under `$TIMECORR_DATA/cmu_mocap`; the notebook parses the AMC file), and writes `docs/_static/tutorial_media/trajectories_{story_listening,stock_market,human_movement}.mp4` (1920 x 600; each order reduced with `hyp.reduce`, each component rescaled to its own range, drawn in hypertools' cubes with `hyp.plot(..., panels=...)`; frames drawn by the notebook's `render_chunk`, the last one held for a second with `hold=1`). Both link their videos in the docs tree and embed them elsewhere (written to `./tutorial_media`)
- Tutorial notebooks: `docs/tutorial/` (`quickstart`, `kernels`, `subjects`, `reduce`, `simulate`, `higher_order`, `events`, `decoding`, `htfa_network_animations`, `stocks`, `trajectories`; rendered without execution; execute them with nbconvert (needs jupyter) before committing, except the three real-data notebooks, which take minutes to tens of minutes and download data). Each starts with a Colab badge and a title cell; its first code cell installs, on Google Colab only, what the notebook imports: `timecorr` (`timecorr[segment]` for `events`, plus named packages such as polars where imported; the real-data notebooks install `timecorr[tutorials]` and `bottleneck>=1.5`, since pandas 3 warns about Colab's older bottleneck), with one shell line, `!pip install -q "timecorr>=0.3.1" ... || pip install -q "timecorr @ git+https://github.com/ContextLab/timecorr.git@master" ...`: release 0.3.1 or later (the first with the helpers the notebooks call) from PyPI, or git master when pip cannot install that (the cell prints nothing of its own; pip's error about PyPI shows before the fallback), and every notebook must run top to bottom in a fresh Colab runtime from that cell alone (the Colab badge is the way to run a tutorial; the docs give no other run instructions); text before a code cell is at most 3 short sentences, and numbers computed by the code are printed, not typed in the text. Code shared by notebooks lives in the package, not in the notebooks: the plot style of the eight simulated-data notebooks (`plt.style.use('timecorr.tutorial')`, with `COLORS` read from its color cycle), the data of the three real-data notebooks (`tc.datasets.story_listening`, `tc.datasets.industry_returns`, `tc.datasets.fetch`), their videos (`tc.render_video` calls the notebook's function that draws a run of frames; files go to `tc.media_dir()` and are shown with `tc.show_video`), community labels and constant columns (the `"labels"` and `"constant_columns"` entries of `return_info`). A thumbnail cell sets `%config InlineBackend.print_figure_kwargs = {'bbox_inches': None}` and shows a 4 x 3 inch figure made with `dpi=150` (600 x 450 pixels). `higher_order.ipynb` holds the PCA event-contrast measurement that `simulate_data`'s order >= 3 warning cites. `htfa_network_animations.ipynb` downloads the HTFA fit of the story-listening data of Owen, Chang & Manning (2021) (460 MB archive, cached under `$TIMECORR_DATA`, default `~/timecorr_data`) and draws the features of orders 1 to 4 on the brain with the htfa toolbox; it writes its four 1920 x 1080, 30 fps H.264 movies (each drawn by one `htfa.animate_network` call of htfa 0.2.0: per-node colors, per-frame radii and edges, two views, caption and legend rows, frames rendered in parallel, a view that comes back black redrawn by htfa; encoded at CRF 23 with x264's preset `slow` and `+faststart`; its stills by `plot_network(..., views=, legend=, caption=)`; one frame per timepoint, 300 frames, 10 s; `QUALITY = 'full'`, chosen with 4 or more usable cores; with fewer, as on Colab, `'preview'` draws 960 x 540 frames of every 8th timepoint and also shows the full-quality videos of the online docs when reachable) to `docs/_static/tutorial_media/htfa_order{1..4}.mp4` (committed; at most about 8 MB each) and links them with `<video>` tags (relative path `../_static/tutorial_media/...`) instead of embedding them; outside `docs/tutorial` it writes them to `./htfa_videos` (`tc.media_dir('htfa_videos')`) and embeds them. `stocks.ipynb` downloads the daily returns of the 49 Industry Portfolios of the Kenneth R. French Data Library (cached under `$TIMECORR_DATA/french`; never committed) and writes `docs/_static/tutorial_media/stocks_network.mp4` (the market as a network, 42 s, CRF 27); the two `Siccodes` files of its sectors are fetched with `tc.datasets.fetch(..., member=...)`. `trajectories.ipynb` uses the HTFA archive of the HTFA tutorial, the French library returns and trial 86_02 of the CMU Motion Capture Database (fetched over http with `tc.datasets.fetch`, checked by SHA-256, cached under `$TIMECORR_DATA/cmu_mocap`; the notebook parses the AMC file), and writes `docs/_static/tutorial_media/trajectories_{story_listening,stock_market,human_movement}.mp4` (1920 x 600; each order reduced with `hyp.reduce`, each component rescaled to its own range, drawn in hypertools' cubes with `hyp.plot(..., panels=...)`; the videos by `hyp.plot(..., panels=..., animate=True, chemtrails=True, caption=...)` of hypertools 1.2, after which the notebook enlarges the caption and adds a title). Both link their videos in the docs tree and embed them elsewhere (written to `./tutorial_media`)

## Dependencies

Expand All @@ -113,4 +113,4 @@ Extras:
- `segment`: hmmlearn (used only by `segment`, and installed on demand if missing)
- `test`: pytest, polars, hmmlearn, imageio-ffmpeg, ipython
- `docs`: what the Sphinx build needs: sphinx, furo, numpydoc, nbsphinx, ipython (`.readthedocs.yaml` installs the package with this extra, plus pandoc, and fails on warnings)
- `tutorials`: what the real-data notebooks (htfa_network_animations, stocks, trajectories) import beyond the runtime dependencies; their Colab install cell installs `timecorr[tutorials]`: htfa[plot,brain3d]>=0.1.0, hypertools>=1.1, pyvista>=0.43, imageio-ffmpeg, pillow, joblib, ipython
- `tutorials`: what the real-data notebooks (htfa_network_animations, stocks, trajectories) import beyond the runtime dependencies; their Colab install cell installs `timecorr[tutorials]`: htfa[plot,brain3d]>=0.2.0, hypertools>=1.2, pyvista>=0.43, imageio-ffmpeg, pillow, joblib, ipython
Binary file modified docs/_static/tutorial_media/htfa_order1.mp4
Binary file not shown.
Binary file modified docs/_static/tutorial_media/htfa_order2.mp4
Binary file not shown.
Binary file modified docs/_static/tutorial_media/htfa_order3.mp4
Binary file not shown.
Binary file modified docs/_static/tutorial_media/htfa_order4.mp4
Binary file not shown.
Binary file modified docs/_static/tutorial_media/trajectories_human_movement.mp4
Binary file not shown.
Binary file modified docs/_static/tutorial_media/trajectories_stock_market.mp4
Binary file not shown.
Binary file modified docs/_static/tutorial_media/trajectories_story_listening.mp4
Binary file not shown.
340 changes: 104 additions & 236 deletions docs/tutorial/htfa_network_animations.ipynb

Large diffs are not rendered by default.

Loading
Loading