Computes the density of values of an image with the option for a mask.

# S3 method for nifti
density(x, ..., mask)

# S3 method for anlz
density(x, ..., mask)

Arguments

x

Object of class nifti

...

Arguments passed to density.default

mask

object to subset the image. If missing, then all values of the image are plotted.

Value

Output of density

Examples

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.   :0.0000622  
#>  1st Qu.: 0.6136   1st Qu.:0.0056362  
#>  Median : 1.6660   Median :0.1065839  
#>  Mean   : 1.6660   Mean   :0.2373038  
#>  3rd Qu.: 2.7184   3rd Qu.:0.4242115  
#>  Max.   : 3.7708   Max.   :0.7737313  
density(img)
#> 
#> Call:
#> 	density.default(x = x)
#> 
#> Data: x (1000 obs.);	Bandwidth 'bw' = 0.2202
#> 
#>        x                 y            
#>  Min.   :-3.7790   Min.   :0.0000205  
#>  1st Qu.:-1.8370   1st Qu.:0.0048685  
#>  Median : 0.1051   Median :0.0647384  
#>  Mean   : 0.1051   Mean   :0.1286028  
#>  3rd Qu.: 2.0472   3rd Qu.:0.2439546  
#>  Max.   : 3.9892   Max.   :0.3948873  

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.   :0.0000622  
#>  1st Qu.: 0.6136   1st Qu.:0.0056362  
#>  Median : 1.6660   Median :0.1065839  
#>  Mean   : 1.6660   Mean   :0.2373038  
#>  3rd Qu.: 2.7184   3rd Qu.:0.4242115  
#>  Max.   : 3.7708   Max.   :0.7737313  
density(as.anlz(img))
#> 
#> Call:
#> 	density.default(x = x)
#> 
#> Data: x (1000 obs.);	Bandwidth 'bw' = 0.2202
#> 
#>        x                 y            
#>  Min.   :-3.7790   Min.   :0.0000205  
#>  1st Qu.:-1.8370   1st Qu.:0.0048685  
#>  Median : 0.1051   Median :0.0647384  
#>  Mean   : 0.1051   Mean   :0.1286028  
#>  3rd Qu.: 2.0472   3rd Qu.:0.2439546  
#>  Max.   : 3.9892   Max.   :0.3948873