Age as covariate textfile in two sample t-test

Submitted by David on

Hi,

I want to calculate a two sample t-test and include age as covariate. Is it correct to just add two textfiles in the Text covariates menu in the same order as my groups in Group images. The textfiles for every group have the covariate (age) for every person in the rows in the same order as the images of the subjects?

For example

Group Images | Text Covariates

Group1             |   AgeGroup1.txt

Group2            |  AgeGroup2.txt      

Great, thanks!

just two quick follow up questions:

1.Will the covariates be centered automatically or is it necessary to do this before?

2. Is it possible to add a second covariate like gender in the same step? If yes, should it be in der form of e.g. 0 for male, 1 for female and in the following format:

Group Images | Text Covariates

Group1             |   AgeGroup1.txt

                          |  GenderGroup1.txt

Group2            |  AgeGroup2.txt    

                          |  GenderGroup2.txt 

Hi David,
1. It's centered automatically, as the constant is modeled in the GLM analysis.

2. 0 for male and 1 for female is OK. In AgeGroup1.txt, you put two columns in, one for age, one for gender, e.g., 
20   1
25   0
30   1
...

Best,

Chao-Gan

On Thu, Mar 10, 2016 at 12:01 AM, The R-fMRI Network <rfmri.org@gmail.com> wrote:
[To post a comment, please reply to rfmri.org@gmail.com ABOVE this line]

Commented by David (David)

Great, thanks!

just two quick follow up questions:

1.Will the covariates be centered automatically or is it necessary to do this before?

2. Is it possible to add a second covariate like gender in the same step? If yes, should it be in der form of e.g. 0 for male, 1 for female and in the following format:

Group Images | Text Covariates

Group1             |   AgeGroup1.txt

                          |  GenderGroup1.txt

Group2            |  AgeGroup2.txt    

                          |  GenderGroup2.txt 


Online version of this post: http://rfmri.org/comment/4194#comment-4194


Many a little makes a mickle -- your kind contributions shall make our efforts not perish from the earth. Please help The R-fMRI Network at http://rfmri.org/#overlay=HelpUs
To manage subscriptions, please visit: http://rnet.co/mailman/listinfo/rfmri.org_rnet.co
Mail comment ID: http://rfmri.org/mailcomment/redirect/%3C31.2243.4194.1457539260.1dc742d3755ed39a8a4f2f3f39c17da3%40www.rfmri.org%3E



--
Chao-Gan YAN, Ph.D.
Principal Investigator
Institute of Psychology, Chinese Academy of Sciences
16 Lincui Road, Chaoyang District, Beijing 100101, China
-

I see, thanks!

I have some problems making this work without the GUI though. Othercovariates is a 2x1 cell where rows correspond to groups and the entries of the cells are subject x  covariates double arrays, i.e. age and gender in the columns and the rows represents subjects (e.g. 100 x 2). I have no covariate image files and I initialize it as follows:

  [ttestDataOriginal Header]=y_TTest2_Image(DependentDirs,OutputName,MaskFile,Othercovariates);  

and get this error
 
Error using exist
The first input to exist must be a string.
 
Error in y_ReadAll (line 44)
elseif (7==exist(InputName,'dir'))
 
Error in y_TTest2_Image (line 46)
        [AllVolume,VoxelSize,theImgFileList, Header_Covariate] = y_ReadAll(CovariateDirs{i});

 

Hi David,

DependentDirs should be 2 by 1 cells as well. Within each cell, should be a

a 4D .nii file name, or

a directory, or

a cell of filenames.

Best,

Chao-Gan

 

 

Thanks for the answer. 

DependentDirs, OutputName and MaskFile are in the correct form, since it works without the covariate cell at the end. But when adding the covariate cell, I get this error. 

I looked at y_TTest2_Image and I think my covariates cell (OtherCovariates) is interpreted as a cell of covariate Images (CovariateDirs) instead of a cell with the text covariates. In line 46, it expects the variable CovariateDirs to be non empty and the if condition gets executed and produces the error. But CovariateDirs should be empty since I only have text covariates. So it should start reading these files at line 58, since the variable OtherCovariates is not empty.

Is it somehow possible to only read OtherCovariates while leaving CovariateDirs empty?

 

