Skip to content

Add animated 2d example - #129

Open
BhoomikaC15 wants to merge 5 commits into
brainglobe:mainfrom
BhoomikaC15:add-animated-2d-example
Open

Add animated 2d example#129
BhoomikaC15 wants to merge 5 commits into
brainglobe:mainfrom
BhoomikaC15:add-animated-2d-example

Conversation

@BhoomikaC15

Copy link
Copy Markdown
Contributor

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
This PR adds an example showing how to generate an animated 2D heatmap across slice positions. It provides a reference implementation for users who want to visualize how region values vary across the brain volume rather than viewing a single static slice.

What does this PR do?
Adds a new example script, examples/heatmap_animated.py, which:

  • iterates through slice positions for a selected atlas/orientation
  • generates sequential 2D heatmap frames using brainglobe-heatmap
  • exports the animation as a GIF using matplotlib.animation
  • keeps color normalization fixed across all frames so values remain comparable throughout the animation
  • includes a frame counter overlay and explicit playback speed when saving the GIF

References

Relates to #106

How has this PR been tested?

  • Ran the example locally and verified that the animation is generated successfully
  • Verified that the script is syntactically valid
  • Confirmed that the colorbar colormap matches the plotted heatmap colormap

Is this a breaking change?

No. This PR only adds a new example script.

Does this PR require an update to the documentation?

No.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.08%. Comparing base (0fea8e1) to head (64b8740).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #129      +/-   ##
==========================================
+ Coverage   69.63%   72.08%   +2.45%     
==========================================
  Files           5        5              
  Lines         326      326              
==========================================
+ Hits          227      235       +8     
+ Misses         99       91       -8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adamltyson adamltyson linked an issue Jun 29, 2026 that may be closed by this pull request
@adamltyson
adamltyson self-requested a review June 29, 2026 17:46
@adamltyson

Copy link
Copy Markdown
Member

Hi @BhoomikaC15, sorry for the delay in reviewing this. This example looks useful (and works first time!), but the changes to the tests don't seem to be related. Would you mind removing them?

A couple of other suggestions:

  • Could you add a few more comments to the new example so users can understand what each part does (so they can edit for their own purposes)
  • could you make sure the variables are at the top (e.g. the atlas) before any function calls?

@BhoomikaC15
BhoomikaC15 force-pushed the add-animated-2d-example branch from 64b8740 to d25b235 Compare July 2, 2026 17:16
@BhoomikaC15

BhoomikaC15 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi @adamltyson, I’ve completed the example updates you requested. Sorry for the extra test files, they were my mistake. I had already added similar tests in a separate PR that’s now merged, but I accidentally included them here as well. I’ve removed those test files from this PR.

Also, the remaining GitHub failure looks unrelated to the example changes and seems to come from the repository’s Python 3.12 dependency chain. Since that may be a repo-wide issue, would you prefer I open a separate PR for that, or should I keep this PR scoped only to the example updates?

@adamltyson

Copy link
Copy Markdown
Member

Hi @BhoomikaC15, you seem to have deleted the test files themselves. Could you make sure the tests aren't touched at all? There should be just one change in this PR, your new example file.

#144 fixed the CI, so if you merge main into this PR, everything should pass. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] New example addition :GIF format

2 participants