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 19, 2024
1 parent 8764cd9 commit 2e7d489
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/deep_neurographs/utils/swc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
)
)

Expand All @@ -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.
Expand Down

0 comments on commit 2e7d489

Please sign in to comment.