Hi all, This issue came up for me too. Can someone please explain how to get covariate text file with multiple covariates to work in the GUI? As a temporary solution, I have been able to submit the covariate values as separate files for each covariate, for each group, for each run (this is a mixed-effects analysis with 2 groups, and 2 runs/subject). However, I am not confident that the values are being read in in the correct order because there does not appear to be a matrix generated in the Matlab workspace. Currently, the order of the files is this: group1_run1_cov1 group1_run2_cov1 group2_run1_cov1 group2_run2_cov1 group1_run1_cov2 group1_run2_cov2 group2_run1_cov2 group2_run2_cov2 These are *.txt files. Previously,I had a formatting issue such that the Space and Enter delimiters would not be read into Matlab. The workaround was to create and save a subject list in the DPARSFA GUI, then open that file and copy a delimiter. I still do not know what this delimiter is: It's invisible in Notepad, and I only realized it was there after the arrow keys did not move from character to character; instead, the cursor hung between two characters and flashed red and blue--this is the delimiter needed for separating rows in the text file. But how can I separate the columns? If anyone can share information about formatting covariate text files to include multiple columns, it would be greatly appreciated. Thanks in advance, Felix

Hi Dr. Yan,

Thanks for your response. I had already tried that but it won't read in the values correctly (Space and Enter do not work). Can you please clarify what is the delimiter to be used in Notepad in order for two columns to be read in? Alternatively, could you please send a copy of such a file so that I can copy-and-paste the delimiter from the file contents?

Thank you,

Felix

Please try "tab" to separate columns. Enter to separate rows. What's your operating system?

On Sat, Oct 14, 2017 at 3:14 AM, The R-fMRI Network <rfmri.org@gmail.com> wrote:
[To post a comment, please reply to rfmri.org@gmail.com ABOVE this line]

Commented by Felix L. Garcia (flgarcia)

Hi Dr. Yan,

Thanks for your response. I had already tried that but it won't read in the values correctly (Space and Enter do not work). Can you please clarify what is the delimiter to be used in Notepad in order for two columns to be read in? Alternatively, could you please send a copy of such a file so that I can copy-and-paste the delimiter from the file contents?

Thank you,

Felix


Online version of this post: http://rfmri.org/comment/5095#comment-5095





--
Chao-Gan YAN, Ph.D.
Principal Investigator
Deputy Director, Magnetic Resonance Imaging Research Center
Institute of Psychology, Chinese Academy of Sciences
16 Lincui Road, Chaoyang District, Beijing 100101, China
-

Hi Dr. Yan,

Tab and Enter did work, but only after I opened BrainNet Viewer. I'm using Windows 10 Pro x64 (Matlab R2017b). It's possible I did not arrange the paths correctly or place toolbox folders in the correct directories after the recent upgrade from R2017a to R2017b, which reset my local user \Documents\MATLAB folder. If you can offer any guidance here I'd really appreciate it, otherwise, it looks like I have a temporary solution.

Thank you,

Felix

Hi Dr. Yan, The only space I found was in this path: "C:\Program Files\MATLAB", which was the default installation directory and the same one I'd been using before the upgrade. Would moving Matlab to the root directory solve this issue? The toolboxes are stored here: C:\Users\fgarc\Documents\MATLAB\spm8\... C:\Users\fgarc\Documents\MATLAB\DPABI_V2.3_170105\... The path for BrainNet Viewer is within the spm8 toolboxes folder: C:\Users\fgarc\Documents\MATLAB\spm8\toolbox\BrainNet\ Do I need to move DPABI to either the spm8\toolbox or MATLAB\toolbox directories? Thank you, Felix

Hi Xiao,

Thanks for your advice. I tried this, unfortunately I still need to load BrainNet Viewer from within spm8 for some of the Statistical Analysis procedures from the DPABI suite to work. The only other potential source of the problem that I can think of is the folder path for the location where the data are stored (on a separate drive from the Matlab folders), which does include spaces, but that's not something I can change because it is an institutional directory for which I do not have administrative privileges. It's not ideal, but for now I am focusing on getting my results so I will use the temporary solution, then I will go back and find a fix.

Many thanks,

Felix