Skip to content

Commit 0ae41f2

Browse files
author
anna-grim
committed
moved id getter
1 parent 75f9e1e commit 0ae41f2

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

src/segmentation_skeleton_metrics/utils/swc_util.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def load_from_zipped_file(self, zipfile, path):
261261

262262
def confirm_load(self, filename):
263263
if len(self.selected_ids) > 0:
264-
segment_id = get_segment_id(filename)
264+
segment_id = util.get_segment_id(filename)
265265
return True if segment_id in self.selected_ids else False
266266
else:
267267
return True
@@ -354,10 +354,6 @@ def read_voxel(self, xyz_str, offset):
354354

355355

356356
# --- Helpers ---
357-
def get_segment_id(filename):
358-
return int(filename.split(".")[0])
359-
360-
361357
def to_zipped_swc(zip_writer, graph, color=None):
362358
"""
363359
Writes a graph to an swc file that is to be stored in a zip.

src/segmentation_skeleton_metrics/utils/util.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,6 @@ def list_paths(directory, extension=None):
106106
return paths
107107

108108

109-
def get_id(path):
110-
"""
111-
Gets segment id of the swc file at "path".
112-
113-
Parameters
114-
----------
115-
path : str
116-
Path to an swc file
117-
118-
Return
119-
------
120-
int or str
121-
Segment id of swc file.
122-
123-
"""
124-
filename = os.path.basename(path).split(".")[0]
125-
return int(filename) if filename.isdigit() else filename
126-
127-
128109
# --- io utils ---
129110
def read_zip(zip_file, path):
130111
"""
@@ -208,6 +189,10 @@ def list_files_in_zip(zip_content):
208189

209190

210191
# --- Miscellaneous ---
192+
def get_segment_id(filename):
193+
return int(filename.split(".")[0])
194+
195+
211196
def load_merged_labels(path):
212197
"""
213198
Loads a list of merged label IDs from a text file.

0 commit comments

Comments
 (0)