Description Usage Arguments Value Author(s) Examples
View source: R/SpatCorrImage.R
This function is to compute voxel-wise spatially varying correlation between two groups of 3D images
1 | comp_images_corr(img_1, img_2, mask = NULL)
|
img_1 |
a matrix of multiple images |
img_2 |
a matrix of multiple images |
mask |
a vector of mask taking logical values. The default is NULL. |
coords |
a matrix of spatial coords of the images. The default is NULL. |
a vector of the correlation values
Jian Kang <jiankang@umich.edu>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | set.seed(1000)
dim_img = c(10,10,10)
n = 50
grids <- lapply(1:3,function(i) seq(-round(dim_img[i]/2)+1,round(dim_img[i]/2),length=dim_img[i]))
coords <- expand.grid(grids)
num_voxels <- prod(dim_img)
img_1 <- array(rnorm(num_voxels*n),dim=c(num_voxels,n))
img_2 <- array(rnorm(num_voxels*n),dim=c(num_voxels,n))
cor_region <- create_sphere_mask(grids,radius=2)
cor_region_list <- array(c(cor_region),dim=dim(img_2))
img_2 <- ifelse(cor_region_list,img_1+rnorm(num_voxels*n,sd=0.5),img_2)
mask <- create_sphere_mask(grids,radius=4)
cor_map <- comp_images_corr(img_1,img_2,c(mask))
plot_3D_image_slices(array(cor_map,dim=dim_img),grids,c(-2,2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.