annotate imagecoordinates_flipaxis.py @ 0:c7a4d8a8b55e draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
author imgteam
date Wed, 20 Mar 2019 12:05:45 -0400
parents
children fb6b557a2937
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
1 import argparse
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
2 import pandas as pd
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
3
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
4
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
5 def imagecoordinates_flipyaxis(input_file, output_file, image_height):
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
6 df = pd.read_csv(input_file, sep='\t')
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
7
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
8 x = df.copy().y # create copy instead of view
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
9 df.y = image_height-(df.x + 1) # since maximal y index = height-1
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
10 df.x = x
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
11 df.to_csv(output_file, sep="\t", index=False)
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
12
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
13
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
14
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
15 if __name__ == "__main__":
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
16 parser = argparse.ArgumentParser()
c7a4d8a8b55e 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')
c7a4d8a8b55e 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')
c7a4d8a8b55e 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', help='height of image')
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
20 parser.add_argument('image_height', type=int, help='height of image')
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
21 args = parser.parse_args()
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
22 imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, args.image_height)
c7a4d8a8b55e planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit 67eaf2b9a9ee1bfed14afba33007ef595890400c
imgteam
parents:
diff changeset
23 # imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, int(args.image_height))