[MINC-users] calculating r-squared values

Jason Lerch jason at phenogenomics.ca
Fri Jun 8 12:39:28 EDT 2012


Try replacing FA with x - mincApply assigns the current voxel to the variable x in its loop. I.e.:

library(RMINC)
gf1 <- read.csv("dti_gd.csv")
fff <- function(x) { return(summary(lm(x ~ score, gf1))$r.squared) }
mincApply(gf1$FA, quote(fff(x)))

Jason

On 2012-06-08, at 11:32 AM, Jared Rowley wrote:

> Hi Jason,
> 
> Thanks for the response.
> 
> I did the following and got an error do you have any suggestions:
> 
> rm(list=ls(all=TRUE))
>> library(RMINC)
>> gf1 <- read.csv("dti_gd.csv")
>> fff <- function(x) { return(summary(lm(FA ~ score, gf1))$r.squared) }
>> mincApply(gf1$FA, quote(fff(x)))
> Number of volumes: 91
> Volume sizes: 193 229 193
> In slice
> 0 Error in storage.mode(y) <- "double" :
>  invalid to change the storage mode of a factor
> In addition: Warning message:
> In model.response(mf, "numeric") :
>  using type="numeric" with a factor response will be ignored
> 
> FA is a column of minc files and score is a column of integers I want to
> correlate with FA.
> 
> Thanks very much,
> 
> Jared
> 
> 
> On Wed, Jun 6, 2012 at 1:35 PM, Jason Lerch <jason at phenogenomics.ca> wrote:
> 
>> This should work, though is going to be slow:
>> 
>> fff <- function(x) { return(summary(lm(x ~ genotype, gf))$r.squared) }
>> 
>> mincApply(filenames, quote(fff(x)))
>> 
>> Note: replace the formula in that function with the appropriate formula
>> for your purposes, and filenames should be a vector of your filenames.
>> Could be worth specifying a mask, as this will run for a few hours.
>> 
>> And I haven't actually tested it, so it might not run at all!
>> 
>> Jason
>> 
>> On 2012-06-05, at 4:18 PM, Jared Rowley wrote:
>> 
>>> Hi Minc Users,
>>> 
>>> I was wondering if anyone knows a way calculate R-squared values on a
>> voxel
>>> level from a linear regression.
>>> 
>>> I assume there is a way with either glim_image or RMINC however reading
>>> though the documentation I could not find a solution.
>>> 
>>> Thanks very much,
>>> 
>>> Jared
>>> _______________________________________________
>>> MINC-users at bic.mni.mcgill.ca
>>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>> 
>> _______________________________________________
>> MINC-users at bic.mni.mcgill.ca
>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>> 
> 
> 
> 
> -- 
> Jared Rowley
> Translational Neuroimaging Laboratory
> McGill Centre for Studies in Aging
> Douglas Hospital Research Center
> McGill University
> 6825 LaSalle Blvd.
> Montreal, QC Canada
> H4H 1R3
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users



More information about the MINC-users mailing list