Find Center of Gravity of Image from FSL
fslcog(img, mm = TRUE, verbose = TRUE, ts = FALSE)
Object of class nifti, or path of file
Logical if the center of gravity (COG) would be in mm (default TRUE
)
or voxels (FALSE
)
(logical) print out command before running
(logical) is the series a timeseries (4D), invoking -t
option
Vector of length 3 unless ts option invoked
FSL uses a 0-based indexing system, which will give you a different
answer compared to cog
, but fslcog(img, mm = FALSE) +1
should be relatively close to cog(img)
if (have.fsl()){
x = array(rnorm(1e6), dim = c(100, 100, 100))
img = nifti(x, dim= c(100, 100, 100),
datatype = convert.datatype()$FLOAT32, cal.min = min(x),
cal.max = max(x), pixdim = rep(1, 4))
fslcog(img)
}
#> fslstats "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpKzob0N/file857516df4cd1.nii.gz" -c
#> [1] 49.48578 49.51181 49.50401