Skip to content

Commit 55d8de3

Browse files
author
anna-grim
committed
flake8 fixes
1 parent 02256c9 commit 55d8de3

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/segmentation_skeleton_metrics/skeleton_metric.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def load_groundtruth(self, swc_pointer):
156156
def load_fragments(self, swc_pointer):
157157
print("\n(2) Load Fragments")
158158
if swc_pointer:
159-
coords_only = False #not self.save_projections
159+
coords_only = False #not self.save_projections
160160
graph_builder = gutil.GraphBuilder(
161161
anisotropy=self.anisotropy,
162162
coords_only=coords_only,
@@ -551,7 +551,7 @@ def find_graph_from_label(self, label):
551551
for key in self.fragment_graphs:
552552
if label == util.get_segment_id(key):
553553
return self.fragment_graphs[key]
554-
554+
555555
def find_label_intersections(self):
556556
"""
557557
Detects merges between ground truth graphs, namely distinct graphs that
@@ -873,7 +873,6 @@ def physical_dist(self, voxel_1, voxel_2):
873873
xyz_1 = img_util.to_physical(voxel_1, self.anisotropy)
874874
xyz_2 = img_util.to_physical(voxel_2, self.anisotropy)
875875
return distance.euclidean(xyz_1, xyz_2)
876-
877876

878877
def init_counter(self):
879878
"""

src/segmentation_skeleton_metrics/utils/graph_util.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
77
88
"""
9-
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed
9+
from concurrent.futures import as_completed, ProcessPoolExecutor
1010
from random import sample
1111
from scipy.spatial import distance
1212
from tqdm import tqdm
1313

1414
import networkx as nx
1515
import numpy as np
16-
import sys
1716

18-
from segmentation_skeleton_metrics.utils import img_util, swc_util, util
19-
20-
ANISOTROPY = np.array([0.748, 0.748, 1.0])
17+
from segmentation_skeleton_metrics.utils import swc_util, util
2118

2219

2320
class GraphBuilder:
@@ -42,7 +39,9 @@ def __init__(
4239

4340
# Reader
4441
anisotropy = anisotropy if use_anisotropy else (1.0, 1.0, 1.0)
45-
self.swc_reader = swc_util.Reader(anisotropy, selected_ids=selected_ids)
42+
self.swc_reader = swc_util.Reader(
43+
anisotropy, selected_ids=selected_ids
44+
)
4645

4746
def run(self, swc_pointer):
4847
graphs = self._build_graphs_from_swcs(swc_pointer)
@@ -51,13 +50,12 @@ def run(self, swc_pointer):
5150

5251
# --- Build Graphs ---
5352
def _build_graphs_from_swcs(self, swc_pointer):
54-
with ThreadPoolExecutor() as executor:
53+
with ProcessPoolExecutor() as executor:
5554
# Assign processes
5655
processes = list()
5756
swc_dicts = self.swc_reader.load(swc_pointer)
5857
while len(swc_dicts) > 0:
5958
swc_dict = swc_dicts.pop()
60-
#if self._process_swc_dict(swc_dict["swc_id"]):
6159
processes.append(executor.submit(self.to_graph, swc_dict))
6260

6361
# Store results
@@ -97,9 +95,8 @@ def to_graph(self, swc_dict):
9795

9896
# Build graph
9997
if not self.coords_only:
100-
#graph.set_nodes()
98+
graph.set_nodes()
10199
id_lookup = dict()
102-
run_length = 0
103100
for i, id_i in enumerate(swc_dict["id"]):
104101
id_lookup[id_i] = i
105102
if swc_dict["pid"][i] != -1:

src/segmentation_skeleton_metrics/utils/swc_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def read_voxel(self, xyz_str, offset):
352352
xyz = [float(xyz_str[i]) + offset[i] for i in range(3)]
353353
return img_util.to_voxels(xyz, self.anisotropy)
354354

355-
355+
356356
# --- Helpers ---
357357
def to_zipped_swc(zip_writer, graph, color=None):
358358
"""

0 commit comments

Comments
 (0)