Mercurial > repos > thomaswollmann > color_deconvolution
annotate color_deconvolution.py @ 4:a35141611262 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit 2a8ca0fcc48586b1fcb3ae5ca42c6f97f72c588e
author | thomaswollmann |
---|---|
date | Sat, 11 Feb 2017 17:29:02 -0500 |
parents | 3b2341714506 |
children | b1a42e192603 |
rev | line source |
---|---|
0
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
1 import argparse |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
2 import sys |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
3 import warnings |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
4 import numpy as np |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
5 import skimage.io |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
6 import skimage.color |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
7 import skimage.util |
2
3b2341714506
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit 92068c64f9a6c3cf59f756b9efc2d561196c6873
thomaswollmann
parents:
0
diff
changeset
|
8 from sklearn.decomposition import PCA, NMF, FastICA, FactorAnalysis |
0
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
9 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
10 convOptions = { |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
11 'hed2rgb' : lambda img_raw: skimage.color.hed2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
12 'hsv2rgb' : lambda img_raw: skimage.color.hsv2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
13 'lab2lch' : lambda img_raw: skimage.color.lab2lch(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
14 'lab2rgb' : lambda img_raw: skimage.color.lab2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
15 'lab2xyz' : lambda img_raw: skimage.color.lab2xyz(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
16 'lch2lab' : lambda img_raw: skimage.color.lch2lab(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
17 'luv2rgb' : lambda img_raw: skimage.color.luv2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
18 'luv2xyz' : lambda img_raw: skimage.color.luv2xyz(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
19 'rgb2hed' : lambda img_raw: skimage.color.rgb2hed(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
20 'rgb2hsv' : lambda img_raw: skimage.color.rgb2hsv(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
21 'rgb2lab' : lambda img_raw: skimage.color.rgb2lab(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
22 'rgb2luv' : lambda img_raw: skimage.color.rgb2luv(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
23 'rgb2rgbcie' : lambda img_raw: skimage.color.rgb2rgbcie(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
24 'rgb2xyz' : lambda img_raw: skimage.color.rgb2xyz(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
25 #'rgb2ycbcr' : lambda img_raw: skimage.color.rgb2ycbcr(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
26 #'rgb2yiq' : lambda img_raw: skimage.color.rgb2yiq(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
27 #'rgb2ypbpr' : lambda img_raw: skimage.color.rgb2ypbpr(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
28 #'rgb2yuv' : lambda img_raw: skimage.color.rgb2yuv(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
29 #'rgba2rgb' : lambda img_raw: skimage.color.rgba2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
30 'rgbcie2rgb' : lambda img_raw: skimage.color.rgbcie2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
31 'xyz2lab' : lambda img_raw: skimage.color.xyz2lab(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
32 'xyz2luv' : lambda img_raw: skimage.color.xyz2luv(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
33 'xyz2rgb' : lambda img_raw: skimage.color.xyz2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
34 #'ycbcr2rgb' : lambda img_raw: skimage.color.ycbcr2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
35 #'yiq2rgb' : lambda img_raw: skimage.color.yiq2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
36 #'ypbpr2rgb' : lambda img_raw: skimage.color.ypbpr2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
37 #'yuv2rgb' : lambda img_raw: skimage.color.yuv2rgb(img_raw), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
38 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
39 'rgb_from_hed' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_hed), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
40 'rgb_from_hdx' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_hdx), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
41 'rgb_from_fgx' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_fgx), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
42 'rgb_from_bex' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_bex), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
43 'rgb_from_rbd' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_rbd), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
44 'rgb_from_gdx' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_gdx), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
45 'rgb_from_hax' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_hax), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
46 'rgb_from_bro' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_bro), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
47 'rgb_from_bpx' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_bpx), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
48 'rgb_from_ahx' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_ahx), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
49 'rgb_from_hpx' : lambda img_raw: skimage.color.combine_stains(img_raw, skimage.color.rgb_from_hpx), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
50 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
51 'hed_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.hed_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
52 'hdx_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.hdx_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
53 'fgx_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.fgx_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
54 'bex_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.bex_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
55 'rbd_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.rbd_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
56 'gdx_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.gdx_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
57 'hax_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.hax_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
58 'bro_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.bro_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
59 'bpx_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.bpx_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
60 'ahx_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.ahx_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
61 'hpx_from_rgb' : lambda img_raw: skimage.color.separate_stains(img_raw, skimage.color.hpx_from_rgb), |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
62 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
63 'pca' : lambda img_raw: np.reshape(PCA(n_components=3).fit_transform(np.reshape(img_raw, [-1, img_raw.shape[2]])), |
2
3b2341714506
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit 92068c64f9a6c3cf59f756b9efc2d561196c6873
thomaswollmann
parents:
0
diff
changeset
|
64 [img_raw.shape[0],img_raw.shape[1],-1]), |
3b2341714506
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit 92068c64f9a6c3cf59f756b9efc2d561196c6873
thomaswollmann
parents:
0
diff
changeset
|
65 'nmf' : lambda img_raw: np.reshape(NMF(n_components=3, init='nndsvda').fit_transform(np.reshape(img_raw, [-1, img_raw.shape[2]])), |
3b2341714506
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit 92068c64f9a6c3cf59f756b9efc2d561196c6873
thomaswollmann
parents:
0
diff
changeset
|
66 [img_raw.shape[0],img_raw.shape[1],-1]), |
3b2341714506
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit 92068c64f9a6c3cf59f756b9efc2d561196c6873
thomaswollmann
parents:
0
diff
changeset
|
67 'ica' : lambda img_raw: np.reshape(FastICA(n_components=3).fit_transform(np.reshape(img_raw, [-1, img_raw.shape[2]])), |
3b2341714506
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit 92068c64f9a6c3cf59f756b9efc2d561196c6873
thomaswollmann
parents:
0
diff
changeset
|
68 [img_raw.shape[0],img_raw.shape[1],-1]), |
3b2341714506
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit 92068c64f9a6c3cf59f756b9efc2d561196c6873
thomaswollmann
parents:
0
diff
changeset
|
69 'fa' : lambda img_raw: np.reshape(FactorAnalysis(n_components=3).fit_transform(np.reshape(img_raw, [-1, img_raw.shape[2]])), |
0
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
70 [img_raw.shape[0],img_raw.shape[1],-1]) |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
71 } |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
72 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
73 parser = argparse.ArgumentParser() |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
74 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
75 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
76 parser.add_argument('conv_type', choices=convOptions.keys(), help='conversion type') |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
77 args = parser.parse_args() |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
78 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
79 img_in = skimage.io.imread(args.input_file.name)[:,:,0:3] |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
80 res = convOptions[args.conv_type](img_in) |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
81 res[res<-1]=-1 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
82 res[res>1]=1 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
83 |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
84 with warnings.catch_warnings(): |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
85 warnings.simplefilter("ignore") |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
86 res = skimage.util.img_as_uint(res) #Attention: precision loss |
101d1347abd9
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/color-deconvolution commit b405a7bf071e77b80e314e4a5c340af71fd63adf
thomaswollmann
parents:
diff
changeset
|
87 skimage.io.imsave(args.out_file.name, res, plugin='tifffile') |