Skip to content

Fetch atlas meshes by loading meshio and converting to vedo mesh#461

Merged
IgorTatarnikov merged 3 commits into
mainfrom
update-atlas-mesh-fetch
Jul 17, 2026
Merged

Fetch atlas meshes by loading meshio and converting to vedo mesh#461
IgorTatarnikov merged 3 commits into
mainfrom
update-atlas-mesh-fetch

Conversation

@IgorTatarnikov

@IgorTatarnikov IgorTatarnikov commented Jul 17, 2026

Copy link
Copy Markdown
Member

Before submitting a pull request (PR), please read the contributing guide.

Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
Following the release of brainglobe-atlasapi==3.0.0rc0 meshes are no longer stored on disk as .obj files. brainrender accesses these files directly to load meshes into vedo.

What does this PR do?
Alters the loading path for atlas meshes. brainrender now requests the mesh directly from brainglobe-atlasapi receiving a meshio.Mesh, this is converted into a vedo.Mesh and passed through as before.

References

#460

How has this PR been tested?

All tests pass locally and local examples involving atlas meshes have been inspected in an environment with brainglobe-atlasapi==3.0.0rc0 and brainglobe-atlasapi==2.3.1

Is this a breaking change?

No, this change is backwards compatible with brainglobe-atlasapi<3.0.0

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 code has been formatted with pre-commit

@IgorTatarnikov IgorTatarnikov changed the title Fetches atlas meshes by loading meshio and converting to vedo mesh Fetch atlas meshes by loading meshio and converting to vedo mesh Jul 17, 2026
@IgorTatarnikov
IgorTatarnikov requested a review from a team July 17, 2026 10:00
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.52%. Comparing base (e1b1969) to head (0f8a341).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #461      +/-   ##
==========================================
+ Coverage   89.48%   89.52%   +0.03%     
==========================================
  Files          27       27              
  Lines        1294     1298       +4     
==========================================
+ Hits         1158     1162       +4     
  Misses        136      136              

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

This all looks sensible to me, although for some reason everything is failing locally for me. Not sure what's going on with my installation.

Could load_mesh_from_file be deleted at this point?

@IgorTatarnikov

Copy link
Copy Markdown
Member Author

I don't think load_mesh_from_file can be removed. It's used to support adding external .obj or .stl files to a scene.

@IgorTatarnikov

Copy link
Copy Markdown
Member Author

This all looks sensible to me, although for some reason everything is failing locally for me. Not sure what's going on with my installation.

Is this with 2.3.1 or 3.0.0rc0?

Could you try deleting ~/.brainglobe/brainglobe-atlasapi?

@adamltyson

Copy link
Copy Markdown
Member

Even after deleting .brainglobe, I still get:

Traceback
(atlasapiv3test) tigger:brainrender adamtyson$ python examples/volumetric_data.py 
Running example: volumetric_data.py
Downloading allen_mouse_25um atlas v3.0 manifest:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/adamtyson/projects/brainglobe/brainrender/brainrender/atlas.py:39 in __init__             │
│                                                                                                  │
│    36 │   │   logger.debug(f"Generating ATLAS: {atlas_name}")                                    │
│    37 │   │                                                                                      │
│    38 │   │   try:                                                                               │
│ ❱  39 │   │   │   super().__init__(atlas_name=atlas_name, print_authors=False)                   │
│    40 │   │   except TypeError:                                                                  │
│    41 │   │   │   # The latest version of BGatlas has no print_authors argument                  │
│    42 │   │   │   super().__init__(atlas_name=atlas_name, check_latest=check_latest)             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: BrainGlobeAtlas.__init__() got an unexpected keyword argument 'print_authors'

