Mercurial > repos > imgteam > points2binaryimage
annotate points2binaryimage.py @ 5:5411384e5e1d draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 6fc9ab8db9ef72ac7ded30d7373768feeae9390d
author | imgteam |
---|---|
date | Fri, 27 Sep 2024 17:41:14 +0000 |
parents | 4c0f16fb9f8d |
children |
rev | line source |
---|---|
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
1 import argparse |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
2 import os |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
3 import warnings |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
4 from typing import List |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
5 |
1
90385ec28b34
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
0
diff
changeset
|
6 import numpy as np |
90385ec28b34
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
0
diff
changeset
|
7 import pandas as pd |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
8 import scipy.ndimage as ndi |
1
90385ec28b34
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
0
diff
changeset
|
9 import skimage.io |
90385ec28b34
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
0
diff
changeset
|
10 |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
11 |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
12 def find_column(df: pd.DataFrame, candidates: List[str]) -> str: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
13 """ |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
14 Returns the column name present in `df` and the list of `candidates`. |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
15 |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
16 Raises: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
17 KeyError: If there is no candidate column name present in `df`, or more than one. |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
18 """ |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
19 intersection = frozenset(df.columns) & frozenset(candidates) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
20 if len(intersection) == 0: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
21 raise KeyError(f'No such column: {", ".join(candidates)}') |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
22 elif len(intersection) > 1: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
23 raise KeyError(f'The column names {", ".join(intersection)} are ambiguous') |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
24 else: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
25 return next(iter(intersection)) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
26 |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
27 |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
28 def points2binaryimage(point_file, out_file, shape, has_header=False, swap_xy=False, bg_value=0, fg_value=0xffff): |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
29 |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
30 img = np.full(shape, dtype=np.uint16, fill_value=bg_value) |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
31 if os.path.exists(point_file) and os.path.getsize(point_file) > 0: |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
32 |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
33 # Read the tabular file with information from the header |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
34 if has_header: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
35 df = pd.read_csv(point_file, delimiter='\t') |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
36 pos_x_column = find_column(df, ['pos_x', 'POS_X']) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
37 pos_y_column = find_column(df, ['pos_y', 'POS_Y']) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
38 pos_x_list = df[pos_x_column].round().astype(int) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
39 pos_y_list = df[pos_y_column].round().astype(int) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
40 assert len(pos_x_list) == len(pos_y_list) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
41 try: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
42 radius_column = find_column(df, ['radius', 'RADIUS']) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
43 radius_list = df[radius_column] |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
44 except KeyError: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
45 radius_list = [0] * len(pos_x_list) |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
46 |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
47 # Read the tabular file without header |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
48 else: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
49 df = pd.read_csv(point_file, header=None, delimiter='\t') |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
50 pos_x_list = df[0].round().astype(int) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
51 pos_y_list = df[1].round().astype(int) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
52 assert len(pos_x_list) == len(pos_y_list) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
53 radius_list = [0] * len(pos_x_list) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
54 |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
55 # Optionally swap the coordinates |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
56 if swap_xy: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
57 pos_x_list, pos_y_list = pos_y_list, pos_x_list |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
58 |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
59 # Perform the rasterization |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
60 for y, x, radius in zip(pos_y_list, pos_x_list, radius_list): |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
61 |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
62 if y < 0 or x < 0 or y >= shape[0] or x >= shape[1]: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
63 raise IndexError(f'The point x={x}, y={y} exceeds the bounds of the image (width: {shape[1]}, height: {shape[0]})') |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
64 |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
65 if radius > 0: |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
66 mask = np.ones(shape, dtype=bool) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
67 mask[y, x] = False |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
68 mask = (ndi.distance_transform_edt(mask) <= radius) |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
69 img[mask] = fg_value |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
70 else: |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
71 img[y, x] = fg_value |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
72 |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
73 else: |
1
90385ec28b34
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
0
diff
changeset
|
74 raise Exception("{} is empty or does not exist.".format(point_file)) # appropriate built-in error? |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
75 |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
76 with warnings.catch_warnings(): |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
77 warnings.simplefilter("ignore") |
1
90385ec28b34
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
0
diff
changeset
|
78 skimage.io.imsave(out_file, img, plugin='tifffile') # otherwise we get problems with the .dat extension |
90385ec28b34
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
0
diff
changeset
|
79 |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
80 |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
81 if __name__ == "__main__": |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
82 parser = argparse.ArgumentParser() |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
83 parser.add_argument('point_file', type=argparse.FileType('r'), help='point file') |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
84 parser.add_argument('out_file', type=str, help='out file (TIFF)') |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
85 parser.add_argument('shapex', type=int, help='shapex') |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
86 parser.add_argument('shapey', type=int, help='shapey') |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
87 parser.add_argument('--has_header', dest='has_header', default=False, help='set True if point file has header') |
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
88 parser.add_argument('--swap_xy', dest='swap_xy', default=False, help='Swap X and Y coordinates') |
0
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
89 |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
90 args = parser.parse_args() |
dd513c9f5230
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/points2binaryimage/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
91 |
1
90385ec28b34
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
imgteam
parents:
0
diff
changeset
|
92 # TOOL |
4
4c0f16fb9f8d
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit a3c77a79db469c9ad18b666f2c64d6e8f573945f
imgteam
parents:
1
diff
changeset
|
93 points2binaryimage(args.point_file.name, args.out_file, (args.shapey, args.shapex), has_header=args.has_header, swap_xy=args.swap_xy) |