Learn R Programming

ANTsR (version 0.4.0)

ripmmarc: Rotation Invariant Patch-based Multi-Modality Analysis aRChitecture

Description

Patch-based and rotation invariant image decomposition. This is similar to patch-based dictionary learning in N-dimensions. Warning: there may be an overlow/underflow error in the C++ underlying this function that appears to occur when insufficient patchSamples are selected.

Usage

ripmmarc(img, mask, patchRadius = 3, patchSamples = 1000,
  patchVarEx = 0.95, meanCenter = FALSE, canonicalFrame = NA,
  evecBasis = NA, rotationInvariant = TRUE, regressProjections = TRUE,
  verbose = FALSE)

Arguments

img

Image to decompose

mask

Binary mask defining regions in which to decompose.

patchRadius

Scalar radius defining the patch size.

patchSamples

Scalar defining the number of random patches to sample.

patchVarEx

Scalar defining the target variance explained. If this is greater than one, then it defines the number of eigenvectors. Otherwise, it defines the target variance explained.

meanCenter

boolean whether we mean center the patches.

canonicalFrame

pass in an existing canonicalFrame.

evecBasis

pass in an existing eigenvector basis.

rotationInvariant

boolean sets whether patches are rotationInvariant.

regressProjections

boolean return reconstruction parameters.

verbose

boolean sets verbosity.

Value

list including the canonical frame, the matrix basis, the patches for the full image, the projection coefficients for the full image, the variance explained and a reconstructed image.

Examples

Run this code
# NOT RUN {
img <- antsImageRead( getANTsRData( "r16" ) )
msk <- getMask( img ) %>% iMath("ME",1)
lap = iMath( img, "Laplacian", 2 )
mskTestTrain = antsImageClone( msk )
mskTestTrain[1:128,1:256]=2
mskTestTrain = mskTestTrain * msk
pr = 2
nv = 15
ripped <- ripmmarc( img, thresholdImage(mskTestTrain,2,2), patchRadius=pr,
  patchSamples=5000, patchVarEx=nv, rotationInvariant = FALSE )
ipatches = ripped$imagePatchMat
ibasis   = scale( ripped$basisMat )
k = 2233
kk = lm( ipatches[k,] ~ t( ibasis[1:10,] ) )
rimg = ripmmarcBasisImage( ripped$canonicalFrame, ipatches[k,] )
# plot( rimg, doCropping=F )
bimg = ripmmarcBasisImage( ripped$canonicalFrame, ibasis[5,] )
# plot( bimg, doCropping=F )

rippedTest <- ripmmarc( img, thresholdImage(mskTestTrain,1,1), patchRadius=pr,
  evecBasis = ripped$basisMat, canonicalFrame = ripped$canonicalFrame,
  patchSamples=500, patchVarEx=nv, rotationInvariant = FALSE )
lapTrainVox = lap[ mskTestTrain == 2 ]
lapTestVox = lap[ mskTestTrain == 1 ]
mydftr = data.frame( lap=lapTrainVox, t1feats=ripped$evecCoeffs )
mydfte = data.frame( lap=lapTestVox, t1feats=rippedTest$evecCoeffs )
mdl = lm( lap ~ . , data = mydftr )
preds = predict( mdl, newdata = mydfte )
# cor.test( preds, mydfte$lap )

# }

Run the code above in your browser using DataLab