Skip to content

Feat: API for plotting multiple 2D slices from the same dataset at different distances - #109

Open
nikas-belogolov wants to merge 4 commits into
brainglobe:mainfrom
nikas-belogolov:feat/multiple-2d-slices-refactoring
Open

Feat: API for plotting multiple 2D slices from the same dataset at different distances#109
nikas-belogolov wants to merge 4 commits into
brainglobe:mainfrom
nikas-belogolov:feat/multiple-2d-slices-refactoring

Conversation

@nikas-belogolov

Copy link
Copy Markdown

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

The old way of plotting multiple figures with a loop created a separate scene for each subplot, which can cause a segmentation fault if the reference to each scene isn't kept.

What does this PR do?

This PR improves the API for plotting multiple 2D slices from the same dataset at different distances

References

issue #54

How has this PR been tested?

pytest and running examples

Is this a breaking change?

no

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

❌ Patch coverage is 14.03509% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.60%. Comparing base (0fea8e1) to head (fbe6ee2).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
brainglobe_heatmap/heatmaps.py 14.81% 46 Missing ⚠️
brainglobe_heatmap/planner.py 0.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (0fea8e1) and HEAD (fbe6ee2). Click for more details.

HEAD has 10 uploads less than BASE
Flag BASE (0fea8e1) HEAD (fbe6ee2)
15 5
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #109      +/-   ##
==========================================
- Coverage   69.63%   62.60%   -7.04%     
==========================================
  Files           5        5              
  Lines         326      369      +43     
==========================================
+ Hits          227      231       +4     
- Misses         99      138      +39     

☔ View full report in Codecov by Sentry.
📢 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.

@IgorTatarnikov IgorTatarnikov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nikas-belogolov, this is a great start. Could you remove the commented out code please?

I think the position argument is being overloaded with too many functions with this addition.

Perhaps, we add a new format. Currently, we support either "2D", or "3D". I propose we add a new "2D_multi" (name to be iterated on) that signals the internal machinery to work with multiple slicers instead of just one. This would allow self.slicer to always be the first position, and self.slicers to be a new optional list that's only filled/used when users request this new "2D_multi" mode.

We should also expose the nrows/ncols of the subplots to the user along with passing **kwargs to the underlying plt.subplot function. This is to avoid hard coding a specific size, or aspect ratio.

Comment thread brainglobe_heatmap/heatmaps.py Outdated
@nikas-belogolov

Copy link
Copy Markdown
Author

@IgorTatarnikov Thank you for the review, I will implement your suggestions by the end of the week for a final review and a merge

@nikas-belogolov

Copy link
Copy Markdown
Author

@IgorTatarnikov I've added a new format 2D_multi for multiple slicers, and exposed nrows, ncols & figsize to the user

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.

2 participants