Dear Martin and FS experts.I have a quick query about how to obtain my design 
matrix of group by age from the following matlab command listed in the lme 
wiki. In the wiki example the matrix is created from variables 1 and 2 (group 
by time). X = [ones(length(M),1) M M(:,1).*M(:,2);
In my case I have a combination of variables 1 and 2 for group (relatives of PT 
and PT) and 5 (age).
I would really appreciate if you could kindly advice on how to adapt the 
command above to my design.
Thanks
Pablo
To: freesurfer@nmr.mgh.harvard.edu
From: mreu...@nmr.mgh.harvard.edu
Date: Tue, 27 Oct 2015 17:13:51 -0400
Subject: Re: [Freesurfer] A mixed effect model approach in within subject 
dataset {Disarmed}


  
    
  
  
    Hi Pablo,

    

    the sortData function sorts the rows so that entries from the same
    subject (in your case same family) are blocked and that within each
    block the time variable (2nd parameter specifies which column that
    is in your M matrix, in your case the first =1) is increasing. 

    It is important, when creating your design matrix X, that ordering
    agrees with Y. That is guaranteed if you generate X from M (which is
    ordered like Y after the sort command). 

    

    Best, Martin

    

    On 10/27/2015 01:32 PM, pablo najt
      wrote:

    
    
      
        
        Thank you for your input. 
        I noticed that if I follow literally all the
          steps in the wiki, my data which is ordered by variable
          'family' (instead of subjects, in my case is number of members
          belonging to e.g. family_1) is shuffled. This happens after I
          run the command sortData below. Especially I noticed that ni
          and X do not match sID.
        It would be really helpful to know what is this
          command doing. I am wondering whether my data differs in
          number of columns or else and because of this I end with a
          shuffled data. Any suggestion or tips to figure what could be
          happening?
        Thanks
        Pablo
        
          

          
          [M, Y, ni] = sortData(M,1,Y,sID)
          
            

              
                To: freesurfer@nmr.mgh.harvard.edu

                From: mreu...@nmr.mgh.harvard.edu

                Date: Wed, 14 Oct 2015 10:54:41 -0400

                Subject: Re: [Freesurfer] A mixed effect model approach
                in within subject dataset {Disarmed}

                

                Hi Pablo,

you should run something like this to get the ni:

[M,Y,ni] = sortData(M,1,Y,sID);  # (sorts the data)
                see

                
https://surfer.nmr.mgh.harvard.edu/fswiki/LinearMixedEffectsModels
                

                

                hope that helps, Martin

                

                

                On 10/14/2015 10:43 AM,
                  pablo najt wrote:

                
                
                  
                    
                    Dear FS experts.
                      I have query about a relating to a previous
                        email (below). I
                          am aiming to run a LME analysis on
                          cross-sectional data from different families
                          and have variable 'family' (number of
                          families) as my NI vector. 
                      My design has three groups and therefore I am
                        not able to use qdec. I am running the matlab
                        commands below and finding some difficulty would
                        really appreciate if you could help out.
                      Thanks
                      Pablo
                      

                        
                      Start analysis as follows:
                      

                      
                      1-Read your label eg.:

                      lhcortex = 
fs_read_label('freesurfer/subjects/fsaverage/label/lh.cortex.label');

                      2-Read the data file eg.:

                      [lhY, lhmri] = fs_read_Y('lh.thickness.mgh'); 

                      
                         %---------------------I input the concatenated .mgh 
image from preproc and 
mris_surf2surf-----------------------------------------------------------------------%
                        

                      
                      3-Fit a vertex-wise lme model with random effects.:

                      lhstats = lme_mass_fit_vw(X, [1 2], lhY, ni, lhcortex); 

                      
                        Here I am getting the following problems:
                        %-------------------- If I use number of families as my 
ni get the 
following------------------------------------------------------------------------------------------------%
                      
                    
                    
                      
                        
                          
                            lhstats = lme_mass_fit_vw(X, [1 2], lhY, 82, 
lhcortex);
                          
                        
                      
                      
                        
                          
                            Error using lme_mass_fit (line 108)
                          
                        
                      
                      
                        
                          
                            The total number of measurements, indicated by 
sum(ni), mustbe the same as the number of rows of the design
                          
                        
                      
                      
                        
                          
                            matrix X
                          
                        
                      
                      
                        
                          
                            

                          
                        
                      
                      
                        
                          
                            Error in lme_mass_fit_vw (line 73)
                          
                        
                      
                      
                        
                          
                            [stats1,st1] = 
lme_mass_fit(X,[],Xrows,Zcols,Y,ni,prs,e);
                            

                          
                        
                      
                    
                    
                      
                         My matrix is organised in "family", "group", Sex" and 
"age" columns".
                        

                                      
4-Perform vertex-wise inference eg.:
CM.C = [your contrast matrix];
F_lhstats = lme_mass_F(lhstats, CM);
5-Save results eg.: 
fs_write_fstats(F_lhstats, lhmri,' sig.mgh', 'sig');  

Date: Thu, 10 Sep 2015 13:44:36 +0000
From: jbernal0...@yahoo.es
To: freesurfer@nmr.mgh.harvard.edu
Subject: Re: [Freesurfer] A mixed effect model approach in within subject 
dataset

Hi Pablo

I think you can use
LME to analyze your data by ordering the rows of your design matrix
appropriately. You can consider all subjects belonging to the same
family as if they were a single subject in a longitudinal analysis.
You can put in your design matrix all subjects belonging to family1
first, then all subjects belonging to family 2 and so on. Then the
'ni' required by lme_mass_fit_vw is a vector with the number of
subjects in each family as its entries (ordered according to your
design matrix). So the length of the 'ni'  vector is equal to the
number of different families in your data.  





Now you can go
further and additionally order the rows of your design matrix within
each family by age. This will allow you to test the effect of age
within family. 





When choosing the
random effects for your statistical model remember that a random
effect can only be the intercept term or any covariate that varies
within family. For example you can compare a model with a single
random effect for the intercept term against the same model but
considering both the intercept  term and age as random effects.




Hope that helps




Cheers
-Jorge




         De: pablo najt <pablon...@hotmail.com>
 Para: "freesurfer@nmr.mgh.harvard.edu" <freesurfer@nmr.mgh.harvard.edu> 
 Enviado: Jueves 10 de septiembre de 2015 8:07
 Asunto: [Freesurfer] A mixed effect model approach in within subject dataset
   






Dear Freesurfer users,I wanted to enquire if anyone had successfully been able 
to implement Bernal's Linear Mixed Effects (LME) Models in cross-section 
dataset *not longitudinal* (please see previous thread below).  I am willing to 
perform a LME (3 groups (HC, PT and Unaffected_relatives) and 3 covariates 
(sex, age, and family) with "family" variable been a within-subject factor. LME 
will allow to control for the non-independence of data contributed by patients 
and relatives from the same families.Thanks in advance!Pablo
From: michaelnot...@hotmail.com
To: freesurfer@nmr.mgh.harvard.edu
Date: Wed, 19 Feb 2014 13:10:09 +0100
Subject: [Freesurfer] Analysis of structural data acquired from multiple sites 
by using a mixed effect model approach







Hi everybody,

I want to compare the surface data of 3 groups (GroupA, GroupB and Controlls) 
but have the problem that they were acquired from 4 different scanner sites. As 
I can see it, there are three ways how I could tackle this problem:

1. I could use mri_glmfit and create a qdec table / fsgd-file with 12 classes: 
Class GroupA_site1; Class GroupA_site2,... And then use the contrasts [0.25 
0.25 0.25 0.25 0 0 0 0 -0.25 -0.25 -0.25 -0.25] to compare GroupA to the 
Controlls. My Problem with this approach is, that the sites don't contribute 
the same amount of subjects to the analysis. I'm not sure if this could be 
handled by simply using a weighted contrast. Meaning, if Site1 and Site2 had 
twice as many subjects than Site3 and Site4, I could modify the contrast to 
[0.33 0.33 0.17 0.17 0 0 0 0 -0.33 -0.33 -0.17 -0.17].

2. I could create dummy variables to account for the variability between sites. 
In this case, I only need to specify 3 classes (Class GroupA; Class GroupB; 
Class Controlls) in my fsgd-file. And I use a design matrix that has 4 dummy 
variables at the end, which specify to which site a subject belongs. This 
approach might work, but I'm not confident that it is the right one.

3. I could use a mixed effect model approach and specify site as a random 
effect.

If I understand it correctly, the mixed effect model approach would be the best 
one, as it accounts for the variability within sites. Is that correct or are 
there other issues/better approaches?


I tried to implement a mixed effect model by using Bernal's Linear Mixed 
Effects (LME) Models 
(http://surfer.nmr.mgh.harvard.edu/fswiki/LinearMixedEffectsModels) but run 
into some problems. I'm not sure if LME can only be applied on longitudinal 
data or if my implementation is wrong. I have a design matrix X that specifies 
the characteristics of each subject per row as follows:

Intercept   GroupA   GroupB   Controll   Age   IQ   Site1   Site2   Site3   
Site4
1  1  0  0  11.1  99   0 0 1 0
1  0  1  0  11.1  101  0 0 1 0
1  1  0  0  11.4  95   1 0 0 0
1  0  0  1  12.4  100  1 0 0 0
...

As I have no repeated measures, 'ni' is just a vector with length X containing 
'1's. If I do now the vertex-wise linear mixed-effects estimation, I get the 
following output:

>> stats = lme_mass_fit_vw(X,[7 8 9 10],Y,ni,lhcortex);
Starting matlabpool using the 'local' profile ... connected to 8 workers.
 
Starting model fitting at each location ...
 
Location 24994: Index exceeds matrix dimensions.
Location 24994: Algorithm did not converge. Initial and final likelihoods: 
-10000000000, -10000000000.
Location 62484: Index exceeds matrix dimensions.
Location 62484: Algorithm did not converge. Initial and final likelihoods: 
-10000000000, -10000000000.
...

I've checked the matrix dimensions of X, Y, ni and lhcortex and compared them 
to the LME mass_univariate example stored in ADNI_Long_50sMCI_vs_50cMCI.mat but 
couldn't find any divergence.

Has anybody encountered similar problems? Is my approach of specifying 'ni' as 
a vector of'1's even legitimate?

Thanks,
Michael


                                          

_______________________________________________
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.
                                          

_______________________________________________
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.


     
_______________________________________________
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.
                                          



_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


-- 
Martin Reuter, PhD
Assistant Professor of Radiology, Harvard Medical School
Assistant Professor of Neurology, Harvard Medical School
A.A.Martinos Center for Biomedical Imaging
Massachusetts General Hospital
Research Affiliate, CSAIL, MIT
Phone: +1-617-724-5652
Web  : http://reuter.mit.edu 
_______________________________________________
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.
                                          



_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


-- 
Martin Reuter, PhD
Assistant Professor of Radiology, Harvard Medical School
Assistant Professor of Neurology, Harvard Medical School
A.A.Martinos Center for Biomedical Imaging
Massachusetts General Hospital
Research Affiliate, CSAIL, MIT
Phone: +1-617-724-5652
Web  : http://reuter.mit.edu 
_______________________________________________
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.                                    

Attachment: ATT00001
Description: Binary data

_______________________________________________
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.

Reply via email to