From 2e7d489f974643b653c6017ca85c74a5e8fe0562 Mon Sep 17 00:00:00 2001 From: Anna Grim <108307071+anna-grim@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:55:11 -0800 Subject: [PATCH] Update swc_util.py --- src/deep_neurographs/utils/swc_util.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/deep_neurographs/utils/swc_util.py b/src/deep_neurographs/utils/swc_util.py index 3a23174..5905dca 100644 --- a/src/deep_neurographs/utils/swc_util.py +++ b/src/deep_neurographs/utils/swc_util.py @@ -168,15 +168,12 @@ def load_from_local_zip(self, zip_path): that swc file. """ - with ZipFile(zip_path, "r") as zip: - swc_files = [f for f in zip.namelist() if f.endswith(".swc")] + with ZipFile(zip_path, "r") as zip_file: swc_dicts = list() + swc_files = [f for f in zip_file.namelist() if f.endswith(".swc")] for f in tqdm(swc_files, desc="Loading Fragments"): - # Check whether to store content - content = utils.read_zip(zip, f).splitlines() - if len(content) > self.min_size - 10: - result = self.parse(content) - result["swc_id"] = util.get_swc_id(path) + result = self.load_from_zipped_file(zip_file, f) + if result: swc_dicts.append(result) return swc_dicts @@ -240,7 +237,7 @@ def load_from_cloud_zip(self, zip_content): for f in util.list_files_in_zip(zip_content): threads.append( executor.submit( - self.load_from_cloud_zipped_file, zip_file, f + self.load_from_zipped_file, zip_file, f ) ) @@ -252,7 +249,7 @@ def load_from_cloud_zip(self, zip_content): swc_dicts.append(result) return swc_dicts - def load_from_cloud_zipped_file(self, zip_file, path): + def load_from_zipped_file(self, zip_file, path): """ Reads swc file stored at "path" which points to a file in a zip.