annotate colocalization_viz.py @ 0:9174e8eaa1e1 draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
author thomaswollmann
date Wed, 16 Jan 2019 15:33:42 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
1 import skimage.io
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
2 import skimage.color
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
3 import numpy as np
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
4 import os
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
5 import sys
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
6 import warnings
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
7
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
8 #TODO make importable by python script
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
9
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
10 args = sys.argv
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
11
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
12 def readImg(path):
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
13 img = skimage.io.imread(path)
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
14 if len(img.shape) > 2:
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
15 img = skimage.color.rgb2gray(img)
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
16 img = np.expand_dims(img > 0, 3)
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
17 return img
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
18
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
19 im1 = readImg(args[1])
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
20 im2 = readImg(args[2])
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
21 res = np.concatenate((im1, im2, np.zeros_like(im1)), axis=2) * 1.0
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
22
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
23 with warnings.catch_warnings():
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
24 warnings.simplefilter("ignore")
9174e8eaa1e1 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit d93e1dd276027cfc3fb518236110395a23d96f66
thomaswollmann
parents:
diff changeset
25 skimage.io.imsave(args[3], res)