ANTsX / ANTsR

R interface to the ANTs biomedical image processing library
https://antsx.github.io/ANTsR
Apache License 2.0
127 stars 35 forks source link

Add new transforms to antsRegistration #219

Closed ntustison closed 6 years ago

ntustison commented 6 years ago

I'd like to be able to align the image geometric centers or centers of mass only which would be useful for the deep learning stuff we're doing over at ANTsRNetExamples. It seems that the easiest route would be to add those two options to antsRegistration. Equivalent would be something like

   antsRegistration -d 3 -v 1 \
      -o ${outputPrefix} \
      -r [$template,$image,0] \
      -t Translation[0.1] \
      -m MI[$template,$image,1,32] \
      -c 0 -s 0 -f 1

Would this be okay? If so, I can make a pull request. Or, if not, would there be a better route for doing this?

Thanks, Nick

cookpa commented 6 years ago

I think this would be useful. Perhaps it would be good to add to antsAI?

ntustison commented 6 years ago

Thanks @cookpa . That would be fine with me. It doesn't look like antsAI is in ANTsR just yet although the old antsAffineInitializer is there. @stnava---would you prefer this route?

By the way, @cookpa , you should check out the BrainExtraction example we have over at ANTsRNetExamples if you're interested. I've been training the model on the ~1100 subjects we used for our cross-sectional cortical thickness paper and you can do brain extraction in < 10 seconds on a laptop where the majority of time is spent in antsRegistration( ..., transform type = "QuickRigid" ... ) .

cookpa commented 6 years ago

Very cool, I will look at it.

ntustison commented 6 years ago

Regardless, @cookpa , I'll go ahead and add that to antsAI. I think that is a really good idea.

ntustison commented 6 years ago

https://github.com/ANTsX/ANTs/commit/27f8e546a1a91f3edf8069d45497cfebadea46f7

stnava commented 6 years ago

another alternative:

fi<-antsImageRead( getANTsRData("r16"))
com1<-getCenterOfMass( fi )  # intensity
com2<-getCenterOfMass( fi * 0 + 1 ) # geometric

and then build/apply antsrTransforms

fi<-antsImageRead( getANTsRData("r16"))
mi<-antsImageRead( getANTsRData("r64"))
comf<-getCenterOfMass( fi )  # intensity
comm<-getCenterOfMass( mi )  # intensity
tx = createAntsrTransform( type="Rigid2DTransform", center=comf,translation=comm-comf )
wimg = applyAntsrTransformToImage(tx, mi, fi )
plot( fi, mi, alpha=0.5  )
plot( fi, wimg, alpha=0.5  )

could be worth wrapping cleanly in a function.

ntustison commented 6 years ago

Ah, brilliant. Thanks.