Mercurial > repos > imgteam > superdsm
annotate run-superdsm.py @ 1:680b866ba043 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
| author | imgteam |
|---|---|
| date | Thu, 06 Jul 2023 00:01:07 +0000 |
| parents | 55b3a064638a |
| children |
| rev | line source |
|---|---|
|
0
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
1 """ |
|
55b3a064638a
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. |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
3 |
|
55b3a064638a
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. |
|
55b3a064638a
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 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
6 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
7 """ |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
8 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
9 import argparse |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
10 import imghdr |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
11 import os |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
12 import pathlib |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
13 import shutil |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
14 import tempfile |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
15 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
16 import ray |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
17 import superdsm.automation |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
18 import superdsm.io |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
19 import superdsm.render |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
20 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
21 |
|
1
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
22 hyperparameters = [ |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
23 ('AF_scale', float), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
28 ('dsm_alpha', float), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
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), |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
37 ] |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
38 |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
39 |
|
680b866ba043
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): |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
41 return key.replace('/', '_') |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
42 |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
43 |
|
680b866ba043
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): |
|
680b866ba043
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() |
|
680b866ba043
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: |
|
680b866ba043
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)) |
|
680b866ba043
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: |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
49 cfg[key] = value |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
50 return cfg |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
51 |
|
680b866ba043
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 7db4b765fa5a1f526cc94cd1f65d963d1e047b27
imgteam
parents:
0
diff
changeset
|
52 |
|
0
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
53 if __name__ == "__main__": |
|
55b3a064638a
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') |
|
55b3a064638a
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') |
|
55b3a064638a
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') |
|
55b3a064638a
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') |
|
55b3a064638a
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') |
|
55b3a064638a
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) |
|
55b3a064638a
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
680b866ba043
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: |
|
680b866ba043
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
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
63 args = parser.parse_args() |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
64 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
65 if args.slots >= 2: |
|
55b3a064638a
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 |
|
55b3a064638a
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 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
68 else: |
|
55b3a064638a
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 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
70 num_processes = 1 |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
71 |
|
55b3a064638a
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) |
|
55b3a064638a
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) |
|
55b3a064638a
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' |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
75 |
|
55b3a064638a
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) |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
77 |
|
55b3a064638a
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: |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
79 tmpdir = pathlib.Path(tmpdirname) |
|
55b3a064638a
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) |
|
55b3a064638a
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}' |
|
55b3a064638a
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) |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
83 |
|
55b3a064638a
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
680b866ba043
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
55b3a064638a
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) |
|
55b3a064638a
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) |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
88 |
|
55b3a064638a
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: |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
90 cfg.dump_json(fp) |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
91 |
|
55b3a064638a
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) |
|
55b3a064638a
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) |
|
55b3a064638a
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/superdsm/ commit 4d66ff6e8a2a842e44e8d0d7102dfb3ac78dca7e
imgteam
parents:
diff
changeset
|
94 |
|
55b3a064638a
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) |
|
55b3a064638a
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) |
