Mercurial > repos > imgteam > imagecoordinates_flipaxis
comparison imagecoordinates_flipaxis.py @ 3:984b342d03a6 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/imagecoordinates_flipaxis/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author | imgteam |
---|---|
date | Mon, 13 Nov 2023 22:11:12 +0000 |
parents | f8f1100d0701 |
children |
comparison
equal
deleted
inserted
replaced
2:f8f1100d0701 | 3:984b342d03a6 |
---|---|
1 import argparse | 1 import argparse |
2 | |
2 import pandas as pd | 3 import pandas as pd |
3 | 4 |
4 | 5 |
5 def imagecoordinates_flipyaxis(input_file, output_file, image_height, offset=[0,0]): | 6 def imagecoordinates_flipyaxis(input_file, output_file, image_height, offset=[0, 0]): |
6 df = pd.read_csv(input_file, sep='\t') | 7 df = pd.read_csv(input_file, sep='\t') |
7 | 8 |
8 x = df.copy().y # create copy instead of view | 9 x = df.copy().y # create copy instead of view |
9 df.y = image_height-(df.x + 1) + offset[1] # since maximal y index = height-1 | 10 df.y = image_height - (df.x + 1) + offset[1] # since maximal y index = height-1 |
10 df.x = x + offset[0] | 11 df.x = x + offset[0] |
11 df.to_csv(output_file, sep="\t", index=False) | 12 df.to_csv(output_file, sep="\t", index=False) |
12 | |
13 | 13 |
14 | 14 |
15 if __name__ == "__main__": | 15 if __name__ == "__main__": |
16 parser = argparse.ArgumentParser() | 16 parser = argparse.ArgumentParser() |
17 parser.add_argument('input_file', type=argparse.FileType('r'), help='original file') | 17 parser.add_argument('input_file', type=argparse.FileType('r'), help='original file') |
19 parser.add_argument('image_height', type=int, help='height of image') | 19 parser.add_argument('image_height', type=int, help='height of image') |
20 parser.add_argument('offset_x', type=int, help='offset in x direction (width)', default=0) | 20 parser.add_argument('offset_x', type=int, help='offset in x direction (width)', default=0) |
21 parser.add_argument('offset_y', type=int, help='offset in y direction (height)', default=0) | 21 parser.add_argument('offset_y', type=int, help='offset in y direction (height)', default=0) |
22 args = parser.parse_args() | 22 args = parser.parse_args() |
23 imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, args.image_height, [args.offset_x, args.offset_y]) | 23 imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, args.image_height, [args.offset_x, args.offset_y]) |
24 # imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, int(args.image_height)) |