Re: [Freesurfer] Stat doubts
Thanks Doug for your quick answer, Sorry for so late answer.One question about this, is about the fast_vol2mat, is this a function? if so, where can I get it?As the PCC is the R value, I'm guessing that I can just square at it, to obtain R2.When you asked me to divide the beta by sqrt(rvar), is there any place where I can find is this is the correct way to get the standardized beta?Best regards,GabrielEl 14/03/13, Douglas Greve gr...@nmr.mgh.harvard.edu escribió: Hi Gabriel, I've attached a matlab routine which will compute the PCC. If you cd into the GLM dir, then X = load('Xg.dat'); beta = MRIread('beta.mgh'); C = load('yourcontrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'yourcontrast/pcc.mgh') The R2 should just be the square of the PCC, right? For the standardized beta, do you just divide the beta by sqrt(rvar)? doug On 3/14/13 1:39 PM, Gabriel Gonzalez Escamilla wrote: Dear Freesurfers I'm performing regression analyses including confounding variables, and I would like to know how to obtain the following information: A) The squre R and B) The standarized beta coefficient of an independient variable; and the partial correlation with its p-values Many thanks in advanced, Gabriel ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer -- --PhD. student Gabriel González-EscamillaLaboratory of Functional NeuroscienceDepartment of Physiology, Anatomy, and Cell BiologyUniversity Pablo de OlavideCtra. de Utrera, Km.141013 - Seville- Spain -Email: ggon...@upo.eshttp://www.upo.es/neuroaging/es/ ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.
Re: [Freesurfer] Stat doubts
I had this exact question yesterday :-) The functions necessary to run it are in $FREESURFER_HOME/matlab and $FREESURFER_HOME/fsfast/**toolbox Just add the path to these directories in your matlab (file - setpath) and you can run the function from your matlab command window *Doug -* I had a follow up question about using this function on clusters identified in mri_glmfit-sim. Is the function as written below calculating the pcc across the whole brain or is it just calculating the rho using the betas specific to the cluster found in mri_glmfit-sim by only taking those betas from beta.mgh that are specific to the contrast and cluster results in C.dat? The reason I ask is that I have a cluster showing a significant relationship between thickness and a continuous behavioral variable (a positive relationship as denoted by a positive log10p of the Maxvertex in the cluster) and I'd like to get the correlation coefficient for it but when I run the PCC function I get zero so I'm wondering if this is because it is calculating across the whole brain rather than just within the cluster? (btw I get the same issue with a similar relationship showing positive corr between thickness and two behav variables). Thanks, Laura. On Thu, Mar 21, 2013 at 10:37 AM, Gabriel Gonzalez Escamilla ggon...@upo.es wrote: Thanks Doug for your quick answer, Sorry for so late answer. One question about this, is about the fast_vol2mat, is this a function? if so, where can I get it? As the PCC is the R value, I'm guessing that I can just square at it, to obtain R2. When you asked me to divide the beta by sqrt(rvar), is there any place where I can find is this is the correct way to get the standardized beta? Best regards, Gabriel El 14/03/13, *Douglas Greve * gr...@nmr.mgh.harvard.edu escribió: Hi Gabriel, I've attached a matlab routine which will compute the PCC. If you cd into the GLM dir, then X = load('Xg.dat'); beta = MRIread('beta.mgh'); C = load('yourcontrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'yourcontrast/pcc.mgh') The R2 should just be the square of the PCC, right? For the standardized beta, do you just divide the beta by sqrt(rvar)? doug On 3/14/13 1:39 PM, Gabriel Gonzalez Escamilla wrote: Dear Freesurfers I'm performing regression analyses including confounding variables, and I would like to know how to obtain the following information: A) The squre R and B) The standarized beta coefficient of an independient variable; and the partial correlation with its p-values Many thanks in advanced, Gabriel ___ Freesurfer mailing listfreesur...@nmr.mgh.harvard.edu Freesurfer@nmr.mgh.harvard.eduhttps://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer -- -- PhD. student Gabriel González-Escamilla Laboratory of Functional Neuroscience Department of Physiology, Anatomy, and Cell Biology University Pablo de Olavide Ctra. de Utrera, Km.1 41013 - Seville - Spain - Email: ggon...@upo.es http://www.upo.es/neuroaging/es/ ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. -- -- Laura M. Tully, MA Social Neuroscience Psychopathology, Harvard University Center for the Assessment and Prevention of Prodromal States, UCLA Semel Institute of Neuroscience ltu...@mednet.ucla.edu ltu...@fas.harvard.edu 310-267-0170 -- My musings as a young clinical scientist: http://theclinicalbrain.blogspot.com/ Follow me on Twitter: @tully_laura ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.
Re: [Freesurfer] Stat doubts
On 03/21/2013 01:37 PM, Gabriel Gonzalez Escamilla wrote: Thanks Doug for your quick answer, Sorry for so late answer. One question about this, is about the fast_vol2mat, is this a function? if so, where can I get it? $FREESURFER_HOME/fsfast/toolbox As the PCC is the R value, I'm guessing that I can just square at it, to obtain R2. When you asked me to divide the beta by sqrt(rvar), is there any place where I can find is this is the correct way to get the standardized beta? I don't know. Maybe ask the person who asked you to get the standardized beta what the definition is:). doug Best regards, Gabriel El 14/03/13, *Douglas Greve * gr...@nmr.mgh.harvard.edu escribió: Hi Gabriel, I've attached a matlab routine which will compute the PCC. If you cd into the GLM dir, then X = load('Xg.dat'); beta = MRIread('beta.mgh'); C = load('yourcontrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'yourcontrast/pcc.mgh') The R2 should just be the square of the PCC, right? For the standardized beta, do you just divide the beta by sqrt(rvar)? doug On 3/14/13 1:39 PM, Gabriel Gonzalez Escamilla wrote: Dear Freesurfers I'm performing regression analyses including confounding variables, and I would like to know how to obtain the following information: A) The squre R and B) The standarized beta coefficient of an independient variable; and the partial correlation with its p-values Many thanks in advanced, Gabriel ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer -- -- PhD. student Gabriel González-Escamilla Laboratory of Functional Neuroscience Department of Physiology, Anatomy, and Cell Biology University Pablo de Olavide Ctra. de Utrera, Km.1 41013 - Seville - Spain - Email: ggon...@upo.es http://www.upo.es/neuroaging/es/ -- Douglas N. Greve, Ph.D. MGH-NMR Center gr...@nmr.mgh.harvard.edu Phone Number: 617-724-2358 Fax: 617-726-7422 Bugs: surfer.nmr.mgh.harvard.edu/fswiki/BugReporting FileDrop: www.nmr.mgh.harvard.edu/facility/filedrop/index.html Outgoing: ftp://surfer.nmr.mgh.harvard.edu/transfer/outgoing/flat/greve/ ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.
Re: [Freesurfer] Stat doubts
It does it across the whole brain (on a voxel-by-voxel basis) but it is specific to the contrasts that you specify. You can run the same commands on the cluster averaged data (xxx.y.ocn...). To do this, don't load in the beta file. Instead y = load('xxx.y.ocn...'); beta = inv(X'*X)*X'*y; then proceed with the rest of the code doug On 03/21/2013 01:49 PM, Laura M. Tully wrote: I had this exact question yesterday :-) The functions necessary to run it are in $FREESURFER_HOME/matlab and $FREESURFER_HOME/fsfast/toolbox Just add the path to these directories in your matlab (file - setpath) and you can run the function from your matlab command window *Doug -* I had a follow up question about using this function on clusters identified in mri_glmfit-sim. Is the function as written below calculating the pcc across the whole brain or is it just calculating the rho using the betas specific to the cluster found in mri_glmfit-sim by only taking those betas from beta.mgh that are specific to the contrast and cluster results in C.dat? The reason I ask is that I have a cluster showing a significant relationship between thickness and a continuous behavioral variable (a positive relationship as denoted by a positive log10p of the Maxvertex in the cluster) and I'd like to get the correlation coefficient for it but when I run the PCC function I get zero so I'm wondering if this is because it is calculating across the whole brain rather than just within the cluster? (btw I get the same issue with a similar relationship showing positive corr between thickness and two behav variables). Thanks, Laura. On Thu, Mar 21, 2013 at 10:37 AM, Gabriel Gonzalez Escamilla ggon...@upo.es mailto:ggon...@upo.es wrote: Thanks Doug for your quick answer, Sorry for so late answer. One question about this, is about the fast_vol2mat, is this a function? if so, where can I get it? As the PCC is the R value, I'm guessing that I can just square at it, to obtain R2. When you asked me to divide the beta by sqrt(rvar), is there any place where I can find is this is the correct way to get the standardized beta? Best regards, Gabriel El 14/03/13, *Douglas Greve * gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu escribió: Hi Gabriel, I've attached a matlab routine which will compute the PCC. If you cd into the GLM dir, then X = load('Xg.dat'); beta = MRIread('beta.mgh'); C = load('yourcontrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'yourcontrast/pcc.mgh') The R2 should just be the square of the PCC, right? For the standardized beta, do you just divide the beta by sqrt(rvar)? doug On 3/14/13 1:39 PM, Gabriel Gonzalez Escamilla wrote: Dear Freesurfers I'm performing regression analyses including confounding variables, and I would like to know how to obtain the following information: A) The squre R and B) The standarized beta coefficient of an independient variable; and the partial correlation with its p-values Many thanks in advanced, Gabriel ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu mailto:Freesurfer@nmr.mgh.harvard.edu Freesurfer@nmr.mgh.harvard.edu mailto:Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer -- -- PhD. student Gabriel González-Escamilla Laboratory of Functional Neuroscience Department of Physiology, Anatomy, and Cell Biology University Pablo de Olavide Ctra. de Utrera, Km.1 41013 - Seville - Spain - Email: ggon...@upo.es mailto:ggon...@upo.es http://www.upo.es/neuroaging/es/ ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu mailto:Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. -- -- Laura M. Tully, MA Social Neuroscience Psychopathology, Harvard University Center for the Assessment and Prevention of Prodromal States, UCLA Semel Institute of Neuroscience ltu...@mednet.ucla.edu
Re: [Freesurfer] Stat doubts
Hi Doug, I gave that a try but got a matrix error - below is the command line and error output from matlab, can you spot what I'm doing wrong? (I'm a matlab newbie I'm afraid...) y = load('contrast/cache.th13.abs.y.ocn.dat'); X = load('Xg.dat'); beta = inv(X'*X)*X'*y; C = load('contrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'contrast/pcc.mgh') ??? Error using == mtimes Inner matrix dimensions must agree. Error in == fast_glm_pcc at 39 yhatd = Rd*(X*beta); Thanks! Laura On Thu, Mar 21, 2013 at 10:56 AM, Douglas N Greve gr...@nmr.mgh.harvard.edu wrote: It does it across the whole brain (on a voxel-by-voxel basis) but it is specific to the contrasts that you specify. You can run the same commands on the cluster averaged data (xxx.y.ocn...). To do this, don't load in the beta file. Instead y = load('xxx.y.ocn...'); beta = inv(X'*X)*X'*y; then proceed with the rest of the code doug On 03/21/2013 01:49 PM, Laura M. Tully wrote: I had this exact question yesterday :-) The functions necessary to run it are in $FREESURFER_HOME/matlab and $FREESURFER_HOME/fsfast/**toolbox Just add the path to these directories in your matlab (file - setpath) and you can run the function from your matlab command window *Doug -* I had a follow up question about using this function on clusters identified in mri_glmfit-sim. Is the function as written below calculating the pcc across the whole brain or is it just calculating the rho using the betas specific to the cluster found in mri_glmfit-sim by only taking those betas from beta.mgh that are specific to the contrast and cluster results in C.dat? The reason I ask is that I have a cluster showing a significant relationship between thickness and a continuous behavioral variable (a positive relationship as denoted by a positive log10p of the Maxvertex in the cluster) and I'd like to get the correlation coefficient for it but when I run the PCC function I get zero so I'm wondering if this is because it is calculating across the whole brain rather than just within the cluster? (btw I get the same issue with a similar relationship showing positive corr between thickness and two behav variables). Thanks, Laura. On Thu, Mar 21, 2013 at 10:37 AM, Gabriel Gonzalez Escamilla ggon...@upo.es mailto:ggon...@upo.es wrote: Thanks Doug for your quick answer, Sorry for so late answer. One question about this, is about the fast_vol2mat, is this a function? if so, where can I get it? As the PCC is the R value, I'm guessing that I can just square at it, to obtain R2. When you asked me to divide the beta by sqrt(rvar), is there any place where I can find is this is the correct way to get the standardized beta? Best regards, Gabriel El 14/03/13, *Douglas Greve * gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.**edu gr...@nmr.mgh.harvard.edu escribió: Hi Gabriel, I've attached a matlab routine which will compute the PCC. If you cd into the GLM dir, then X = load('Xg.dat'); beta = MRIread('beta.mgh'); C = load('yourcontrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,**rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.**volsize); MRIwrite(rho,'yourcontrast/**pcc.mgh') The R2 should just be the square of the PCC, right? For the standardized beta, do you just divide the beta by sqrt(rvar)? doug On 3/14/13 1:39 PM, Gabriel Gonzalez Escamilla wrote: Dear Freesurfers I'm performing regression analyses including confounding variables, and I would like to know how to obtain the following information: A) The squre R and B) The standarized beta coefficient of an independient variable; and the partial correlation with its p-values Many thanks in advanced, Gabriel __**_ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu mailto:freesur...@nmr.mgh.** harvard.edu Freesurfer@nmr.mgh.harvard.edu freesur...@nmr.mgh.harvard.**edu Freesurfer@nmr.mgh.harvard.edu mailto: freesur...@nmr.mgh.**harvard.edu Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.**edu/mailman/listinfo/**freesurferhttps://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer -- -- PhD. student Gabriel González-Escamilla Laboratory of Functional Neuroscience Department of Physiology, Anatomy, and Cell Biology University Pablo de Olavide Ctra. de Utrera, Km.1 41013 - Seville - Spain - Email: ggon...@upo.es mailto:ggon...@upo.es
Re: [Freesurfer] Stat doubts
oh, sorry, you'll need to recompute rvarmat (don't load rvar or beta) [betamat rvarmat] = fast_glmfit(y,X); Make sure you have $FREESURFER_HOME/fsfast/toolbox in your matlab path doug On 03/21/2013 05:04 PM, Laura M. Tully wrote: Hi Doug, I gave that a try but got a matrix error - below is the command line and error output from matlab, can you spot what I'm doing wrong? (I'm a matlab newbie I'm afraid...) y = load('contrast/cache.th13.abs.y.ocn.dat'); X = load('Xg.dat'); beta = inv(X'*X)*X'*y; C = load('contrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'contrast/pcc.mgh') ??? Error using == mtimes Inner matrix dimensions must agree. Error in == fast_glm_pcc at 39 yhatd = Rd*(X*beta); Thanks! Laura On Thu, Mar 21, 2013 at 10:56 AM, Douglas N Greve gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu wrote: It does it across the whole brain (on a voxel-by-voxel basis) but it is specific to the contrasts that you specify. You can run the same commands on the cluster averaged data (xxx.y.ocn...). To do this, don't load in the beta file. Instead y = load('xxx.y.ocn...'); beta = inv(X'*X)*X'*y; then proceed with the rest of the code doug On 03/21/2013 01:49 PM, Laura M. Tully wrote: I had this exact question yesterday :-) The functions necessary to run it are in $FREESURFER_HOME/matlab and $FREESURFER_HOME/fsfast/toolbox Just add the path to these directories in your matlab (file - setpath) and you can run the function from your matlab command window *Doug -* I had a follow up question about using this function on clusters identified in mri_glmfit-sim. Is the function as written below calculating the pcc across the whole brain or is it just calculating the rho using the betas specific to the cluster found in mri_glmfit-sim by only taking those betas from beta.mgh that are specific to the contrast and cluster results in C.dat? The reason I ask is that I have a cluster showing a significant relationship between thickness and a continuous behavioral variable (a positive relationship as denoted by a positive log10p of the Maxvertex in the cluster) and I'd like to get the correlation coefficient for it but when I run the PCC function I get zero so I'm wondering if this is because it is calculating across the whole brain rather than just within the cluster? (btw I get the same issue with a similar relationship showing positive corr between thickness and two behav variables). Thanks, Laura. On Thu, Mar 21, 2013 at 10:37 AM, Gabriel Gonzalez Escamilla ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es wrote: Thanks Doug for your quick answer, Sorry for so late answer. One question about this, is about the fast_vol2mat, is this a function? if so, where can I get it? As the PCC is the R value, I'm guessing that I can just square at it, to obtain R2. When you asked me to divide the beta by sqrt(rvar), is there any place where I can find is this is the correct way to get the standardized beta? Best regards, Gabriel El 14/03/13, *Douglas Greve * gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu escribió: Hi Gabriel, I've attached a matlab routine which will compute the PCC. If you cd into the GLM dir, then X = load('Xg.dat'); beta = MRIread('beta.mgh'); C = load('yourcontrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'yourcontrast/pcc.mgh') The R2 should just be the square of the PCC, right? For the standardized beta, do you just divide the beta by sqrt(rvar)? doug On 3/14/13 1:39 PM, Gabriel Gonzalez Escamilla wrote: Dear Freesurfers I'm performing regression analyses including confounding
Re: [Freesurfer] Stat doubts
So this instead? y = load('contrast/cache.th13.abs.**y.ocn.dat'); X = load('Xg.dat'); beta = inv(X'*X)*X'*y; C = load('contrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); [betamat rvarmat] = fast_glmfit(y,X); rhomat = fast_glm_pcc(betamat,X,C,**rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.**volsize); MRIwrite(rho,'contrast/pcc.**mgh') On Thu, Mar 21, 2013 at 3:14 PM, Douglas N Greve gr...@nmr.mgh.harvard.eduwrote: oh, sorry, you'll need to recompute rvarmat (don't load rvar or beta) [betamat rvarmat] = fast_glmfit(y,X); Make sure you have $FREESURFER_HOME/fsfast/**toolbox in your matlab path doug On 03/21/2013 05:04 PM, Laura M. Tully wrote: Hi Doug, I gave that a try but got a matrix error - below is the command line and error output from matlab, can you spot what I'm doing wrong? (I'm a matlab newbie I'm afraid...) y = load('contrast/cache.th13.abs.**y.ocn.dat'); X = load('Xg.dat'); beta = inv(X'*X)*X'*y; C = load('contrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,**rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.**volsize); MRIwrite(rho,'contrast/pcc.**mgh') ??? Error using == mtimes Inner matrix dimensions must agree. Error in == fast_glm_pcc at 39 yhatd = Rd*(X*beta); Thanks! Laura On Thu, Mar 21, 2013 at 10:56 AM, Douglas N Greve gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.**edugr...@nmr.mgh.harvard.edu wrote: It does it across the whole brain (on a voxel-by-voxel basis) but it is specific to the contrasts that you specify. You can run the same commands on the cluster averaged data (xxx.y.ocn...). To do this, don't load in the beta file. Instead y = load('xxx.y.ocn...'); beta = inv(X'*X)*X'*y; then proceed with the rest of the code doug On 03/21/2013 01:49 PM, Laura M. Tully wrote: I had this exact question yesterday :-) The functions necessary to run it are in $FREESURFER_HOME/matlab and $FREESURFER_HOME/fsfast/**toolbox Just add the path to these directories in your matlab (file - setpath) and you can run the function from your matlab command window *Doug -* I had a follow up question about using this function on clusters identified in mri_glmfit-sim. Is the function as written below calculating the pcc across the whole brain or is it just calculating the rho using the betas specific to the cluster found in mri_glmfit-sim by only taking those betas from beta.mgh that are specific to the contrast and cluster results in C.dat? The reason I ask is that I have a cluster showing a significant relationship between thickness and a continuous behavioral variable (a positive relationship as denoted by a positive log10p of the Maxvertex in the cluster) and I'd like to get the correlation coefficient for it but when I run the PCC function I get zero so I'm wondering if this is because it is calculating across the whole brain rather than just within the cluster? (btw I get the same issue with a similar relationship showing positive corr between thickness and two behav variables). Thanks, Laura. On Thu, Mar 21, 2013 at 10:37 AM, Gabriel Gonzalez Escamilla ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es wrote: Thanks Doug for your quick answer, Sorry for so late answer. One question about this, is about the fast_vol2mat, is this a function? if so, where can I get it? As the PCC is the R value, I'm guessing that I can just square at it, to obtain R2. When you asked me to divide the beta by sqrt(rvar), is there any place where I can find is this is the correct way to get the standardized beta? Best regards, Gabriel El 14/03/13, *Douglas Greve * gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.**edu gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.**edugr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.**edu gr...@nmr.mgh.harvard.edu escribió: Hi Gabriel, I've attached a matlab routine which will compute the PCC. If you cd into the GLM dir, then X = load('Xg.dat'); beta = MRIread('beta.mgh'); C = load('yourcontrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta);
Re: [Freesurfer] Stat doubts
yes, no need to load rvar or the first computations of betamat and rvarmat, and you don't need beta = ... On 3/21/13 6:34 PM, Laura M. Tully wrote: So this instead? y = load('contrast/cache.th13.abs.y.ocn.dat'); X = load('Xg.dat'); beta = inv(X'*X)*X'*y; C = load('contrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); [betamat rvarmat] = fast_glmfit(y,X); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'contrast/pcc.mgh') On Thu, Mar 21, 2013 at 3:14 PM, Douglas N Greve gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu wrote: oh, sorry, you'll need to recompute rvarmat (don't load rvar or beta) [betamat rvarmat] = fast_glmfit(y,X); Make sure you have $FREESURFER_HOME/fsfast/toolbox in your matlab path doug On 03/21/2013 05:04 PM, Laura M. Tully wrote: Hi Doug, I gave that a try but got a matrix error - below is the command line and error output from matlab, can you spot what I'm doing wrong? (I'm a matlab newbie I'm afraid...) y = load('contrast/cache.th13.abs.y.ocn.dat'); X = load('Xg.dat'); beta = inv(X'*X)*X'*y; C = load('contrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'contrast/pcc.mgh') ??? Error using == mtimes Inner matrix dimensions must agree. Error in == fast_glm_pcc at 39 yhatd = Rd*(X*beta); Thanks! Laura On Thu, Mar 21, 2013 at 10:56 AM, Douglas N Greve gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu mailto:gr...@nmr.mgh.harvard.edu wrote: It does it across the whole brain (on a voxel-by-voxel basis) but it is specific to the contrasts that you specify. You can run the same commands on the cluster averaged data (xxx.y.ocn...). To do this, don't load in the beta file. Instead y = load('xxx.y.ocn...'); beta = inv(X'*X)*X'*y; then proceed with the rest of the code doug On 03/21/2013 01:49 PM, Laura M. Tully wrote: I had this exact question yesterday :-) The functions necessary to run it are in $FREESURFER_HOME/matlab and $FREESURFER_HOME/fsfast/toolbox Just add the path to these directories in your matlab (file - setpath) and you can run the function from your matlab command window *Doug -* I had a follow up question about using this function on clusters identified in mri_glmfit-sim. Is the function as written below calculating the pcc across the whole brain or is it just calculating the rho using the betas specific to the cluster found in mri_glmfit-sim by only taking those betas from beta.mgh that are specific to the contrast and cluster results in C.dat? The reason I ask is that I have a cluster showing a significant relationship between thickness and a continuous behavioral variable (a positive relationship as denoted by a positive log10p of the Maxvertex in the cluster) and I'd like to get the correlation coefficient for it but when I run the PCC function I get zero so I'm wondering if this is because it is calculating across the whole brain rather than just within the cluster? (btw I get the same issue with a similar relationship showing positive corr between thickness and two behav variables). Thanks, Laura. On Thu, Mar 21, 2013 at 10:37 AM, Gabriel Gonzalez Escamilla ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es mailto:ggon...@upo.es wrote: Thanks Doug for your quick answer, Sorry for so late answer. One question about this, is about the fast_vol2mat, is this a function? if so, where can I get it? As the PCC is the R value, I'm guessing that I can just square at it, to obtain R2.
[Freesurfer] Stat doubts
Dear Freesurfers I'm performing regression analyses including confounding variables, and I would like to know how to obtain the following information:A) The squre Rand B) The standarized beta coefficient of an independient variable; and the partial correlation with its p-valuesMany thanks in advanced,Gabriel ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.
Re: [Freesurfer] Stat doubts
Hi Gabriel, I've attached a matlab routine which will compute the PCC. If you cd into the GLM dir, then X = load('Xg.dat'); beta = MRIread('beta.mgh'); C = load('yourcontrast/C.dat'); rvar = MRIread('rvar.mgh'); betamat = fast_vol2mat(beta); rvarmat = fast_vol2mat(rvar); rhomat = fast_glm_pcc(betamat,X,C,rvarmat); rho = beta; rho.vol = fast_mat2vol(rhomat,rho.volsize); MRIwrite(rho,'yourcontrast/pcc.mgh') The R2 should just be the square of the PCC, right? For the standardized beta, do you just divide the beta by sqrt(rvar)? doug On 3/14/13 1:39 PM, Gabriel Gonzalez Escamilla wrote: Dear Freesurfers I'm performing regression analyses including confounding variables, and I would like to know how to obtain the following information: A) The squre R and B) The standarized beta coefficient of an independient variable; and the partial correlation with its p-values Many thanks in advanced, Gabriel ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer function rho = fast_glm_pcc(beta,X,C,rvar) % rho = fast_glm_pcc(beta,X,C,rvar) % % Computes the partial correlation coefficient of the given % univariate contrast. % % WARNING: X must have a column of 1s or both X and y must have % been demeaned before the glm. % % $Id: fast_glm_pcc.m,v 1.2 2012/11/19 22:18:23 greve Exp $ if(nargin ~= 4) fprintf('rho = fast_glm_pcc(beta,X,C,rvar)\n'); return; end [J nbeta] = size(C); if(J ~= 1) fprintf('ERROR: fast_glm_pcc: contrast must be univariate\n'); return; end ntp = size(X,1); DOF = ntp - nbeta; % Design matrix projected onto the contrast space. This forms % the space of the contrast Xc = X*C'; % Null space of the contrast D = null(C); % Design matrix projected onto the null-space contrast. This forms % the space of the nuisance regressors Xd = X*D; % Residual-forming matrix of the nuisance regressors Rd = eye(ntp) - Xd*inv(Xd'*Xd)*Xd'; % Orthogonalize both Xc and yhat wrt the nuisance regressors Xcd = Rd*Xc; yhatd = Rd*(X*beta); % Compute sums and cross-products needed for correlation coef Xcdtyz = Xcd'*yhatd; sumXcd = sum(Xcd); sumyz = sum(yhatd); % Fails without column of 1s in X XcdtXcd = sum(Xcd.^2); yztyz = sum(yhatd.^2) + DOF*rvar; rho = (Xcdtyz-sumXcd.*sumyz)./sqrt((XcdtXcd-sumXcd.^2).*(yztyz-sumyz.^2)); return; ___ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.