RNotes | EBImage | Features

Basic | Haralick | Moment | Shape


The function computeFeatures.basic computes spatial-independent statistics on pixel intensities:

All basic features have a prefix “b.”.

Intensity values range from 0.0 to 1.0.

library(EBImage)
computeFeatures.basic(x, ref, properties=FALSE, basic.quantiles=c(0.01, 0.05, 0.5, 0.95, 0.99), xs, ...)

List properties of basic features

feature.properties <- computeFeatures.basic(properties=TRUE)
feature.properties
    name translation.invariant rotation.invariant
1 b.mean                  TRUE               TRUE
2   b.sd                  TRUE               TRUE
3  b.mad                  TRUE               TRUE
4 b.q001                  TRUE               TRUE
5 b.q005                  TRUE               TRUE
6  b.q05                  TRUE               TRUE
7 b.q095                  TRUE               TRUE
8 b.q099                  TRUE               TRUE

Load and segment nucleus

par(mfrow=c(1,2))
y <- readImage(system.file("images", "nuclei.tif", package="EBImage"))[,,1]
x <- thresh(y, 10, 10, 0.05)
x <- opening(x, makeBrush(5, shape='disc'))
x <- bwlabel(x)

display(y, title="Cell nuclei")
display(x, title="Segmented nuclei")

Compute basic features

basicFeatures <- computeFeatures.basic(x, y)
str(basicFeatures)
 num [1:76, 1:8] 0.242 0.443 0.704 0.491 0.479 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:76] "1" "2" "3" "4" ...
  ..$ : chr [1:8] "b.mean" "b.sd" "b.mad" "b.q001" ...
options(digits=4)
basicFeatures
   b.mean    b.sd    b.mad  b.q001  b.q005  b.q05 b.q095 b.q099
