Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/branch_metric.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"threshold_dis": 2,
"threshold_mode": 1,
"z_scale": 1,
"scale": [1, 1, 1],
"true_positive": 3,
"missed": 4,
"excess": 5
Expand Down
3 changes: 1 addition & 2 deletions config/diadem_metric.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"list_distant_matches": true,
"list_continuations": true,
"find_proper_root": true,
"z_scale": 1,
"TRAJECTORY_NONE": -1.0,
"scale": [1, 1, 1],
"xy_threshold": 1.2,
"z_threshold": 0.0,
"default_xy_path_error_threshold": 0.05,
Expand Down
2 changes: 1 addition & 1 deletion config/length_metric.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"rad_mode": 1,
"rad_threshold": 1,
"len_threshold": 0.2,
"z_scale": 1,
"scale": [1,1,1],
"debug": false
}
2 changes: 1 addition & 1 deletion config/link_metric.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"z_scale": 1
"scale": [1, 1, 1]
}
10 changes: 7 additions & 3 deletions config/schemas/branch_metric_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
"required": [
"threshold_dis",
"threshold_mode",
"z_scale",
"scale",
"true_positive",
"missed",
"excess"
],
"properties": {
"threshold_dis": {"type": "number", "exclusiveMinimum": 0},
"threshold_dis": {"type": "number", "minimum": 0},
"threshold_mode": {"type": "number", "enum": [1, 2]},
"z_scale": {"type": "number","minimum": 0},
"scale": {"type":"array",
"additionalItems": {"type": "number", "minimum": 0},
"minItems": 3,
"maxItems": 3
},
"true_positive": {"type": "integer", "exclusiveMinimum": 0},
"missed": {"type": "integer", "exclusiveMinimum": 0},
"excess": {"type": "integer", "exclusiveMinimum": 0}
Expand Down
7 changes: 5 additions & 2 deletions config/schemas/diadem_metric_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
"list_distant_matches": {"type": "boolean", "default": "false"},
"list_continuations": {"type": "boolean", "default": "false"},
"find_proper_root": {"type": "boolean", "default": "true"},
"z_scale": {"type": "number", "minimum": 0},
"TRAJECTORY_NONE": {"type": "number"},
"scale": {"type":"array",
"additionalItems": {"type": "number", "minimum": 0},
"minItems": 3,
"maxItems": 3
},
"xy_threshold": {"type": "number", "minimum": 0},
"z_threshold": {"type": "number", "minimum": 0},
"default_xy_path_error_threshold": {"type": "number", "minimum": 0},
Expand Down
12 changes: 8 additions & 4 deletions config/schemas/length_metric_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
"rad_mode",
"rad_threshold",
"len_threshold",
"z_scale",
"scale",
"debug"
],
"properties": {
"rad_mode": {"type": "number", "enum": [1,2]},
"rad_threshold": {"type": "number", "exclusiveMinimum": 0},
"len_threshold": {"type": "number", "exclusiveMinimum": 0},
"z_scale": {"type": "number", "minimum": 0},
"rad_threshold": {"type": "number", "minimum": 0},
"len_threshold": {"type": "number", "minimum": 0},
"scale": {"type":"array",
"additionalItems": {"type": "number", "minimum": 0},
"minItems": 3,
"maxItems": 3
},
"debug": {"type": "boolean"}
}
}
8 changes: 6 additions & 2 deletions config/schemas/link_metric_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"title": "link metric schema",
"type": "object",
"required": [
"z_scale"
"scale"
],
"properties": {
"z_scale": {"type": "number", "minimum": 0}
"scale": {"type":"array",
"additionalItems": {"type": "number", "minimum": 0},
"minItems": 3,
"maxItems": 3
}
}
}
8 changes: 0 additions & 8 deletions config/schemas/overlap_clean_schema.json

This file was deleted.

