bspace <- BrainSpace(c(16,16,16), spacing=c(1,1,1))
grid <- indexToGrid(bspace, 1:(16*16*16))
kres <- kmeans(grid, centers=10)
mask <- BrainVolume(rep(1, 16^3),bspace)
clusvol <- ClusteredBrainVolume(mask, kres$cluster)
Run the code above in your browser using DataLab