Skip to content

fix(#103): replace mesh projection with direct atlas volume read#125

Open
ArielShadrac wants to merge 2 commits intobrainglobe:mainfrom
ArielShadrac:fix/103-annotation-volume-2d
Open

fix(#103): replace mesh projection with direct atlas volume read#125
ArielShadrac wants to merge 2 commits intobrainglobe:mainfrom
ArielShadrac:fix/103-annotation-volume-2d

Conversation

@ArielShadrac
Copy link

Closes #103

Problem

The 2D frontal slice was showing only contours with no colours, and
the medio-lateral axis was inverted.

Before (bug #103)

Capture d'écran 2026-03-08 233857 image

After — correct colours and orientation

Figure_1
Code used to generate the render ```python import brainglobe_heatmap as bgh

dict1 = {
'mlf': 1.04, 'IO': 0.5, 'IP': 0.40, 'DCO': 0.88, 'VCO': 0.17,
'chpl': 0.14, 'IRN': 0.009, 'V4': 0.023, 'V4r': 0.11, 'PRP': 0.012,
'py': 0.38, 'MV': 0.097, 'SUV': 0.118, 'RO': 0.07, 'SPIV': 0.099,
'RPA': 0.467, 'MARN': 0.010, 'MY': 0.353, 'ICB': 0.056, 'SPVO': 0.036,
'das': 0.101, 'CB': 1.094, 'sctd': 1.318, 'NTS': 0.172, 'arb': 0.022,
'x': 0.112, 'sptV': 0.220, 'DN': 0.054, 'PARN': 0.009, 'rust': 0.042,
'sctv': 0.119, 'LING': 0.056, 'AMBd': 0.0, 'NOD': 0.419, 'PGRNd': 0.178,
'PGRNl': 0.025, 'FN': 0.016, 'PRM': 0.351, 'COPY': 0.267, 'PFL': 0.9,
'tspc': 0.020, 'GRN': 0.024, 'ANcr2': 0.280, 'icp': 0.096, 'VeCB': 0.053,
}

bgh.Heatmap(
dict1,
position=11500,
orientation="frontal",
thickness=100,
vmin=min(dict1.values()),
vmax=max(dict1.values()),
format="2D",
).show()


</details>


## Changes
- `_get_slice_from_volume`: reads `atlas.annotation` directly instead
  of projecting 3D meshes, fixing the ML-axis inversion
- `_build_region_masks_bottomup`: bottom-up ancestor traversal fixes
  empty masks for parent regions (e.g. CB) whose pixels are carried
  by leaf sub-regions in the annotation volume
- Single cumulative RGBA canvas replaces repeated `imshow()` calls
- Added `color_mode`, `show_labels`, smooth vectorial contours

## Tests
- Unit tests: `tests/test_unit/test_heatmaps_unit.py`
- Integration tests: `tests/test_integration/test_heatmaps_integration.py`

## How to test
pytest tests/ -v

ArielShadrac and others added 2 commits March 8, 2026 23:22
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.

[BUG]Visual contour display abnormality

1 participant