Skip to content

Commit

Permalink
Merge pull request #491 from FZJ-INM1-BDA/fix_relatedRegions
Browse files Browse the repository at this point in the history
fix: return all related regions, not just first matching
  • Loading branch information
xgui3783 authored Oct 18, 2023
2 parents ff9cafa + 13ed728 commit 1520b4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 6 additions & 0 deletions e2e/core/test_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ def test_homologies_related_regions(parc, reg_spec, has_related, has_homology, h
repeat("ebrains")
)
assert len([f for f in features]) > 0

def test_related_region_hemisphere():
reg = siibra.get_region("2.9", "PGa")
all_related_reg = [reg for reg in reg.get_related_regions()]
assert any("left" in ass.assigned_structure.name for ass in all_related_reg)
assert any("right" in ass.assigned_structure.name for ass in all_related_reg)
14 changes: 6 additions & 8 deletions siibra/core/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,14 +895,12 @@ def translate_pevs(cls, src: "Region", _id: Union[str, List[str]]):
logger.warning(f"other version with uuid {uuid} not found")
continue

if len(found_targets) > 1:
logger.warning(f"Found multiple ({len(found_targets)}), returning the first one")

yield cls(
query_structure=src,
assigned_structure=found_targets[0],
qualification=RegionRelationship.OTHER_VERSION
)
for found_target in found_targets:
yield cls(
query_structure=src,
assigned_structure=found_target,
qualification=RegionRelationship.OTHER_VERSION
)

# homologuous
relations = pe.get("inRelationTo", [])
Expand Down

0 comments on commit 1520b4e

Please sign in to comment.