Computes the density of values of an image with the option for a mask.
Object of class nifti
Arguments passed to density.default
object to subset the image. If missing, then all values of the image are plotted.
Output of density
img = nifti(array(rnorm(10^3), dim = rep(10, 3)))
mask = img > 0
density(img, mask = mask)
#>
#> Call:
#> density.default(x = x)
#>
#> Data: x (490 obs.); Bandwidth 'bw' = 0.1474
#>
#> x y
#> Min. :-0.4389 Min. :6.166e-05
#> 1st Qu.: 0.6135 1st Qu.:5.602e-03
#> Median : 1.6660 Median :1.065e-01
#> Mean : 1.6660 Mean :2.371e-01
#> 3rd Qu.: 2.7184 3rd Qu.:4.238e-01
#> Max. : 3.7708 Max. :7.731e-01
density(img)
#>
#> Call:
#> density.default(x = x)
#>
#> Data: x (1000 obs.); Bandwidth 'bw' = 0.2202
#>
#> x y
#> Min. :-3.7790 Min. :2.037e-05
#> 1st Qu.:-1.8370 1st Qu.:4.861e-03
#> Median : 0.1051 Median :6.467e-02
#> Mean : 0.1051 Mean :1.285e-01
#> 3rd Qu.: 2.0472 3rd Qu.:2.437e-01
#> Max. : 3.9892 Max. :3.945e-01
density(as.anlz(img), mask = mask)
#>
#> Call:
#> density.default(x = x)
#>
#> Data: x (490 obs.); Bandwidth 'bw' = 0.1474
#>
#> x y
#> Min. :-0.4389 Min. :6.166e-05
#> 1st Qu.: 0.6135 1st Qu.:5.602e-03
#> Median : 1.6660 Median :1.065e-01
#> Mean : 1.6660 Mean :2.371e-01
#> 3rd Qu.: 2.7184 3rd Qu.:4.238e-01
#> Max. : 3.7708 Max. :7.731e-01
density(as.anlz(img))
#>
#> Call:
#> density.default(x = x)
#>
#> Data: x (1000 obs.); Bandwidth 'bw' = 0.2202
#>
#> x y
#> Min. :-3.7790 Min. :2.037e-05
#> 1st Qu.:-1.8370 1st Qu.:4.861e-03
#> Median : 0.1051 Median :6.467e-02
#> Mean : 0.1051 Mean :1.285e-01
#> 3rd Qu.: 2.0472 3rd Qu.:2.437e-01
#> Max. : 3.9892 Max. :3.945e-01