1  0.2420 0.09380 0.104654 0.11765 0.12431 0.2196 0.4078 0.4324
2  0.4430 0.13157 0.165702 0.19490 0.23922 0.4353 0.6314 0.7020
3  0.7036 0.17765 0.197680 0.33137 0.43922 0.6863 1.0000 1.0000
4  0.4911 0.09920 0.122096 0.27608 0.32157 0.4941 0.6392 0.6667
5  0.4785 0.10341 0.116282 0.27843 0.31373 0.4745 0.6508 0.6862
6  0.5325 0.10349 0.110468 0.29498 0.34157 0.5451 0.6745 0.6972
7  0.5986 0.13028 0.145353 0.35686 0.36863 0.6078 0.8039 0.8636
8  0.5119 0.12828 0.156981 0.28741 0.32157 0.5020 0.7216 0.7636
9  0.8511 0.16673 0.148260 0.39898 0.52294 0.9000 1.0000 1.0000
10 0.3467 0.04532 0.046513 0.24314 0.26667 0.3529 0.4118 0.4353
11 0.3372 0.03322 0.043606 0.28235 0.28235 0.3373 0.3898 0.4112
12 0.4447 0.10004 0.116282 0.24824 0.28039 0.4549 0.5902 0.6267
13 0.2117 0.03004 0.031978 0.15855 0.16922 0.2098 0.2655 0.2689
14 0.8434 0.16642 0.174424 0.47992 0.52529 0.8824 1.0000 1.0000
15 0.9404 0.12030 0.000000 0.58776 0.64863 1.0000 1.0000 1.0000
16 0.9477 0.11028 0.000000 0.55843 0.67843 1.0000 1.0000 1.0000
17 0.5659 0.10683 0.116282 0.33882 0.37255 0.5804 0.7216 0.7522
18 0.9275 0.13133 0.000000 0.53820 0.61569 1.0000 1.0000 1.0000
19 0.8436 0.16779 0.151167 0.46408 0.52549 0.8980 1.0000 1.0000
20 0.3459 0.08596 0.075584 0.22855 0.23922 0.3294 0.5137 0.6176
21 0.5548 0.12992 0.154074 0.29769 0.34510 0.5529 0.7586 0.8196
22 0.6047 0.14690 0.168609 0.28957 0.35373 0.6157 0.8212 0.8549
23 0.4190 0.08128 0.087212 0.25557 0.28961 0.4196 0.5608 0.5961
24 0.4061 0.06637 0.075584 0.26275 0.29412 0.4118 0.5031 0.5255
25 0.7648 0.18721 0.252914 0.39196 0.44706 0.7667 1.0000 1.0000
26 0.6152 0.14791 0.180238 0.32549 0.37333 0.6118 0.8486 0.9111
27 0.7132 0.14610 0.174424 0.41459 0.46275 0.7373 0.9059 0.9444
28 0.6625 0.15268 0.191866 0.37208 0.44706 0.6510 0.9216 0.9687
29 0.5224 0.08422 0.098840 0.36941 0.38824 0.5412 0.6353 0.6502
30 0.7483 0.17761 0.215122 0.40075 0.45882 0.7608 1.0000 1.0000
31 0.6634 0.14001 0.156981 0.36667 0.41961 0.6863 0.8657 0.9176
32 0.7793 0.17370 0.209308 0.39318 0.47843 0.8078 1.0000 1.0000
33 0.6446 0.15683 0.168609 0.31765 0.37255 0.6588 0.8902 0.9529
34 0.7355 0.17928 0.220936 0.38404 0.45216 0.7373 1.0000 1.0000
35 0.9110 0.15298 0.000000 0.48306 0.57294 1.0000 1.0000 1.0000
36 0.6067 0.13167 0.145353 0.36173 0.39294 0.6039 0.8267 0.8696
37 0.8405 0.16494 0.168609 0.47451 0.52392 0.8863 1.0000 1.0000
38 0.4717 0.08552 0.087212 0.27059 0.31373 0.4824 0.5931 0.6182
39 0.4265 0.08336 0.093026 0.26667 0.28902 0.4275 0.5647 0.5942
40 0.8467 0.15251 0.174424 0.47843 0.56471 0.8824 1.0000 1.0000
41 0.4876 0.10337 0.116282 0.26471 0.31667 0.4863 0.6480 0.7049
42 0.5470 0.13760 0.156981 0.27741 0.31255 0.5686 0.7651 0.7903
43 0.9359 0.12857 0.000000 0.52659 0.61569 1.0000 1.0000 1.0000
44 0.9129 0.13505 0.000000 0.48784 0.60784 1.0000 1.0000 1.0000
45 0.3018 0.05912 0.058141 0.21647 0.22941 0.2902 0.4118 0.4388
46 0.9154 0.13496 0.000000 0.53682 0.60118 1.0000 1.0000 1.0000
47 0.5394 0.11862 0.127911 0.30525 0.34980 0.5373 0.7412 0.7961
48 0.7146 0.11824 0.098840 0.41341 0.48235 0.7490 0.8678 0.8863
49 0.7370 0.13221 0.127911 0.42502 0.49412 0.7608 0.9375 0.9882
50 0.4757 0.10085 0.116282 0.28106 0.31765 0.4745 0.6378 0.6627
51 0.3885 0.07878 0.095933 0.21482 0.24706 0.3941 0.5020 0.5181
52 0.4029 0.07395 0.084305 0.24576 0.27235 0.4098 0.5098 0.5420
53 0.6488 0.14984 0.162795 0.33475 0.39216 0.6471 0.8902 0.9216
54 0.5405 0.11174 0.139539 0.33725 0.36039 0.5412 0.7137 0.7436
55 0.8823 0.15587 0.005814 0.47980 0.56471 0.9961 1.0000 1.0000
56 0.3939 0.09808 0.081398 0.23529 0.27078 0.3686 0.5998 0.6337
57 0.7394 0.16331 0.186052 0.39608 0.45490 0.7451 1.0000 1.0000
58 0.5010 0.11385 0.136632 0.27427 0.31373 0.5118 0.6667 0.6904
59 0.4056 0.08940 0.093026 0.21914 0.25961 0.4000 0.5639 0.5983
60 0.7883 0.18559 0.244193 0.40000 0.45882 0.8196 1.0000 1.0000
61 0.5951 0.11405 0.110468 0.32078 0.38431 0.6078 0.7725 0.8078
62 0.4777 0.08873 0.087212 0.29243 0.32098 0.4863 0.6118 0.6443
63 0.5528 0.11658 0.133725 0.30835 0.35294 0.5569 0.7255 0.7701
64 0.3696 0.07891 0.093026 0.22400 0.24314 0.3725 0.4902 0.5174
65 0.2618 0.04546 0.046513 0.16471 0.18039 0.2667 0.3333 0.3569
66 0.5967 0.13053 0.127911 0.35463 0.39235 0.5843 0.8390 0.8980
67 0.5514 0.10868 0.110468 0.32580 0.36863 0.5608 0.7278 0.7490
68 0.3363 0.05553 0.052327 0.21569 0.23529 0.3412 0.4275 0.4507
69 0.5696 0.12181 0.139539 0.31263 0.35922 0.5922 0.7412 0.7619
70 0.4065 0.07290 0.081398 0.27059 0.29412 0.4078 0.5294 0.5759
71 0.3128 0.05811 0.058141 0.17263 0.21569 0.3137 0.4057 0.4392
72 0.8720 0.16014 0.055234 0.46647 0.56059 0.9627 1.0000 1.0000
73 0.5737 0.12449 0.156981 0.32941 0.37275 0.5765 0.7451 0.7662
74 0.4289 0.08613 0.093026 0.24314 0.27451 0.4353 0.5561 0.6000
75 0.3133 0.04606 0.046513 0.20392 0.22353 0.3176 0.3725 0.3882
76 0.1355 0.03449 0.040699 0.09078 0.09314 0.1275 0.1863 0.1910

