From ab621eb71d12d68dd771507685b96b718faa3b47 Mon Sep 17 00:00:00 2001 From: zhanghan Date: Thu, 10 Jun 2021 11:54:57 +0800 Subject: [PATCH] add config documentation --- config/.config_documentation.md | 49 +++++++++++++++++++ .../skeletonize.schema.json | 42 ---------------- .../test1best.json | 20 -------- .../test3best.json | 20 -------- .../test4best.json | 20 -------- .../tmp/readme.txt | 2 - pyneval/cli/pyneval.py | 29 +++++------ pyneval/io/read_swc.py | 2 +- 8 files changed, 63 insertions(+), 121 deletions(-) create mode 100644 config/.config_documentation.md delete mode 100644 config/fake_reconstruction_configs/skeletonize.schema.json delete mode 100644 config/fake_reconstruction_configs/test1best.json delete mode 100644 config/fake_reconstruction_configs/test3best.json delete mode 100644 config/fake_reconstruction_configs/test4best.json diff --git a/config/.config_documentation.md b/config/.config_documentation.md new file mode 100644 index 0000000..a43ea97 --- /dev/null +++ b/config/.config_documentation.md @@ -0,0 +1,49 @@ +## How to set configs +### 1. SSD metric +|parameter|type|description| +|---|:---:|---| +|threshold_mode|int|mode(1 or 2):
1 means static threshold, final threshold equal to ssd_threshold.
2 means dynamic threshold, final threshold equal to ssd_threshold * src_node.radius| +|ssd_threshold|float| For each node in gold standard tree, ssd find its closest node in test tree. If the distance of these two nodes is less than ssd_threshold, this node is successfully reconstructed and it will contribute to recall or precision, otherwise the distance will be contribute to ssd score. | +|up_sample_threshold|float|up sample rate of gold standard and test test tree. Smaller sample rate threshold means higher sample rate, denser upsampled tree. +|scale|tuple(1*3)| scaling of gold and test tree in x,y,z coordinates. +|debug|boolean|show debug information or not| + +### 2. length metric +|parameter|type|description| +|---|:---:|---| +|rad_mode|int|mode(1 or 2):
1 means static threshold, final threshold equal to rad_threshold.
2 means dynamic threshold, final threshold equal to rad_threshold * src_node.radius| +|rad_threshold|float|This threshold measures the distance between nodes on gold standard tree and the closest edge on test tree. +|len_threshold|float|This threshold measures the difference between edges on gold standard tree and their corresponding trace on test tree. +|scale|tuple(1*3)|scaling of gold and test tree in x,y,z coordinates. | +|debug|boolean|show debug information or not| + +### 3. branch metric +|parameter|type|description| +|---|:---:|---| +|threshold_dis|float| If the distance of two nodes on two trees is less than this threshold, they are probably matched. +|scale|tuple(1*3)| scaling of gold and test tree in x,y,z coordinates.| +|true_positive_type|int| Identify the type of true positive nodes in swc. (This and following two parameters may affect the color of nodes in visualization program) | +|false_negative_type|int| Identify the type of false negative nodes in swc. | +|false_positive_type|int| Identify the type of false positive nodes in swc. | + +### 4. diadem metric +|parameter|type|description| +|---|:---:|---| +|weight_mode|int|Choose different map between degree and weight.
(a). WEIGHT_DEGREE = 1
weight is the degree of node
(b). WEIGHT_SQRT_DEGREE = 2
weight is the sqrt of degree
(c). WEIGHT_DEGREE_HARMONIC_MEAN = 3
weight is the harmonic mean of degree of left and right son.
(d). WEIGHT_PATH_LENGTH = 4
weight is the length of path from node to its root
| +|remove_spur|boolean| remove spur or not | +|count_excess_nodes|boolean| count excess nodes in test tree or not | +|list_miss|boolean| list missed nodes(reconstruct failed nodes) or not| +|list_distant_matches|boolean| distant match means the parent of a branch is not a matched node, but ancestor is. If this branch is matched, they are distant matched| +|list_continuations|boolean| Continuation refer to nodes with only one one. List this kind of nodes or not. | +|find_proper_root|boolean| find a pair of matched node as roots of two trees or not | +|scale|tuple(1*3)|scaling of gold and test tree in x,y,z coordinates.| +|xy_threshold|float| node distance threshold in xy surface.| +|z_threshold|float| node distance threshold in z axis. | +|default_xy_path_error_threshold|float| path length difference threshold in xy surface. +|default_z_path_error_threshold|float| path length difference threshold in z axis. | +|debug|boolean| show debug information or not | + +### 5. link metric +|parameter|type|description| +|---|:---:|---| +|scale|tuple(1*3)|scaling of gold and test tree in x,y,z coordinates.| diff --git a/config/fake_reconstruction_configs/skeletonize.schema.json b/config/fake_reconstruction_configs/skeletonize.schema.json deleted file mode 100644 index 714945c..0000000 --- a/config/fake_reconstruction_configs/skeletonize.schema.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "title": "Skeletonization Schema", - "type": "object", - "properties": { - "downsampleInterval": { - "description": "Downsampling the stack before running skeletonization", - "type": "array", - "minItems": 3, - "maxItems": 3, - "items": {"type": "integer"} - }, - "minimalLength": { - "description": "Minimal length of the resulted branches", - "type": "integer", - "minimum": 0 - }, - "keepingSingleObject": { - "description": "Keep an isolated object or not even if it is too small or short", - "type": "boolean" - }, - "rebase": { - "description": "Reset the starting point to a terminal point?", - "type": "boolean" - }, - "fillingHole": { - "description": "Reset the starting point to a terminal point?", - "type": "boolean" - }, - "maximalDistance": { - "description": "Maximum distance to connect isolated branches.", - "type": "number", - "minimum": 0 - }, - "minimalObjectSize": { - "description": "Minimal size of objects to skeletonize.", - "type": "integer", - "minimum": 0 - } - } -} - - diff --git a/config/fake_reconstruction_configs/test1best.json b/config/fake_reconstruction_configs/test1best.json deleted file mode 100644 index bea0f61..0000000 --- a/config/fake_reconstruction_configs/test1best.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "trace": { - "tag": "trace configuration", - "default": { - "minimalScoreAuto": 0.42039409, - "minimalScoreManual": 1, - "minimalScoreSeed": 1, - "minimalScore2d": 0.59725383, - "refit": false, - "spTest": false, - "crossoverTest": false, - "tuneEnd": true, - "edgePath": false, - "enhanceMask": true, - "seedMethod": 1, - "recover": 1, - "maxEucDist": 10 - } - } -} diff --git a/config/fake_reconstruction_configs/test3best.json b/config/fake_reconstruction_configs/test3best.json deleted file mode 100644 index 1caea01..0000000 --- a/config/fake_reconstruction_configs/test3best.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "trace": { - "tag": "trace configuration", - "default": { - "minimalScoreAuto": 0.39791192, - "minimalScoreManual": 1, - "minimalScoreSeed": 98459854, - "minimalScore2d": 0.263612, - "refit": false, - "spTest": false, - "crossoverTest": false, - "tuneEnd": true, - "edgePath": false, - "enhanceMask": true, - "seedMethod": 1, - "recover": 1, - "maxEucDist": 10 - } - } -} diff --git a/config/fake_reconstruction_configs/test4best.json b/config/fake_reconstruction_configs/test4best.json deleted file mode 100644 index 769bc1e..0000000 --- a/config/fake_reconstruction_configs/test4best.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "trace": { - "tag": "trace configuration", - "default": { - "minimalScoreAuto": 0.45898798, - "minimalScoreManual": 0.74510809, - "minimalScoreSeed": 0.82922591, - "minimalScore2d": 0.0, - "refit": false, - "spTest": false, - "crossoverTest": false, - "tuneEnd": true, - "edgePath": false, - "enhanceMask": true, - "seedMethod": 1, - "recover": 1, - "maxEucDist": 10 - } - } -} diff --git a/config/fake_reconstruction_configs/tmp/readme.txt b/config/fake_reconstruction_configs/tmp/readme.txt index b489f54..e69de29 100644 --- a/config/fake_reconstruction_configs/tmp/readme.txt +++ b/config/fake_reconstruction_configs/tmp/readme.txt @@ -1,2 +0,0 @@ -This folder is used to place the temporary reconstruct configs. -Dont' delete this folder. \ No newline at end of file diff --git a/pyneval/cli/pyneval.py b/pyneval/cli/pyneval.py index 2be81f0..e44720c 100644 --- a/pyneval/cli/pyneval.py +++ b/pyneval/cli/pyneval.py @@ -107,38 +107,39 @@ def read_parameters(): parser.add_argument( "--gold", "-G", - help="path to the gold-standard SWC file", - required=True + help="path of the gold standard SWC file", + required=False ) parser.add_argument( "--test", "-T", - help="a list of SWC files for evaluation", - required=True, + help="a list of reconstructed SWC files or folders for evaluation", + required=False, nargs='*', ) parser.add_argument( "--metric", "-M", help="metric choice: " + get_metric_summary(False) + ".", - required=True + required=False ) parser.add_argument( "--output", "-O", - help="metric output path, including different scores of the metric", + help="output path of metric results, output file is in json format with different scores of the metric", required=False ) parser.add_argument( "--detail", "-D", - help="detail \"type\" marked for gold/test SWC file, including marked swc trees", + help="output path of detail metric result, swc format presented.\n" + "identify different type according to metric result for each node", required=False ) parser.add_argument( "--config", "-C", - help="custom configuration file for the specified metric", + help="path of custom configuration file for the specified metric", required=False ) parser.add_argument( @@ -166,10 +167,9 @@ def set_configs(abs_dir, args): # argument: metric metric = get_root_metric(args.metric) if not metric: - print("\nERROR: The metric '{}' is not supported.".format(args.metric)) - print("\nValid options for --metric:\n") - print(get_metric_summary(True)) - return 1 + raise Exception("\nERROR: The metric '{}' is not supported.".format(args.metric) + + "\nValid options for --metric:\n" + + get_metric_summary(True)) # argument: test test_swc_paths = [os.path.join(abs_dir, path) for path in args.test] @@ -245,10 +245,7 @@ def run(): abs_dir = os.path.abspath("") init(abs_dir) - try: - args = read_parameters() - except: - raise Exception("[Error: ] Error in reading parameters") + args = read_parameters() gold_swc_tree, test_swc_trees, metric, output_dir, detail_dir, config, is_debug = set_configs(abs_dir, args) for test_swc_tree in test_swc_trees: diff --git a/pyneval/io/read_swc.py b/pyneval/io/read_swc.py index ce30f63..63bb7b3 100644 --- a/pyneval/io/read_swc.py +++ b/pyneval/io/read_swc.py @@ -17,7 +17,7 @@ def read_swc_trees(swc_file_paths, tree_name_dict=None): swc_tree_list = [] if os.path.isfile(swc_file_paths): if not (swc_file_paths[-4:] == ".swc" or swc_file_paths[-4:] == ".SWC"): - print(swc_file_paths + "is not a tif file") + print(swc_file_paths + "is not a swc file") return None swc_tree = SwcTree() swc_tree.load(swc_file_paths)