Skip to content

Commit

Permalink
Limit thalamus region dirvecs to specific regions (#27)
Browse files Browse the repository at this point in the history
* Limit thalamus region dirvecs to specific regions

This replaces the region selection of what region direction-vectors are
made for in thalamus with a regular expression. This was scientifically
necessary for exclusion of the habenular and peripeduncular regions, and
code-wise so that the thalamus region selection regex can be harmonized
across all uses. For information on which regions were chosen and how
this list was created, see the internal BBP Confluence page located at
"Circuits > Mouse Thalamus > Atlas-based Whole-thalamus subregion
selection". This regex has been built from the region list of the
desired and present thalamus regions as of the "final" version of the
hierarchy and annotation built by the Atlas pipeline, which is the
output of the rule `split_barrel_ccfv3_l23split`.

* Fix tests and pass linting/etc.

My addition broke the tests because the thalamus regions in the tests
weren't included in my subregion query. This has been fixed.

I also made the changes necessary to pass all the `tox` tests, including
linting, formatting, and general tests.

* Synchronize thalamus regex with placement-hints

---------

Co-authored-by: Austin E. Soplata <[email protected]>
  • Loading branch information
asoplata and Austin E. Soplata authored May 21, 2024
1 parent b3880ce commit fadfe0e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions atlas_direction_vectors/thalamus.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numpy as np
from atlas_commons.typing import BoolArray, NDArray
from atlas_commons.utils import get_region_mask
from atlas_commons.utils import get_region_mask, query_region_mask
from scipy.ndimage import correlate # type: ignore
from scipy.ndimage.morphology import generate_binary_structure # type: ignore
from voxcell import RegionMap, VoxelData
Expand Down Expand Up @@ -63,7 +63,19 @@ def compute_direction_vectors(
as the input one. Voxels outside the thalamus have np.nan coordinates.
"""

thalamus_mask = get_region_mask("TH", brain_regions.raw, region_map)
# For information on which regions were chosen and how this list was created, see the internal
# BBP Confluence page located at "Circuits > Mouse Thalamus > Atlas-based Whole-thalamus
# subregion selection".
thalamus_query = {
"query": "@^(?:AD|AMd|AMv|AV|CL|CM|Eth|IAD|IAM|IGL|IMD|IntG|LD|LGd-co|LGd-ip|LGd-sh|LGv_O|"
+ "LP|MD_O|MGd|MGm|MGv|PCN|PF|PIL|PO|POL|PR|PT|PVT|PoT|RE|RH|SGN|SMT|SPA|SPFm|SPFp|SubG|"
+ "TH_O|VAL|VM|VPL|VPLpc|VPM|VPMpc|Xi)$",
"attribute": "acronym",
"with_descendants": False,
}

thalamus_mask = query_region_mask(thalamus_query, brain_regions.raw, region_map)

reticular_nucleus_mask = get_region_mask("RT", brain_regions.raw, region_map)
reticular_nucleus_complement_mask = np.logical_and(thalamus_mask, ~reticular_nucleus_mask)
common_outer_boundary_mask = _get_common_outer_boundary(thalamus_mask, reticular_nucleus_mask)
Expand Down
2 changes: 1 addition & 1 deletion tests/app/test_direction_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_thalamus():
with runner.isolated_filesystem():
voxel_data = create_voxeldata(
718, # VPL, Ventral posterolateral nucleus of the thalamus
709, # VPM, Ventral posteromedial nucleus of the thalamus
733, # VPM, Ventral posteromedial nucleus of the thalamus
)
voxel_data.save_nrrd("annotation.nrrd")
result = runner.invoke(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_thalamus.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def test_get_common_outer_boundary():

def test_compute_direction_vectors(region_map):
voxel_data = create_voxeldata(
685, # VM, Ventral medial nucleus of the thalamus
709, # VP, Ventral posterior complex of the thalamus
718, # VPL, Ventral posterolateral nucleus of the thalamus
733, # VPM, Ventral posteromedial nucleus of the thalamus
)
with warnings.catch_warnings(record=True) as warnings_:
direction_vectors = tested.compute_direction_vectors(region_map, voxel_data)
Expand Down

0 comments on commit fadfe0e

Please sign in to comment.