Skip to content

Commit

Permalink
removes double dilation away from nodes so unpaired branches finish a…
Browse files Browse the repository at this point in the history
…way from the crossing branches for tracing
  • Loading branch information
MaxGamill-Sheffield committed Sep 16, 2024
1 parent a6d24b4 commit a34e513
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions topostats/tracing/ordered_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import numpy.typing as npt
import pandas as pd
from skimage.morphology import label
from skimage.morphology import binary_dilation, label
from topoly import jones, translate_code

from topostats.logs.logs import LOGGER_NAME
Expand Down Expand Up @@ -136,16 +136,15 @@ def compile_trace(self, reverse_min_conf_crossing: bool = False) -> tuple[list,
low_conf_idx = None

# Get the image minus the crossing regions
minus = self.skeleton.copy()
nodes = np.zeros_like(self.skeleton)
for node_no in node_coords: # this stops unpaired branches from interacting with the pairs
nodes[node_no[0][:, 0], node_no[0][:, 1]] = 1
minus = np.where(binary_dilation(binary_dilation(nodes)) == self.skeleton, 0, self.skeleton)
# remove crossings from skeleton
for crossings in crossing_coords:
for crossing in crossings:
minus[crossing[:, 0], crossing[:, 1]] = 0
minus = label(minus)
# Get both image
both = minus.copy()
for node_num, crossings in enumerate(crossing_coords):
for crossing_num, crossing in enumerate(crossings):
both[crossing[:, 0], crossing[:, 1]] = node_num + crossing_num + minus.max()

# setup z array
z = []
Expand Down

0 comments on commit a34e513

Please sign in to comment.