Skip to content

Commit

Permalink
Merge branch 'master' of github.com:seung-lab/igneous
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Feb 22, 2025
2 parents 60bcf7d + 83e246f commit c148f05
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
28 changes: 25 additions & 3 deletions igneous/tasks/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,33 @@ def compute_cross_sectional_area(self, vol, bbox, skeletons):
def repair_cross_sectional_area_contacts(self, vol, bbox, skeletons):
from dbscan import DBSCAN

repair_skels = [
skel for skel in skeletons.values()
if np.any(skel.cross_sectional_area_contacts > 0)
boundaries = [
bbox.minpt.x == vol.bounds.minpt.x,
bbox.maxpt.x == vol.bounds.maxpt.x,
bbox.minpt.y == vol.bounds.minpt.y,
bbox.maxpt.y == vol.bounds.maxpt.y,
bbox.minpt.z == vol.bounds.minpt.z,
bbox.maxpt.z == vol.bounds.maxpt.z,
]

if all(boundaries):
return skeletons

invalid_repairs = 0
for i, bnd in enumerate(boundaries):
invalid_repairs |= (bnd << i)

invalid_repairs = (~np.uint8(invalid_repairs)) & np.uint8(0b00111111)

# We want to repair any skeleton that has a contact with the
# edge except those that are contacting the volume boundary due to futility

repair_skels = []
for skel in skeletons.values():
contacts = skel.cross_sectional_area_contacts & invalid_repairs
if np.any(contacts):
repair_skels.append(skel)

delta = int(self.cross_sectional_area_shape_delta)

shape = bbox.size3()
Expand Down
13 changes: 7 additions & 6 deletions igneous_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ def enqueue_tasks(ctx, queue, tasks):
tq.insert(tasks, parallel=parallel)
return tq

class TupleN(click.ParamType):
class ListN(click.ParamType):
"""A command line option type consisting of 3 comma-separated integers."""
name = 'tupleN'
name = 'ListN'
def convert(self, value, param, ctx):
if isinstance(value, str):
value = tuple(map(int, value.split(',')))
value = list(map(int, value.split(',')))
return value

class Tuple34(click.ParamType):
Expand Down Expand Up @@ -1236,19 +1236,20 @@ def skeletongroup():
@click.option('--soma-const', default=300, help="Const factor for soma invalidation.", type=float, show_default=True)
@click.option('--max-paths', default=None, help="Abort skeletonizing an object after this many paths have been traced.", type=float)
@click.option('--sharded', is_flag=True, default=False, help="Generate shard fragments instead of outputing skeleton fragments.", show_default=True)
@click.option('--labels', type=TupleN(), default=None, help="Skeletonize only this comma separated list of labels.", show_default=True)
@click.option('--labels', type=ListN(), default=None, help="Skeletonize only this comma separated list of labels.", show_default=True)
@click.option('--cross-section', type=int, default=0, help="Compute the cross sectional area for each skeleton vertex. May add substantial computation time. Integer value is the normal vector rolling average smoothing window over vertices. 0 means off.", show_default=True)
@click.option('--output', '-o', type=CloudPath(), default=None, help="Output the results to a different place.", show_default=True)
@click.option('--timestamp', type=int, default=None, help="(graphene) Use the proofreading state at this UNIX timestamp.", show_default=True)
@click.option('--root-ids', type=CloudPath(), default=None, help="(graphene) If you have a materialization of graphene root ids for this timepoint, it's more efficient to use it than making requests to the graphene server.", show_default=True)
@click.option('--progress', is_flag=True, default=False, help="Print progress bars.", show_default=True)
@click.pass_context
def skeleton_forge(
ctx, path, queue, mip, shape,
fill_missing, dust_threshold, dust_global, spatial_index,
fix_branching, fix_borders, fix_avocados, fix_autapses,
fill_holes, scale, const, soma_detect, soma_accept,
soma_scale, soma_const, max_paths, sharded, labels,
cross_section, output, timestamp, root_ids,
cross_section, output, timestamp, root_ids, progress,
):
"""
(1) Synthesize skeletons from segmentation cutouts.
Expand Down Expand Up @@ -1287,7 +1288,7 @@ def skeleton_forge(
teasar_params=teasar_params,
fix_branching=fix_branching, fix_borders=fix_borders,
fix_avocados=fix_avocados, fill_holes=fill_holes,
dust_threshold=dust_threshold, progress=False,
dust_threshold=dust_threshold, progress=progress,
parallel=1, fill_missing=fill_missing,
sharded=sharded, spatial_index=spatial_index,
dust_global=dust_global, object_ids=labels,
Expand Down

0 comments on commit c148f05

Please sign in to comment.