# HG changeset patch # User imgteam # Date 1553097967 14400 # Node ID 5a210baa2ff15fb9c6a7f4deaa8a63524eee2e1a planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c diff -r 000000000000 -r 5a210baa2ff1 imagecoordinates_flipaxis.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagecoordinates_flipaxis.py Wed Mar 20 12:06:07 2019 -0400 @@ -0,0 +1,23 @@ +import argparse +import pandas as pd + + +def imagecoordinates_flipyaxis(input_file, output_file, image_height): + df = pd.read_csv(input_file, sep='\t') + + x = df.copy().y # create copy instead of view + df.y = image_height-(df.x + 1) # since maximal y index = height-1 + df.x = x + df.to_csv(output_file, sep="\t", index=False) + + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('input_file', type=argparse.FileType('r'), help='original file') + parser.add_argument('out_file_str', type=str, help='string of output file name') + # parser.add_argument('image_height', help='height of image') + parser.add_argument('image_height', type=int, help='height of image') + args = parser.parse_args() + imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, args.image_height) + # imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, int(args.image_height)) diff -r 000000000000 -r 5a210baa2ff1 imagecoordinates_flipaxis.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagecoordinates_flipaxis.xml Wed Mar 20 12:06:07 2019 -0400 @@ -0,0 +1,30 @@ + + Switches the axes of an image and flips the y axis. + + pandas + + + + + + + + + + + + + + + + + + + Makes x the horizontal axis (left to right) and y the vertical axis (bottom to top), + like in a coordinate system. + + 10.1016/j.jbiotec.2017.07.019 + + diff -r 000000000000 -r 5a210baa2ff1 test-data/out2.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/out2.tsv Wed Mar 20 12:06:07 2019 -0400 @@ -0,0 +1,7 @@ +x y +4 495 +104 494 +204 493 +34 492 +4 491 +4 490 diff -r 000000000000 -r 5a210baa2ff1 test-data/table.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/table.tsv Wed Mar 20 12:06:07 2019 -0400 @@ -0,0 +1,7 @@ +x y +4 4 +5 104 +6 204 +7 34 +8 4 +9 4