fix: replace dead streamlines URL with Allen mesoscale connectivity via cloud-volume#438
fix: replace dead streamlines URL with Allen mesoscale connectivity via cloud-volume#438AdityaGupta716 wants to merge 13 commits intobrainglobe:mainfrom
Conversation
|
Hey @alessandrofelder @adamltyson, please review! |
|
Thanks for raising this @AdityaGupta716. This seems like a fairly big change, could you add some tests? Also could you make sure this works locally for you before asking reviewers to check it? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #438 +/- ##
==========================================
+ Coverage 86.60% 87.82% +1.21%
==========================================
Files 27 27
Lines 1239 1281 +42
==========================================
+ Hits 1073 1125 +52
+ Misses 166 156 -10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @adamltyson, I've added unit tests with mocked I/O covering the main functions and also verified it works locally — attached a screenshot of the render for experiment , you can see the brain mesh, injection site, and streamlines all coming through correctly. Let me know if there's anything else you'd like me to change!
|
|
Hi, I tested this and there is still a small issue : from https://connectivity.brain-map.org/projection/experiment/298004028?imageId=298004308&initImage=TWO_PHOTON&x=22791&y=11608 it is somhow flipped. tried to modify this but coludnt solve it: Amazing work getting this to work again! |
|
solved it here AdityaGupta716#1
|
Numerical verification showed brainrender's atlas mesh vertices use raw Allen CCF (PIR) coordinates, so no PIR→ASR conversion is needed. Removed _get_atlas_extents_um, _get_dv_extent_um, and all axis flip logic. Skeleton vertices are now passed through as-is after nm→um conversion. Co-developed-by: RobertoDF (identified the flip issue in brainglobe#438)
for more information, see https://pre-commit.ci
IgorTatarnikov
left a comment
There was a problem hiding this comment.
Hi @AdityaGupta716, this is great, thanks!
There seems to be a LR mirror/flip that's missing in the current code. The below screenshot was generated using the below code. According to https://connectivity.brain-map.org/projection/experiment/298004028?imageId=298004308&initImage=TWO_PHOTON&x=22791&y=11608, the streamlines should be in the right hemisphere, whereas in brainrender they show up in the left hemisphere (I specifically added right TH instead of both). I think this needs to be addressed before we can proceed further.
Code
from pathlib import Path
from myterial import orange
from rich import print
from brainrender import Scene
from brainrender.actors.streamlines import make_streamlines
from brainrender.atlas_specific.allen_brain_atlas.streamlines import get_streamlines_data
print(f"[{orange}]Running example: {Path(__file__).name}")
# Create a brainrender scene
scene = Scene()
# Add brain regions
scene.add_brain_region("TH", hemisphere="right")
# Get streamlines data and add
streams = get_streamlines_data([298004028])
scene.add(*make_streamlines(*streams, color="salmon", alpha=0.5))
# Render!
scene.render()
| @@ -1,4 +1,5 @@ | |||
| import pandas as pd | |||
| import requests as http_requests | |||
There was a problem hiding this comment.
There's no need to alias unless absolutely necessary! It adds a bit of extra friction when reading the code as requests is a common library that's used across many Python projects.
| import requests as http_requests | |
| import requests |
There was a problem hiding this comment.
We should have at least one test that downloads a small experiment and an injection site to make sure the data sources are still accessible.
for more information, see https://pre-commit.ci
|
hi @IgorTatarnikov, thanks for the review , i added a Z (medial-lateral) axis flip (z = ml_extent - z) to fix the hemisphere issue and also renamed import requests as http_requests to just import requests and added an integration test that downloads experiment 479983421 from GCS to make sure the data source stays live,also moved cloud-volume out of hard dependencies since the code already handles it being missing . |





What does this PR do?
Fixes the broken streamlines functionality by replacing the defunct
neuroinformatics.nl cache with the official Allen mesoscale connectivity
dataset hosted on Google Cloud Storage.
Why is this needed?
Closes #266
The URL
https://neuroinformatics.nl/HBP/allen-connectivity-viewer/json/streamlines_*.json.gzreturns 403 Forbidden. This was a third-party cache that is no longer maintained.
Changes
precomputed://gs://allen_neuroglancer_ccf/allen_mesoscaleaccessed via
cloud-volume— the official source recommended by AIBS (@fcollman)get_streamlines_data()to fetch skeleton data usingcloudvolume.CloudVolume_skeleton_to_dataframe()to convert the new precomputed skeleton format(vertices in nm + edges) back to the
{"x", "y", "z"}dict format expected byStreamlines._make_mesh()y = 8000 - y) to convert from Allen CCF PIR space tobrainrender's ASR orientation
_get_injection_site_um()to fetch real injection coordinates from the AllenBrain Atlas API (
ProjectionStructureUnionize) instead of using an approximationcloud-volumetopyproject.tomldependenciesforce_downloadflagHow was this tested?
StreamlinesactorIs this a breaking change?
No — the public API (
get_streamlines_data,get_streamlines_for_region) is unchanged.The output DataFrame format is identical to the old format.
Does this require a documentation update?
Yes — users will need
cloud-volumeinstalled. This is now listed as a dependencyin
pyproject.tomlso it will be installed automatically.