Mercurial > repos > imgteam > imagecoordinates_flipaxis
annotate 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 |
rev | line source |
---|---|
0
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
1 import argparse |
3
984b342d03a6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/imagecoordinates_flipaxis/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
2
diff
changeset
|
2 |
0
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
3 import pandas as pd |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
4 |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
5 |
3
984b342d03a6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/imagecoordinates_flipaxis/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
2
diff
changeset
|
6 def imagecoordinates_flipyaxis(input_file, output_file, image_height, offset=[0, 0]): |
984b342d03a6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/imagecoordinates_flipaxis/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
2
diff
changeset
|
7 df = pd.read_csv(input_file, sep='\t') |
0
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
8 |
3
984b342d03a6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/imagecoordinates_flipaxis/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
2
diff
changeset
|
9 x = df.copy().y # create copy instead of view |
984b342d03a6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/imagecoordinates_flipaxis/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
2
diff
changeset
|
10 df.y = image_height - (df.x + 1) + offset[1] # since maximal y index = height-1 |
1
d0960e1b25a8
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit da043bdec956714abb0fa82f278931bbe1a6d41d
imgteam
parents:
0
diff
changeset
|
11 df.x = x + offset[0] |
0
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
12 df.to_csv(output_file, sep="\t", index=False) |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
13 |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
14 |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
15 if __name__ == "__main__": |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
16 parser = argparse.ArgumentParser() |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
17 parser.add_argument('input_file', type=argparse.FileType('r'), help='original file') |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
18 parser.add_argument('out_file_str', type=str, help='string of output file name') |
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
19 parser.add_argument('image_height', type=int, help='height of image') |
1
d0960e1b25a8
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit da043bdec956714abb0fa82f278931bbe1a6d41d
imgteam
parents:
0
diff
changeset
|
20 parser.add_argument('offset_x', type=int, help='offset in x direction (width)', default=0) |
d0960e1b25a8
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit da043bdec956714abb0fa82f278931bbe1a6d41d
imgteam
parents:
0
diff
changeset
|
21 parser.add_argument('offset_y', type=int, help='offset in y direction (height)', default=0) |
0
5a210baa2ff1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff
changeset
|
22 args = parser.parse_args() |
1
d0960e1b25a8
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit da043bdec956714abb0fa82f278931bbe1a6d41d
imgteam
parents:
0
diff
changeset
|
23 imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, args.image_height, [args.offset_x, args.offset_y]) |