Skip to content

Commit 2bddec4

Browse files
authored
Update swc_util.py
1 parent 333fe31 commit 2bddec4

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/segmentation_skeleton_metrics/utils/swc_util.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ def read_from_gcs_swcs(self, bucket_name, swc_paths):
334334
if result:
335335
swc_dicts.append(result)
336336
pbar.update(1)
337-
print("# swcs:", len(swc_dicts))
338337
return swc_dicts
339338

340339
def read_from_gcs_swc(self, bucket_name, path):
@@ -440,20 +439,23 @@ def parse(self, content, filename):
440439
# Initializations
441440
swc_id, _ = os.path.splitext(filename)
442441
content, offset = self.process_content(content)
443-
swc_dict = {
444-
"id": np.zeros((len(content)), dtype=int),
445-
"pid": np.zeros((len(content)), dtype=int),
446-
"voxel": np.zeros((len(content), 3), dtype=np.int32),
447-
"swc_id": swc_id,
448-
}
449-
450-
# Parse content
451-
for i, line in enumerate(content):
452-
parts = line.split()
453-
swc_dict["id"][i] = parts[0]
454-
swc_dict["pid"][i] = parts[-1]
455-
swc_dict["voxel"][i] = self.read_voxel(parts[2:5], offset)
456-
return swc_dict
442+
if len(content) > 20:
443+
swc_dict = {
444+
"id": np.zeros((len(content)), dtype=int),
445+
"pid": np.zeros((len(content)), dtype=int),
446+
"voxel": np.zeros((len(content), 3), dtype=np.int32),
447+
"swc_id": swc_id,
448+
}
449+
450+
# Parse content
451+
for i, line in enumerate(content):
452+
parts = line.split()
453+
swc_dict["id"][i] = parts[0]
454+
swc_dict["pid"][i] = parts[-1]
455+
swc_dict["voxel"][i] = self.read_voxel(parts[2:5], offset)
456+
return swc_dict
457+
else:
458+
return None
457459

458460
def process_content(self, content):
459461
"""

0 commit comments

Comments
 (0)