Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Structures don't load for atlases in user configured brainglobe_dir path #165

Open
pderdeyn opened this issue Nov 16, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@pderdeyn
Copy link

Describe the bug
I have set a different path for my brainglobe_dir variable in the config file for brainglobe_atlasapi than the default. When I load the brainrender widget in napari, I can see the atlases I have in this folder. However, when I click an atlas once to view the structures, I get a stack or errors (shown in screenshots)

To Reproduce
Step 1: Change brainglobe_dir in config file (~/.config/brainglobe/bg_config.conf)
Step 2: Add an atlas to installation
Step 3: Open brainrender widget in napari and click atlas from the list

Expected behaviour
List of structures should appear and I should be able to load in meshes

Screenshots

image

Computer used (please complete the following information):

  • OS: Ubuntu
  • Version 18.j04

Additional context
Interestingly, double clicking does work to show the annotation and reference images

@pderdeyn pderdeyn added the bug Something isn't working label Nov 16, 2024
@pderdeyn
Copy link
Author

I fixed this on my computer with a couple of small changes in https://github.com/brainglobe/brainrender-napari/blob/main/brainrender_napari/utils/load_user_data.py

import json
from pathlib import Path

from brainglobe_atlasapi.list_atlases import get_local_atlas_version
+ from brainglobe_atlasapi import config

def read_atlas_metadata_from_file(atlas_name: str):
    """Reads atlas metadata stored in a `.json` in the BrainGlobe directory."""
-    brainglobe_dir = Path.home() / ".brainglobe"
+    brainglobe_dir = config.get_brainglobe_dir()
    with open(
        brainglobe_dir
        / f"{atlas_name}_v{get_local_atlas_version(atlas_name)}"
        / "metadata.json",
    ) as metadata_file:
        return json.loads(metadata_file.read())


def read_atlas_structures_from_file(atlas_name: str):
    """Reads structure info from a '.json' in the BrainGlobe directory."""
-    brainglobe_dir = Path.home() / ".brainglobe"
+    brainglobe_dir = config.get_brainglobe_dir()
    with open(
        brainglobe_dir
        / f"{atlas_name}_v{get_local_atlas_version(atlas_name)}"
        / "structures.json",
    ) as metadata_file:
        return json.loads(metadata_file.read())

Technically the error I encountered came from just the second function there, I didn't see references to read_atlas_metadata_from_file, but included the change there anyways, too

@alessandrofelder
Copy link
Member

alessandrofelder commented Nov 19, 2024

Thanks a lot for reporting @pderdeyn - would you want to make a Pull Request with your fixes by any chance? (Happy either way)

@pderdeyn
Copy link
Author

Sure, can do, @alessandrofelder! I should be able to do that later in the week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants