Skip to content

Commit f3a5d6d

Browse files
added utility function to get list of children regions
1 parent a822113 commit f3a5d6d

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

cuisto/utils.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,7 @@ def get_blacklist(file: str, atlas: BrainGlobeAtlas) -> list:
131131

132132
# add regions and their descendants
133133
for region in content["WITH_CHILDS"]["members"]:
134-
blacklist.extend(
135-
[
136-
atlas.structures[id]["acronym"]
137-
for id in atlas.structures.tree.expand_tree(
138-
atlas.structures[region]["id"]
139-
)
140-
]
141-
)
134+
blacklist.extend(get_child_regions(atlas, region))
142135

143136
# add regions specified exactly (no descendants)
144137
blacklist.extend(content["EXACT"]["members"])
@@ -198,6 +191,29 @@ def get_leaves_list(atlas: BrainGlobeAtlas) -> list:
198191
return leaves_list
199192

200193

194+
def get_child_regions(atlas: BrainGlobeAtlas, parent_region: str) -> list:
195+
"""
196+
Get list of regions that are child of `parent_region`.
197+
198+
Parameters
199+
----------
200+
atlas : BrainGlobeAtlas
201+
Atlas to extract regions from.
202+
203+
Returns
204+
-------
205+
child_list : list
206+
List of regions.
207+
208+
"""
209+
return [
210+
atlas.structures[id]["acronym"]
211+
for id in atlas.structures.tree.expand_tree(
212+
atlas.structures[parent_region]["id"]
213+
)
214+
]
215+
216+
201217
def ccf_to_stereo(
202218
x_ccf: float | np.ndarray, y_ccf: float | np.ndarray, z_ccf: float | np.ndarray = 0
203219
) -> tuple:

docs/demo_notebooks/cells_distributions.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@
912912
],
913913
"metadata": {
914914
"kernelspec": {
915-
"display_name": "hq",
915+
"display_name": "cuisto-env",
916916
"language": "python",
917917
"name": "python3"
918918
},
@@ -926,7 +926,7 @@
926926
"name": "python",
927927
"nbconvert_exporter": "python",
928928
"pygments_lexer": "ipython3",
929-
"version": "3.12.7"
929+
"version": "3.12.8"
930930
}
931931
},
932932
"nbformat": 4,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cuisto"
3-
version = "2024.12.19.1"
3+
version = "2025.01.07"
44
authors = [{ name = "Guillaume Le Goc", email = "g.legoc@posteo.org" }]
55
description = "Quantification of objects in histological slices"
66
readme = "README.md"

0 commit comments

Comments
 (0)