initializeEigenanatomy.Rd
InitializeEigenanatomy is a helper function to initialize sparseDecom and sparseDecom2. Can be used to estimate sparseness parameters per eigenvector. The user then only chooses nvecs and optional regularization parameters.
initializeEigenanatomy(initmat, mask = NULL, nreps = 1, smoothing = 0)
initmat | input matrix where rows provide initial vector values. alternatively, this can be an antsImage which contains labeled regions. |
---|---|
mask | mask if available |
nreps | nrepetitions to use |
smoothing | if using an initial label image, optionally smooth each roi |
list is output
Avants BB
mat<-t(replicate(3, rnorm(100)) ) initdf<-initializeEigenanatomy( mat ) # produces a mask dmat<-replicate(100, rnorm(20)) # data matrix svdv = t( svd( mat, nu=0, nv=10 )$v ) ilist = matrixToImages( svdv, initdf$mask ) eseg = eigSeg( initdf$mask, ilist, TRUE ) eanat<-sparseDecom( dmat, inmask=initdf$mask, sparseness=0, smooth=0, initializationList=ilist, cthresh=0, nvecs=length(ilist) ) initdf2<-initializeEigenanatomy( mat, nreps=2 ) eanat<-sparseDecom( dmat, inmask=initdf$mask, sparseness=0, smooth=0, z=-0.5, initializationList=initdf2$initlist, cthresh=0, nvecs=length(initdf2$initlist) ) # now a regression eanatMatrix<-eanat$eigenanatomyimages # 'averages' loosely speaking anyway myEigenanatomyRegionAverages<-dmat %*% t( eanatMatrix ) dependentvariable<-rnorm( nrow(dmat) ) summary(lm( dependentvariable ~ myEigenanatomyRegionAverages ))#> #> Call: #> lm(formula = dependentvariable ~ myEigenanatomyRegionAverages) #> #> Residuals: #> Min 1Q Median 3Q Max #> -1.5471 -0.7817 0.1856 0.7615 1.2461 #> #> Coefficients: (1 not defined because of singularities) #> Estimate Std. Error t value Pr(>|t|) #> (Intercept) -0.005678 0.256690 -0.022 0.983 #> myEigenanatomyRegionAverages1 -0.733521 2.057987 -0.356 0.727 #> myEigenanatomyRegionAverages2 0.558452 1.969882 0.283 0.781 #> myEigenanatomyRegionAverages3 -2.957976 14.121203 -0.209 0.837 #> myEigenanatomyRegionAverages4 3.282327 14.377400 0.228 0.823 #> myEigenanatomyRegionAverages5 NA NA NA NA #> myEigenanatomyRegionAverages6 -0.408361 0.482746 -0.846 0.412 #> #> Residual standard error: 1.056 on 14 degrees of freedom #> Multiple R-squared: 0.09468, Adjusted R-squared: -0.2287 #> F-statistic: 0.2928 on 5 and 14 DF, p-value: 0.909 #>nvox<-1000 dmat<-replicate(nvox, rnorm(20)) dmat2<-replicate(30, rnorm(20)) mat<-t(replicate(3, rnorm(nvox)) ) initdf<-initializeEigenanatomy( mat ) eanat<-sparseDecom2( inmatrix = list(dmat,dmat2), inmask=list(initdf$mask,NA), sparseness=c( -0.1, -0.2 ), smooth=0, initializationList=initdf$initlist, cthresh=c(0,0), nvecs=length(initdf$initlist), priorWeight = 0.1 )