Skip to content

Increase MaximumLength of vedo's Mesh.join(reset=True)#121

Open
zenWai wants to merge 2 commits intobrainglobe:mainfrom
zenWai:pr/join-segments
Open

Increase MaximumLength of vedo's Mesh.join(reset=True)#121
zenWai wants to merge 2 commits intobrainglobe:mainfrom
zenWai:pr/join-segments

Conversation

@zenWai
Copy link
Contributor

@zenWai zenWai commented Mar 3, 2026

Description

What is this PR

  • Bug fix

Why is this PR needed?

import brainglobe_heatmap as bgh
values = dict(CL=1,CM=2, PAG=3)
position = 9100 # or 7100 9200
f = bgh.Heatmap(
    values,
    position,
    orientation="frontal",
    title=f"kim10um frontal {position}",
    atlas_name="kim_mouse_10um",
    vmin=-5,
    vmax=3,
    format="2D",
).show()
kim10um_frontal_7100_before kim10um_frontal_9100_before
vedo's join(reset=True) uses vtkStripper with its default MaximumLength=1000. For high-resolution atlases like kim_mouse_10um, the root contour exceeds this limit, causing the stripper to split it into multiple cells and when it gets split into multiple cells, only the first cell is kept causing the issue seen above.

What does this PR do?

Replicate vedo's join(reset=True) with the limit raised to 100000, so the stripper doesn't split it into multiple cells.

kim10um_frontal_7100_pr kim10um_frontal_9100_pr
  • New test to test the functionality of the method introduced.

How has this PR been tested?

  • Tests
  • New test
  • Examples above and /examples\
  • Several different position on kim

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

- Taking as an example kim_mouse_10um position 9100, specifically fixes the root not being fully visible
@zenWai
Copy link
Contributor Author

zenWai commented Mar 3, 2026

I started with a simple piece.clean() and it showed potential, did fix the issue on the particular showcased position 7100 but 9100 still had issues. The reason piece.clean() helped is because kim particularly have lots of vertices that are repeated on same position and by cleaning the lazy .join() did not exceeded the limit sooner.

After exploring a bit more I saw the need to increase the MaximumLength from vtkStripper used when calling .join().

I wasn't able to find a easy straight forward way of increasing the MaximumLength for vtkStripper, so I replicated the join() method to be able to increase the MaximumLength.
The new method is a 1:1 copy of current source code.

it would be awesome to find a better way to increase the MaximumLength for vtkStripper and deprecate the introduced method _join_reset( )

@zenWai
Copy link
Contributor Author

zenWai commented Mar 3, 2026

Currently the tests will need the kim_mouse_10um, but potentially will stress ghactions 🤔
Just checked and kim_mouse_10um is 10gb, insane!

@adamltyson
Copy link
Member

It's not practical to use an atlas of that size for automated tests, can you create some synthetic data for testing?

- test with sphere, shuffled cells, higher res triggers SetMaximumLength constraint
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   69.63%   71.46%   +1.83%     
==========================================
  Files           5        5              
  Lines         326      347      +21     
==========================================
+ Hits          227      248      +21     
  Misses         99       99              

☔ 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.

@zenWai
Copy link
Contributor Author

zenWai commented Mar 4, 2026

It's not practical to use an atlas of that size for automated tests, can you create some synthetic data for testing?

Done! Thanks for the quick feedback.

@zenWai zenWai marked this pull request as ready for review March 4, 2026 11:03
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