Mercurial > repos > imgteam > detection_viz
changeset 4:99433164b593 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/detection_viz/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author | imgteam |
---|---|
date | Mon, 13 Nov 2023 22:11:04 +0000 |
parents | cb2d9de888a1 |
children | |
files | detection_viz.py detection_viz.xml |
diffstat | 2 files changed, 32 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/detection_viz.py Wed Dec 18 05:02:11 2019 -0500 +++ b/detection_viz.py Mon Nov 13 22:11:04 2023 +0000 @@ -1,13 +1,13 @@ import argparse -import sys -import os import csv - + import matplotlib +import matplotlib.pyplot as plt +import skimage.io + + matplotlib.use('Agg') -import matplotlib.pyplot as plt -import skimage.io def plot_circles(file_name, ax, color, stroke_size, radius): resfile = open(file_name, 'rb') @@ -17,11 +17,12 @@ ax.add_patch(circ) resfile.close() + def detection_viz(input_file, output_file, tp=None, fn=None, fp=None, stroke_size=3, circle_radius=50): img = skimage.io.imread(input_file) fig = plt.figure(figsize=(40, 40)) - ax = fig.add_axes([0, 0, 1, 1]) + ax = fig.add_axes([0, 0, 1, 1]) ax.axis('off') plt.imshow(img) @@ -34,11 +35,12 @@ fig.canvas.print_png(output_file, dpi=1800) + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('input_file', type=argparse.FileType('r'), help='original file') # output file should not be of type argparse.FileType('w') sine it is created immediately in this case which leads to an error in renaming - parser.add_argument('out_file_str', type=str, help='string of output file name') + parser.add_argument('out_file_str', type=str, help='string of output file name') parser.add_argument('--tp', dest='input_tp_file', type=argparse.FileType('r'), help='input TP file') parser.add_argument('--fn', dest='input_fn_file', type=argparse.FileType('r'), help='input FN file') parser.add_argument('--fp', dest='input_fp_file', type=argparse.FileType('r'), help='input FP file') @@ -46,14 +48,14 @@ parser.add_argument('--circle_radius', dest='circle_radius', type=float, default=50, help='circle radius') args = parser.parse_args() - tp=None + tp = None if args.input_tp_file: - tp=args.input_tp_file.name - fn=None + tp = args.input_tp_file.name + fn = None if args.input_fn_file: - fn=args.input_fn_file.name - fp=None + fn = args.input_fn_file.name + fp = None if args.input_fp_file: - fp=args.input_fp_file.name + fp = args.input_fp_file.name detection_viz(args.input_file.name, args.out_file_str, tp=tp, fn=fn, fp=fp, stroke_size=args.thickness, circle_radius=args.circle_radius)
--- a/detection_viz.xml Wed Dec 18 05:02:11 2019 -0500 +++ b/detection_viz.xml Mon Nov 13 22:11:04 2023 +0000 @@ -1,5 +1,11 @@ -<tool id="ip_detection_viz" name="Detection Visualization" version="0.3"> - <description>Detection Visualization</description> +<tool id="ip_detection_viz" name="Visualize detections" version="0.3-2"> + <description></description> + <edam_operations> + <edam_operation>operation_3443</edam_operation> + </edam_operations> + <xrefs> + <xref type="bio.tools">galaxy_image_analysis</xref> + </xrefs> <requirements> <requirement type="package" version="0.14.2">scikit-image</requirement> <requirement type="package" version="3.0.2">matplotlib</requirement> @@ -61,9 +67,15 @@ <tests> <test> <param name="input" value="sample.png"/> - <param name="tp_option.display" value="false"/> - <param name="fn_option.display" value="false"/> - <param name="fp_option.display" value="false"/> + <conditional name="tp_option"> + <param name="display" value="false"/> + </conditional> + <conditional name="fn_option"> + <param name="display" value="false"/> + </conditional> + <conditional name="fp_option"> + <param name="display" value="false"/> + </conditional> <output name="output" value="out.png" ftype="png"/> </test> </tests>