Skip to content

Commit

Permalink
debug graph cut
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhmark committed Mar 19, 2024
1 parent 04150b2 commit 48805ae
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1,884 deletions.
9 changes: 4 additions & 5 deletions ecut/base_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def export_swc(self, partition=True):
frag_node = self._fragment_trees[frag.source][frag_id]
nodes = self._fragment[frag_id].nodes
if not frag_node.reverse:
nodes = reversed(nodes)
nodes = nodes[::-1]
par_frag_id = frag_node.parent
if par_frag_id == -1:
last_id = -1, 1
Expand Down Expand Up @@ -126,10 +126,9 @@ def _linear_programming(self):
# finding variables for fragment/soma pairs that require solving
scores = {} # var_i_s, i: fragment id, s: soma id
for i, frag in self._fragment.items():
if len(frag.traversed) > 1: # mixed sources
scores[i] = {}
for s in frag.traversed:
scores[i][s] = pulp.LpVariable(f'Score_{i}_{s}', 0) # non-negative
scores[i] = {}
for s in frag.traversed:
scores[i][s] = pulp.LpVariable(f'Score_{i}_{s}', 0) # non-negative

# objective func: cost * score
self._problem += pulp.lpSum(
Expand Down
10 changes: 6 additions & 4 deletions example/app2_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@


if __name__ == '__main__':
tree = swc_handler.parse_swc('../test/data/gcut_input.swc_sorted.swc')
# tree = swc_handler.parse_swc('../test/data/gcut_input.swc_sorted.swc')
tree = swc_handler.parse_swc(r'D:\rectify\my_app2\18452_26569_3425_5509.swc')

# detect soma
d = DetectTracingMask(5)
soma = d.predict(tree, [.3, .3, 1.])

# anneal
a = MorphAnneal(tree)
tree = a.run()

# detect soma
d = DetectTracingMask(2.5, 100)
soma = d.predict(tree, [.25, .25, 1.])
kd = KDTree([t[2:5] for t in tree])
inds = kd.query(soma, return_distance=False)
inds = [tree[i[0]][0] for i in inds]
Expand Down
2 changes: 1 addition & 1 deletion example/batch_1891.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def main(args):
files = sorted(indir.glob('*.swc'))
outfiles = [outdir / f.name for f in files]
arglist = [*zip(files, outfiles)]
with Pool(16) as p:
with Pool(12) as p:
for i in tqdm(p.imap(main, arglist), total=len(arglist)):
pass
Loading

0 comments on commit 48805ae

Please sign in to comment.