During handling of the above exception, another exception occurred:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/adamtyson/projects/brainglobe/brainrender/examples/volumetric_data.py:24 in <module>      │
│                                                                                                  │
│   21                                                                                             │
│   22 print(f"[{orange}]Running example: {Path(__file__).name}")                                  │
│   23                                                                                             │
│ ❱ 24 scene = Scene(inset=False)                                                                  │
│   25                                                                                             │
│   26 data = np.load(volume_file)                                                                 │
│   27 print(data.shape)                                                                           │
│                                                                                                  │
│ /Users/adamtyson/projects/brainglobe/brainrender/brainrender/scene.py:69 in __init__             │
│                                                                                                  │
│    66 │   │   self.actors = []  # stores all actors in the scene                                 │
│    67 │   │   self.labels = []  # stores all `labels` actors in scene                            │
│    68 │   │                                                                                      │
│ ❱  69 │   │   self.atlas = Atlas(atlas_name=atlas_name, check_latest=check_latest)               │
│    70 │   │                                                                                      │
│    71 │   │   self.screenshots_folder = (                                                        │
│    72 │   │   │   Path(screenshots_folder)                                                       │
│                                                                                                  │
│ /Users/adamtyson/projects/brainglobe/brainrender/brainrender/atlas.py:42 in __init__             │
│                                                                                                  │
│    39 │   │   │   super().__init__(atlas_name=atlas_name, print_authors=False)                   │
│    40 │   │   except TypeError:                                                                  │
│    41 │   │   │   # The latest version of BGatlas has no print_authors argument                  │
│ ❱  42 │   │   │   super().__init__(atlas_name=atlas_name, check_latest=check_latest)             │
│    43 │                                                                                          │
│    44 │   @property                                                                              │
│    45 │   def zoom(self) -> float:                                                               │
│                                                                                                  │
│ /Users/adamtyson/miniforge3/envs/atlasapiv3test/lib/python3.13/site-packages/brainglobe_atlasapi │
│ /bg_atlas.py:110 in __init__                                                                     │
│                                                                                                  │
│   107 │   │   │   │   # If internet is up, then the atlas name was invalid                       │
│   108 │   │   │   │   raise ValueError(f"{atlas_name} is not a valid atlas name!")               │
│   109 │   │   │   else:                                                                          │
│ ❱ 110 │   │   │   │   self.download()                                                            │
│   111 │   │   │   │   assert self.local_full_name is not None, (                                 │
│   112 │   │   │   │   │   "Download failed: local atlas manifest not found after "               │
│   113 │   │   │   │   │   "download."                                                            │
│                                                                                                  │
│ /Users/adamtyson/miniforge3/envs/atlasapiv3test/lib/python3.13/site-packages/brainglobe_atlasapi │
│ /bg_atlas.py:249 in download                                                                     │
│                                                                                                  │
│   246 │   │   │   f"Downloading {self.atlas_name} atlas "                                        │
│   247 │   │   │   f"v{remote_version_str.replace('_', '.')} manifest:"                           │
│   248 │   │   )                                                                                  │
│ ❱ 249 │   │   self.fs.get(remote_path, local_path, callback=TqdmCallback())                      │
│   250 │   │   self.metadata = read_json(local_path)                                              │
│   251 │   │                                                                                      │
│   252 │   │   try:                                                                               │
│                                                                                                  │
│ /Users/adamtyson/miniforge3/envs/atlasapiv3test/lib/python3.13/site-packages/fsspec/spec.py:1007 │
│ in get                                                                                           │
│                                                                                                  │
│   1004 │   │   │   │   (has_magic(rpath) and source_is_file)                                     │
│   1005 │   │   │   │   or (not has_magic(rpath) and dest_is_dir and not trailing_sep(rpath))     │
│   1006 │   │   │   )                                                                             │
│ ❱ 1007 │   │   │   lpaths = other_paths(                                                         │
│   1008 │   │   │   │   rpaths,                                                                   │
│   1009 │   │   │   │   lpath,                                                                    │
│   1010 │   │   │   │   exists=exists,                                                            │
│                                                                                                  │
│ /Users/adamtyson/miniforge3/envs/atlasapiv3test/lib/python3.13/site-packages/fsspec/utils.py:414 │
│ in other_paths                                                                                   │
│                                                                                                  │
│   411 │   │   │   else:                                                                          │
│   412 │   │   │   │   path2 = [p.replace(cp, path2, 1) for p in paths]                           │
│   413 │   else:                                                                                  │
│ ❱ 414 │   │   assert len(paths) == len(path2)                                                    │
│   415 │   return path2                                                                           │
│   416                                                                                            │
│   417                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: object of type 'PosixPath' has no len()
Exception ignored in: <function Scene.__del__ at 0x14ba9de40>
Traceback (most recent call last):
  File "/Users/adamtyson/projects/brainglobe/brainrender/brainrender/scene.py", line 114, in __del__
    self.close()
  File "/Users/adamtyson/projects/brainglobe/brainrender/brainrender/render.py", line 322, in close
    self.plotter.close()
AttributeError: 'NoneType' object has no attribute 'close'

@IgorTatarnikov

Copy link
Copy Markdown
Member Author

I can replicate on Mac, weird that CI passes!

I'll move this to draft for now

@IgorTatarnikov
IgorTatarnikov marked this pull request as draft July 17, 2026 10:47
@IgorTatarnikov
IgorTatarnikov marked this pull request as ready for review July 17, 2026 13:52
@IgorTatarnikov

Copy link
Copy Markdown
Member Author

Issue should be solved by brainglobe/brainglobe-atlasapi#860

@adamltyson

Copy link
Copy Markdown
Member

Works for me with a clean installation :)

@IgorTatarnikov

Copy link
Copy Markdown
Member Author

Perfect! I'll merge this now to unblock brainglobe-heatmap.

@IgorTatarnikov
IgorTatarnikov merged commit 5dab17e into main Jul 17, 2026
12 checks passed
@IgorTatarnikov
IgorTatarnikov deleted the update-atlas-mesh-fetch branch July 17, 2026 14:52
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