Mercurial > repos > imgteam > colocalization_viz
annotate colocalization_viz.py @ 3:0f8652663a03 draft default tip
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 0500f513ee291ae0f6fad32a0b4fad05cd59cb71"
author | imgteam |
---|---|
date | Sat, 26 Feb 2022 17:13:42 +0000 |
parents | c73332d5c3bb |
children |
rev | line source |
---|---|
1
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
1 import argparse |
0
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
2 import sys |
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
3 |
3
0f8652663a03
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 0500f513ee291ae0f6fad32a0b4fad05cd59cb71"
imgteam
parents:
2
diff
changeset
|
4 import numpy as np |
0f8652663a03
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 0500f513ee291ae0f6fad32a0b4fad05cd59cb71"
imgteam
parents:
2
diff
changeset
|
5 import skimage.color |
0f8652663a03
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 0500f513ee291ae0f6fad32a0b4fad05cd59cb71"
imgteam
parents:
2
diff
changeset
|
6 import skimage.io |
0f8652663a03
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 0500f513ee291ae0f6fad32a0b4fad05cd59cb71"
imgteam
parents:
2
diff
changeset
|
7 from skimage import img_as_uint |
0f8652663a03
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 0500f513ee291ae0f6fad32a0b4fad05cd59cb71"
imgteam
parents:
2
diff
changeset
|
8 from skimage.exposure import equalize_adapthist |
0
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
9 |
3
0f8652663a03
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 0500f513ee291ae0f6fad32a0b4fad05cd59cb71"
imgteam
parents:
2
diff
changeset
|
10 |
0f8652663a03
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 0500f513ee291ae0f6fad32a0b4fad05cd59cb71"
imgteam
parents:
2
diff
changeset
|
11 # TODO make importable by python script |
0
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
12 def readImg(path): |
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
13 img = skimage.io.imread(path) |
1
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
14 |
0
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
15 if len(img.shape) > 2: |
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
16 img = skimage.color.rgb2gray(img) |
1
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
17 img = equalize_adapthist(img, clip_limit=0.03) |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
18 img = img_as_uint(img) |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
19 img = np.reshape(img, [img.shape[0], img.shape[1], 1]) |
0
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
20 return img |
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
21 |
9ddb11b272ee
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
22 |
1
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
23 parser = argparse.ArgumentParser() |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
24 parser.add_argument('input_file1', type=argparse.FileType('r'), default=sys.stdin, help='input file (red)') |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
25 parser.add_argument('input_file2', type=argparse.FileType('r'), default=sys.stdin, help='input file (green)') |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
26 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
27 args = parser.parse_args() |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
28 |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
29 im1 = readImg(args.input_file1.name) |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
30 im2 = readImg(args.input_file2.name) |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
31 res = np.concatenate((im1, im2, np.zeros_like(im1)), axis=-1) |
fc85eb253163
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
imgteam
parents:
0
diff
changeset
|
32 skimage.io.imsave(args.out_file.name, res) |