12 changes: 8 additions & 4 deletions config/schemas/ssd_metric_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
"threshold_mode",
"ssd_threshold",
"up_sample_threshold",
"z_scale",
"scale",
"debug"
],
"properties": {
"threshold_mode": {"type": "integer", "enum": [1,2]},
"ssd_threshold": {"type": "number", "exclusiveMinimum": 0},
"up_sample_threshold": {"type": "number", "exclusiveMinimum": 0},
"z_scale": {"type":"number", "minimum": 0},
"ssd_threshold": {"type": "number", "minimum": 0},
"up_sample_threshold": {"type": "number", "minimum": 0},
"scale": {"type":"array",
"additionalItems": {"type": "number", "minimum": 0},
"minItems": 3,
"maxItems": 3
},
"debug": {"type": "boolean"}
}
}
3 changes: 0 additions & 3 deletions config/schemas/up_sample_schema.json

This file was deleted.

4 changes: 2 additions & 2 deletions config/schemas/volume_metric_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"debug"
],
"properties": {
"length_threshold": {"type": "number", "exclusiveMinimum": 0},
"intensity_threshold": {"type": "number", "exclusiveMinimum": 0},
"length_threshold": {"type": "number", "minimum": 0},
"intensity_threshold": {"type": "number", "minimum": 0},
"debug": {"type": "boolean"}
}
}
6 changes: 3 additions & 3 deletions config/ssd_metric.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"threshold_mode": 1,
"ssd_threshold": 1,
"up_sample_threshold": 1.0,
"z_scale": 1,
"ssd_threshold": 2,
"up_sample_threshold": 1,
"scale": [1,1,1],
"debug": false
}
1 change: 0 additions & 1 deletion pyneval/cli/pyneval.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def excute_metric(metric, gold_swc_tree, test_swc_tree, config, detail_dir, outp
out_path=os.path.join(detail_dir, file_name + "precision.swc"),
extra=anno_utils.get_detail_type(metric))


if output_dir:
read_json.save_json(data=result,
json_file_path=os.path.join(output_dir, file_name + ".json"))
Expand Down
6 changes: 3 additions & 3 deletions pyneval/metric/branch_leaf_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ def branch_leaf_metric(gold_swc_tree, test_swc_tree, config):
# read configs
threshold_dis = config["threshold_dis"]
threshold_mode = config["threshold_mode"]
z_scale = config["z_scale"]
scale = config["scale"]

gold_swc_tree.z_rescale(z_scale)
test_swc_tree.z_rescale(z_scale)
gold_swc_tree.rescale(scale)
test_swc_tree.rescale(scale)
# in threshold mode 2, threshold is a multiple of the average length of edges
if threshold_mode == 2:
# length of the entire gold swc forest
Expand Down
6 changes: 3 additions & 3 deletions pyneval/metric/diadem_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,9 @@ def diadem_metric(gold_swc_tree, test_swc_tree, config):
diadem_init()
config_init(config)
diadam_match_utils.diadem_utils_init(config)
z_scale = config["z_scale"]
gold_swc_tree.z_rescale(z_scale)
test_swc_tree.z_rescale(z_scale)
scale = config["scale"]
gold_swc_tree.rescale(scale)
test_swc_tree.rescale(scale)
test_kdtree, test_pos_node_dict = point_match_utils.create_kdtree(test_swc_tree.get_node_list())

t_matches = {}
Expand Down
6 changes: 3 additions & 3 deletions pyneval/metric/length_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def length_metric(gold_swc_tree, test_swc_tree, config):
rad_mode = config["rad_mode"]
rad_threshold = config["rad_threshold"]
len_threshold = config["len_threshold"]
z_scale = config["z_scale"]
scale = config["scale"]
debug = config["debug"]

gold_swc_tree.z_rescale(z_scale)
test_swc_tree.z_rescale(z_scale)
gold_swc_tree.rescale(scale)
test_swc_tree.rescale(scale)
gold_swc_tree.set_node_type_by_topo(root_id=1)
test_swc_tree.set_node_type_by_topo(root_id=5)

Expand Down
6 changes: 3 additions & 3 deletions pyneval/metric/link_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def get_extra_pos_nodes(big_set, subset):


