Mercurial > repos > imgteam > superdsm
annotate run-superdsm.py @ 1:700ae37e5c69 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
author | imgteam |
---|---|
date | Thu, 06 Jul 2023 00:01:18 +0000 |
parents | 1b0fc671187f |
children | 244f67290d28 |
rev | line source |
---|---|
0
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
1 """ |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
2 Copyright 2023 Leonid Kostrykin, Biomedical Computer Vision Group, Heidelberg University. |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
3 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
4 Distributed under the MIT license. |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
5 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
6 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
7 """ |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
8 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
9 import argparse |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
10 import imghdr |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
11 import os |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
12 import pathlib |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
13 import shutil |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
14 import tempfile |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
15 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
16 import ray |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
17 import superdsm.automation |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
18 import superdsm.io |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
19 import superdsm.render |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
20 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
21 |
1
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
22 hyperparameters = [ |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
23 ('AF_scale', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
24 ('c2f_region_analysis/min_atom_radius', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
25 ('c2f_region_analysis_min_norm_energy_improvement', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
26 ('c2f_region_analysis_max_atom_norm_energy', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
27 ('c2f_region_analysis_max_cluster_marker_irregularity', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
28 ('dsm_alpha', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
29 ('dsm_AF_alpha', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
30 ('global_energy_minimization_betai', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
31 ('global_energy_minimization_AF_beta', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
32 ('postprocess_mask_max_distance', int), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
33 ('postprocess_mask_stdamp', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
34 ('postprocess_max_norm_energy', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
35 ('postprocess_min_contrast', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
36 ('postprocess_min_object_radius', float), |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
37 ] |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
38 |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
39 |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
40 def get_param_name(key): |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
41 return key.replace('/', '_') |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
42 |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
43 |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
44 def create_config(args): |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
45 cfg = superdsm.config.Config() |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
46 for key, _ in hyperparameters: |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
47 value = getattr(args, get_param_name(key)) |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
48 if value is not None: |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
49 cfg[key] = value |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
50 return cfg |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
51 |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
52 |
0
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
53 if __name__ == "__main__": |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
54 parser = argparse.ArgumentParser(description='Segmentation of cell nuclei in 2-D fluorescence microscopy images') |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
55 parser.add_argument('image', help='Path to the input image') |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
56 parser.add_argument('cfg', help='Path to the file containing the configuration') |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
57 parser.add_argument('masks', help='Path to the file containing the segmentation masks') |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
58 parser.add_argument('overlay', help='Path to the file containing the overlay of the segmentation results') |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
59 parser.add_argument('seg_border', type=int) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
60 parser.add_argument('slots', type=int) |
1
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
61 for key, ptype in hyperparameters: |
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
62 parser.add_argument('--' + get_param_name(key), type=ptype, default=None) |
0
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
63 args = parser.parse_args() |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
64 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
65 if args.slots >= 2: |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
66 num_threads_per_process = 2 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
67 num_processes = args.slots // num_threads_per_process |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
68 else: |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
69 num_threads_per_process = 1 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
70 num_processes = 1 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
71 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
72 os.environ['MKL_NUM_THREADS'] = str(num_threads_per_process) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
73 os.environ['OPENBLAS_NUM_THREADS'] = str(num_threads_per_process) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
74 os.environ['MKL_DEBUG_CPU_TYPE'] = '5' |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
75 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
76 ray.init(num_cpus=num_processes, log_to_driver=True) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
77 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
78 with tempfile.TemporaryDirectory() as tmpdirname: |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
79 tmpdir = pathlib.Path(tmpdirname) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
80 img_ext = imghdr.what(args.image) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
81 img_filepath = tmpdir / f'input.{img_ext}' |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
82 shutil.copy(str(args.image), img_filepath) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
83 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
84 pipeline = superdsm.pipeline.create_default_pipeline() |
1
700ae37e5c69
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
85 cfg = create_config(args) |
0
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
86 img = superdsm.io.imread(img_filepath) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
87 data, cfg, _ = superdsm.automation.process_image(pipeline, cfg, img) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
88 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
89 with open(args.cfg, 'w') as fp: |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
90 cfg.dump_json(fp) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
91 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
92 overlay = superdsm.render.render_result_over_image(data, border_width=args.seg_border, normalize_img=False) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
93 superdsm.io.imwrite(args.overlay, overlay) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
94 |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
95 masks = superdsm.render.rasterize_labels(data) |
1b0fc671187f
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
96 superdsm.io.imwrite(args.masks, masks) |