Correlations of basic features

correlationMatrix <- cor(basicFeatures)
correlationMatrix
##        b.mean   b.sd     b.mad    b.q001   b.q005  b.q05 b.q095 b.q099
## b.mean 1.0000 0.8187  0.130102  0.965111 0.982894 0.9966 0.9643 0.9463
## b.sd   0.8187 1.0000  0.609574  0.681544 0.714602 0.7864 0.9278 0.9322
## b.mad  0.1301 0.6096  1.000000 -0.007986 0.006149 0.0681 0.3527 0.3782
## b.q001 0.9651 0.6815 -0.007986  1.000000 0.989190 0.9670 0.8934 0.8731
## b.q005 0.9829 0.7146  0.006149  0.989190 1.000000 0.9840 0.9167 0.8955
## b.q05  0.9966 0.7864  0.068097  0.967027 0.984035 1.0000 0.9436 0.9225
## b.q095 0.9643 0.9278  0.352670  0.893360 0.916726 0.9436 1.0000 0.9954
## b.q099 0.9463 0.9322  0.378235  0.873109 0.895515 0.9225 0.9954 1.0000

Heatmaps of correlation matrix

Color-coded display of correlation matrix

library(gplots)         # heatmap.2
library(RColorBrewer)   # brewer.pal
heatmap.2(correlationMatrix, dendrogram="none", Rowv=FALSE, symm=TRUE,
          cellnote=format(round(correlationMatrix,2)),
          main="Basic Features",
          scale="none", col=brewer.pal(11,"RdBu"), margins=c(9,9), trace="none")

Dendrograms show relationships in correlation matrix

heatmap.2(correlationMatrix, key=FALSE,
          cellnote=format(round(correlationMatrix,2)),
          main="Basic Features",
          scale="none", col=brewer.pal(11,"RdBu"), margins=c(9,9), trace="none")

A diverging palette from RColorBrewer is used for the heatmaps since correlations can range from -1 to +1. In the RdBu pallete, red is low and blue is high.


packageVersion("EBImage")
## [1] '4.8.2'
packageVersion("gplots")
## [1] '2.16.0'
packageVersion("RColorBrewer")
## [1] '1.1.2'

efg
2015-01-22 2315