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

How to use CompCor to get nuisance regressors for wm and csf #338

Open carolin31 opened 3 years ago

carolin31 commented 3 years ago

Hello,

I am analyzing a resting state data set. And I would like to use CompCor to obtain a file that includes 5 principal component regressors for the wm tissue and 5 principal components for csf. And I would like to use this file afterwards in afni for nuisance regression. I have an EPI time series, and wm and ventricle masks (created based on Freesurfer segmentation) that I brought into EPI space using antsRegistration.

So far I have only used ants but I read on source forge that CompCor is not maintained in ants anymore and is moved to antsR. So I am trying to figure out how to use CompCor in antsR. I checked https://antsx.github.io/ANTsR/articles/RestingBOLD.html and https://antsx.github.io/ANTsR/reference/compcor.html but it is still not clear to me what CompCor in antsR exactly outputs. And how I make sure that it calculates the principal components for wm and then csf.

Can somebody help me with how to use CompCor to do what I described above?

I am grateful for any thoughts! That you very much in advance! Carolin

stnava commented 3 years ago

here is pseudo code

csfmat = timeSeries2Matrix( boldImage,  csfMask )
csfcompcor = compcor( csfmat, 5 )
wmat = timeSeries2Matrix( boldImage,  wmMask )
wmcompcor = compcor( wmat, 5 )
joined = cbind( ... what's above ... )

then run regression for instance with the ilr function.

carolin31 commented 3 years ago

Hello Brian,

thank you very much for your response! The following question is, I am sure, a very stupid question but again I have never used antsR before. I installed everything according to the 'from command line' section. I installed only itkR and ANTsRCore and not the whole R package. And now I am wondering how I can start to use this code? I see that it says for usage: load the package: library (antsR). Do I have to type this into R studio meaning that I do need the R package? I stupidly typed it into my bash terminal and it was complaining about the brackets so I know that this is not the right way ;)

Is there any document that describes for beginners how to use antsR or do I just need to learn how to use R studio?

Thank you very much Carolin

muschellij2 commented 3 years ago

Dear Carolin, You must work in R with ANTsR. There are a number of ways to learn R: https://www.dataquest.io/path/data-analyst-r/, https://www.coursera.org/learn/r-programming. I have a course at https://johnmuschelli.com/imaging_in_r/, but it assumes you know R. Best, John

On Thu, Jan 28, 2021 at 7:53 PM carolin31 notifications@github.com wrote:

Hello Brian,

thank you very much for your response! The following question is, I am sure, a very stupid question but again I have never used antsR before. I installed everything according to the 'from command line' section. I installed only itkR and ANTsRCore and not the whole R package. And now I am wondering how I can start to use this code? I see that it says for usage: load the package: library (antsR). Do I have to type this into R studio meaning that I do need the R package? I stupidly typed it into my bash terminal and it was complaining about the brackets so I know that this is not the right way ;)

Is there any document that describes for beginners how to use antsR or do I just need to learn how to use R studio?

Thank you very much Carolin

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsR/issues/338#issuecomment-769497346, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIGPLUHTOFQEIDAWIVULGLS4IBHRANCNFSM4WSTZTBA .

carolin31 commented 3 years ago

Hello antsR experts!

I finally learnt some R and succeeded in running CompCor using antsR. Thank you John for the helpful links! I have another question in regards to aCompCor. Does it automatically remove linear trends from the data before estimating the principal components or is this something I need to do beforehand?

Thank you very much in advance Carolin