def link_metric(gold_swc_tree, test_swc_tree, config):
z_scale = config['z_scale']
gold_swc_tree.z_rescale(z_scale)
test_swc_tree.z_rescale(z_scale)
scale = config['scale']
gold_swc_tree.rescale(scale)
test_swc_tree.rescale(scale)

gold_list = gold_swc_tree.get_node_list()
test_list = test_swc_tree.get_node_list()
Expand Down
6 changes: 3 additions & 3 deletions pyneval/metric/ssd_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ def ssd_metric(gold_swc_tree: swc_node.SwcTree, test_swc_tree: swc_node.SwcTree,
threshold_mode = config["threshold_mode"]
ssd_threshold = config["ssd_threshold"]
up_sample_threshold = config["up_sample_threshold"]
z_scale = config["z_scale"]
scale = config["scale"]

gold_swc_tree.z_rescale(z_scale)
test_swc_tree.z_rescale(z_scale)
gold_swc_tree.rescale(scale)
test_swc_tree.rescale(scale)
u_gold_swc_tree = re_sample.up_sample_swc_tree(swc_tree=gold_swc_tree,
length_threshold=up_sample_threshold)
u_test_swc_tree = re_sample.up_sample_swc_tree(swc_tree=test_swc_tree,
Expand Down
3 changes: 1 addition & 2 deletions pyneval/metric/utils/diadam_match_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

_2D = "2d"

global TRAJECTORY_NONE
TRAJECTORY_NONE = -1.0
global g_xy_threshold
global g_z_threshold
global g_default_xy_path_error_threshold
Expand All @@ -24,7 +24,6 @@ def diadem_utils_init(config):
global g_default_z_path_error_threshold
global g_local_path_error_threshold

TRAJECTORY_NONE = config["TRAJECTORY_NONE"]
g_xy_threshold = config["xy_threshold"]
g_z_threshold = config["z_threshold"]
g_default_xy_path_error_threshold = config["default_xy_path_error_threshold"]
Expand Down
6 changes: 4 additions & 2 deletions pyneval/model/swc_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,11 @@ def scale(self, sx, sy, sz, adjusting_radius=True):
for tn in niter:
tn.scale(sx, sy, sz, adjusting_radius)

def z_rescale(self, z_scale):
def rescale(self, scale):
for node in self.get_node_list():
node.set_z(node.get_z() * z_scale)
node.set_z(node.get_z() * scale[2])
node.set_y(node.get_y() * scale[1])
node.set_x(node.get_x() * scale[0])

def length(self, force_update=False):
if self._total_length is not None and force_update == False:
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
url='https://github.com/bennieHan/PyNeval.git',
packages=['pyneval', 'pyneval.cli', 'test', 'test.test_model',
'test.test_model.diadem_metric', 'test.test_model.length_metric',
'pyneval.io', 'pyneval.metric', 'pyneval.metric.utils', 'pyneval.metric.utils.klib', 'pyneval.model', 'pyneval.tools', 'pyneval.tools.optimize'],
'pyneval.io', 'pyneval.metric', 'pyneval.metric.utils', 'pyneval.metric.utils.klib', 'pyneval.model',
'pyneval.tools', 'pyneval.tools.optimize'],
py_modules=['pyneval', 'pyneval.cli', 'test', 'test.test_model',
'test.test_model.diadem_metric', 'test.test_model.length_metric',
'pyneval.io', 'pyneval.metric', 'pyneval.metric.utils', 'pyneval.metric.utils.klib', 'pyneval.model', 'pyneval.tools', 'pyneval.tools.optimize'],
'pyneval.io', 'pyneval.metric', 'pyneval.metric.utils', 'pyneval.metric.utils.klib', 'pyneval.model',
'pyneval.tools', 'pyneval.tools.optimize'],
data_files=[('config', glob.glob('config/*.json')),
("config/schemas", glob.glob('config/schemas/*.json'))],
install_requires=[
Expand Down