Skip to content

Commit

Permalink
Update swc_util.py
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-grim authored Nov 25, 2024
1 parent bccfa9c commit d75f806
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions src/deep_neurographs/utils/swc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, anisotropy=[1.0, 1.0, 1.0], min_size=0):
Parameters
----------
anisotropy : list[float], optional
anisotropy : List[float], optional
Image to world scaling factors applied to xyz coordinates to
account for anisotropy of the microscope. The default is
[1.0, 1.0, 1.0].
Expand Down Expand Up @@ -70,7 +70,7 @@ def load(self, swc_pointer):
Returns
-------
list[dict]
List[dict]
List of dictionaries whose keys and values are the attribute name
and values from an swc file.
Expand Down Expand Up @@ -102,7 +102,7 @@ def load_from_local_paths(self, swc_paths):
Returns
-------
list[dict]
List[dict]
List of dictionaries whose keys and values are the attribute name
and values from an swc file.
Expand Down Expand Up @@ -135,7 +135,7 @@ def load_from_local_path(self, path):
Returns
-------
list[dict]
List[dict]
List of dictionaries whose keys and values are the attribute name
and values from an swc file.
Expand All @@ -156,7 +156,7 @@ def load_from_local_zip(self, zip_path):
Paramters
---------
swc_paths : list or dict
swc_paths : Container
If swc files are on local machine, list of paths to swc files where
each file corresponds to a neuron in the prediction. If swc files
are on cloud, then dict with keys "bucket_name" and "path".
Expand Down Expand Up @@ -284,7 +284,7 @@ def parse(self, content):
Parameters
----------
content : list[str]
content : List[str]
List of entries from an swc file.
Returns
Expand Down Expand Up @@ -461,7 +461,7 @@ def write_graph(path, graph, color=None):
Returns
-------
list[str]
List[str]
List of swc file entries to be written.
"""
Expand Down Expand Up @@ -571,6 +571,29 @@ def make_entry(graph, i, parent, node_to_idx):
return entry, node_to_idx


def make_simple_entry(node, parent, xyz, radius=5):
"""
Makes an entry to be written in an swc file.
Parameters
----------
node : int
Node that entry corresponds to.
parent : int
Parent of node "i".
xyz : numpy.ndarray
xyz coordinate to be written to an swc file.
Returns
-------
str
Entry of an swc file
"""
x, y, z = tuple(xyz)
return f"{node} 2 {x} {y} {z} {radius} {parent}"


def set_radius(graph, i):
"""
Sets the radius of node "i".
Expand All @@ -595,28 +618,6 @@ def set_radius(graph, i):
return radius


def make_simple_entry(node, parent, xyz, radius=5):
"""
Makes an entry to be written in an swc file.
Parameters
----------
node : int
Node that entry corresponds to.
parent : int
Parent of node "i".
xyz : numpy.ndarray
...
Returns
-------
...
"""
x, y, z = tuple(xyz)
return f"{node} 2 {x} {y} {z} {radius} {parent}"


# --- Miscellaneous ---
def to_graph(swc_dict, swc_id=None, set_attrs=False):
"""
Expand Down

0 comments on commit d75f806

Please sign in to comment.