Skip to content

Commit

Permalink
fix: ensure properties are added to skeletons
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Aug 2, 2024
1 parent 4e6c6ec commit 656abdb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions kimimaro/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,16 @@ def cross_sectional_area(
visualize_section_planes: For debugging, paint section planes
and display them using microviewer.
"""
prop = {
xs_prop = {
"id": "cross_sectional_area",
"data_type": "float32",
"num_components": 1,
}
xs_contact_prop = {
"id": "cross_sectional_area_contacts",
"data_type": "uint8",
"num_components": 1,
}

def cross_sectional_area_helper(skel, binimg, roi):
cross_sections = None
Expand Down Expand Up @@ -235,8 +240,6 @@ def cross_sectional_area_helper(skel, binimg, roi):
for idx, vals in branch_pt_vals.items():
areas[idx] = sum(vals) / len(vals)

add_property(skel, prop)

skel.cross_sectional_area = areas
skel.cross_sectional_area_contacts = contacts

Expand All @@ -247,6 +250,9 @@ def cross_sectional_area_helper(skel, binimg, roi):
)

for skel in skeletons.values():
add_property(skel, xs_prop)
add_property(skel, xs_contact_prop)

if not hasattr(skel, "cross_sectional_area"):
skel.cross_sectional_area = np.full(len(skel.vertices), -1, dtype=np.float32, order="F")
if not hasattr(skel, "cross_sectional_area_contacts"):
Expand Down

0 comments on commit 656abdb

Please sign in to comment.