Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: upd whole brain routines #53

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions src/deep_neurographs/intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def build_neurograph_from_gcs_zips(
img_path=None,
min_size=MIN_SIZE,
n_proposals_per_leaf=N_PROPOSALS_PER_LEAF,
search_radius=SEARCH_RADIUS,
prune=PRUNE,
prune_depth=PRUNE_DEPTH,
optimize_proposals=OPTIMIZE_PROPOSALS,
Expand All @@ -106,9 +105,6 @@ def build_neurograph_from_gcs_zips(
n_proposals_per_leaf : int, optional
Number of edge proposals generated from each leaf node in an swc file.
The default is the global variable "N_PROPOSALS_PER_LEAF".
search_radius : float, optional
Maximum Euclidean length of an edge proposal. The default is the
global variable "SEARCH_RADIUS".
prune : bool, optional
Indication of whether to prune short branches. The default is the
global variable "PRUNE".
Expand Down Expand Up @@ -152,19 +148,6 @@ def build_neurograph_from_gcs_zips(
t, unit = utils.time_writer(time() - t0)
print(f"Module Runtime(): {round(t, 4)} {unit} \n")

# Generate proposals
if search_radius > 0:
print("Generate Edge Proposals...")
t0 = time()
neurograph.generate_proposals(
search_radius, n_proposals_per_leaf=n_proposals_per_leaf
)
t, unit = utils.time_writer(time() - t0)
print(
"# proposals:",
utils.reformat_number(len(neurograph.mutable_edges)),
)

t, unit = utils.time_writer(time() - total_runtime)
print(f"Total Runtime: {round(t, 4)} {unit}")
print(f"Memory Consumption: {round(utils.get_memory_usage(), 4)} GBs")
Expand Down
8 changes: 6 additions & 2 deletions src/deep_neurographs/neurograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ def __add_nodes(self, nodes, key, node_ids, cur_id, swc_id):
node_ids[i] = cur_id
self.add_node(
node_ids[i],
xyz=nodes[key][i]["xyz"],
proposals=set(),
radius=nodes[key][i]["radius"],
swc_id=swc_id,
xyz=nodes[key][i]["xyz"],
)
if key == "leafs":
self.leafs.add(cur_id)
Expand Down Expand Up @@ -173,6 +174,8 @@ def generate_proposals(
# Add edge
edge = frozenset((leaf, node))
self.proposals[edge] = {"xyz": np.array([xyz_leaf, xyz])}
self.nodes[node]["proposals"].add(leaf)
self.nodes[leaf]["proposals"].add(node)

# Check whether to optimization proposals
if optimize:
Expand Down Expand Up @@ -264,9 +267,10 @@ def split_edge(self, edge, attrs, idx):
new_node = len(self.nodes) + 1
self.add_node(
new_node,
xyz=tuple(attrs["xyz"][idx]),
proposals=set(),
radius=attrs["radius"][idx],
swc_id=attrs["swc_id"],
xyz=tuple(attrs["xyz"][idx]),
)
self.__add_edge((i, new_node), attrs, np.arange(0, idx + 1))
self.__add_edge(
Expand Down
Loading