# Re: [Freesurfer] Running Linear Mixed Effects (LME) Model

I have tabulated the columns for easier comprehension.

Column 1

Column 2

Column 3

Column 4

Column 5

Column 6

intercept

time of each scan from base scan for a given subject

age at first scan for a given subject

group (1, 2, or 3)

visit (1,2 3, or 4)

Column 2 * Column 3

Thanks again.

Mayank
On Mar 6, 2018, at 12:05 PM, Kaushal, Mayank
<mkaus...@mcw.edu<mailto:mkaus...@mcw.edu>> wrote:

Changing the Matlab directory worked.
Thanks for all your inputs, Kersten.

Sorry to prolong the conversation but if possible, I would appreciate input on
whether my thought process regarding the LME analysis is on the right track.

I am looking to compare cortical thickness between 3 groups over multiple
visits.

The design matrix created by me X = [ones(length(M),1) M M(:,1).*M(:,2)];
Column 1 Column 2 Column 3 Column 4 Column 5 Column 6
intercept time of each scan from base scan age at first scan group (1, 2, or 3)
visit (1,2 3, or 4)  Column 2 * Column 3

Presently, I am running lhstats = lme_mass_fit_vw(X,[1 2],Y,ni,lhcortex,[],1)
as a test run.

However, I would like to include Columns 1, 4, and 5 as random effects for LME
analysis and if possible even include Column 2 as a random effect to have 4
random effects.        lhstats = lme_mass_fit_vw(X,[1 4 5],Y,ni,lhcortex,[],1)
or  lhstats = lme_mass_fit_vw(X,[1 2 4 5],Y,ni,lhcortex,[],1)

Now, I would like to know if having 3 or possibly 4 random effects would be too
many random effects.

Mayank
On Mar 6, 2018, at 8:57 AM, Diers, Kersten /DZNE
<kersten.di...@dzne.de<mailto:kersten.di...@dzne.de><mailto:kersten.di...@dzne.de>>
wrote:

ATTENTION: This email originated from a sender outside of MCW. Use caution when
clicking on links or opening attachments.
________________________________

The LME toolbox will create a text file ('parfor_progress1.txt') in
Matlab's present working directory to indicate its progress in
processing each vertex.

To create this file it needs to have write permissions in Matlab's
present working directory.

I speculate that your present working directory in Matlab is the root
directory '/' where the toolbox cannot create a file.

The solution would be to not run the scripts from '/', but to set the
Matlab working directory to another directory where you have write
permissions.

Best regards

Kersten

-----Original Message-----
From: "Kaushal, Mayank"
<mkaus...@mcw.edu<mailto:mkaus...@mcw.edu><mailto:mkaus...@mcw.edu>>
<freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>>
To: Freesurfer support list
<freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>>
Subject: Re: [Freesurfer] Running Linear Mixed Effects (LME) Model
Date: Tue, 6 Mar 2018 15:17:31 +0100

lme_mass_fit_vw(X,[1 2],Y,ni,lhcortex,[],1), I received the following
errors.

Error using parfor_progress (line 17)
Do you have write permissions for /?

Error in lme_mass_fit (line 155)
fn = parfor_progress('init',nv);

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

Thoughts?

Mayank

On Mar 6, 2018, at 7:08 AM, Diers, Kersten /DZNE <Kersten.Diers@dzne.
de> wrote:

ATTENTION: This email originated from a sender outside of MCW. Use
caution when clicking on links or opening attachments.
________________________________

Yes,

my understanding is the same.

The LME toolbox can in a way be regarded as a post-processing add-on
to
Freesurfer. The only interface with Freesurfer are the read/write
functions, everything else is to the best of my knowledge independent
of Freesurfer. So I cannot see any problems in using the newer
version
of the LME toolbox with data from Freesurfer 5.3.

Needless to say, this does not affect the usual recommendation, which
is that Freesurfer versions should not be mixed in general.

Best,

Kersten

------Original Message-----
From: "Kaushal, Mayank" <mkaus...@mcw.edu<mailto:mkaus...@mcw.edu>>
<freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>>
To: Freesurfer support list
<freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>>
Subject: Re: [Freesurfer] Running Linear Mixed Effects (LME) Model
Date: Mon, 5 Mar 2018 20:47:36 +0100

The version string I have been using:
\$Revision: 1.1.1.1 \$  \$Date: 2012/02/02 11:25:52 \$
So, it appears that I do indeed have the older version.

I am running Matlab 2017a, which is a relatively newer version.

Before I proceed with using LME toolbox from a freesurfer 6.0, I
would
appreciate your input on the following.

My understanding is that LME toolbox is used for statistical analysis
and is independent of the freesurfer version performing the actual
cortical thickness analysis. So, in theory, if I import cortical
thickness data processed in version 5.3, I should still be able to
run
the LME toolbox from a version 6.0.
So, can I input the files processed by freesurfer 5.3 (files that
have
been processed till mris_preproc and mri_surf2surf) and simply use
the
LME toolbox from a version 6.0 to perform the statistical analysis?

Mayank

On Mar 5, 2018, at 1:29 PM, Diers, Kersten /DZNE <Kersten.Diers@dzn
e.
de> wrote:

ATTENTION: This email originated from a sender outside of MCW. Use
caution when clicking on links or opening attachments.
________________________________

Hi,

I believe that we are dealing with a version issue now.

Specifically, I have so far been testing with an LME toolbox from a
Freesurfer 6.0 version on Matlab R2016a. In that sense, there is no
need for a separate download of the LME scripts, since they are
included within the freesurfer directory (e.g.
'freesurfer/matlab/lme').

It is primarily the 'lme_mass_fit.m' script, which throws the
current
'help
lme_mass_fit.m')?

Within my 5.3 installation, the version string is:
% \$Revision: 1.1.2.2 \$  \$Date: 2013/02/23 21:08:10 \$

Within my 6.0 installation, the version string is:
\$Revision: 1.3 \$  \$Date: 2016/04/08 19:39:24 \$

Unfortunately, the version string of the 'lme_mass_fit.m' script
within
a toolbox that I just downloaded from the LME website is the most
ancient one:
% \$Revision: 1.1.1.1 \$  \$Date: 2012/02/02 11:25:52 \$

When I use the 1.1.1.1 version instead of the one that is included
within Freesurfer 6.0, I can replicate the problem reported in your
current mail. With the 1.3 version I have no issues.

As far as I know, the 'lme_mass_fit.m' script was updated to
accommodate the changes in Matlab's way of doing the parallel
processing. In older Matlab versions this was done using the
'matlabpool' command, but this was replaced by 'parpool', which is
-
to
my knowledge - the only way of running parallel processing with
recent
Matlab versions. The LME toolbox was originally only tailored to
the
'matlabpool' command, but has later been adapted to also include
the
'parpool' command.

Assuming that you are using a relatively recent Matlab version, the
use
of earlier vs. later versions of the toolbox would explain our
respective observations.

All in all, I currently see no way of getting an older version of
the
LME toolbox to run with a current Matlab version - except from
modifying the code itself. So my suggestion would be to just use
the
newer LME toolbox that is shipped with Freesurfer 6.0.

Let us know if I am mistaken or if there are further issues.

Best regards,

Kersten

-----Original Message-----
From: "Kaushal, Mayank" <mkaus...@mcw.edu<mailto:mkaus...@mcw.edu>>
<freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>>
To: Freesurfer support list
<freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>>
Subject: Re: [Freesurfer] Running Linear Mixed Effects (LME) Model
Date: Mon, 5 Mar 2018 16:34:14 +0100

Thanks for the quick response Kersten.

I tried all the potential suggestions mentioned in your post but
still
no luck.

Here’s the summary:

lhstats = lme_mass_fit_vw(X,[1 2],Y,ni,lhcortex,[],1)
Undefined function or variable 'matlabpool'.

Error in lme_mass_fit (line 124)
if (matlabpool('size') > 0)

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

lhstats = lme_mass_fit_vw(X,[1 2],Y,ni,lhcortex,[],2)
Undefined function or variable 'matlabpool'.

Error in lme_mass_fit (line 123)
if (prs==1) || (matlabpool('size') ~= prs)

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

The "automatically create a parallel pool" was already deselected
in
my
case.

the
freesurfer website.

Mayank

On Mar 5, 2018, at 9:12 AM, Diers, Kersten /DZNE <Kersten.Diers@d
zn
e.
de> wrote:

ATTENTION: This email originated from a sender outside of MCW.
Use
caution when clicking on links or opening attachments.
________________________________

Hi,

you might try supplying an additional command-line argument while
calling the 'lme_mass_fit_vw' function:

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

This will tell Matlab to use only one worker. Further
documentation
on
this additional argument can be obtained by typing 'help
lme_mass_fit_vw' at the Matlab prompt.

To get this working with my Matlab installation, I additionally
to deselect the "Automatically create parallel pool (if one
doesn't
already exist) when parallel keywords (e.g., parfor) are
executed."
option. This can be found in Matlab's preferences menu (--> see
the
Parallel Computing toolbox section).

As an alternative, using two workers might also be an option in
your
case:

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

To get this alternative approach working, I did not have to
change
the
Matlab preferences.

Hope this helps,

Kersten

-----Original Message-----
From: "Kaushal, Mayank" <mkaus...@mcw.edu<mailto:mkaus...@mcw.edu>>
<freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>

To: freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>
<freesur...@nmr.mgh.harvard.ed<mailto:freesur...@nmr.mgh.harvard.ed>
u>
Subject: [Freesurfer] Running Linear Mixed Effects (LME) Model
Date: Sun, 4 Mar 2018 23:56:03 +0100

Dear Freesurfer Community,

Running lhstats = lme_mass_fit_vw(X,[1 2],Y,ni,lhcortex); gives
the
following error,
Starting parallel pool (parpool) using the 'local' profile ...
Error using parpool (line 104)
You requested a minimum of 8 workers, but the cluster "local" has
the
NumWorkers property set to allow a maximum of 2 workers. To run a
communicating job on more workers than this (up to a maximum of
512
for
the Local cluster), increase the value of the NumWorkers
property for the cluster. The default value of NumWorkers for a
Local
cluster is the number of cores on the local machine.

Error in lme_mass_fit (line 137)
parpool(prs);

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

I am running Matlab on a personal MacBook Pro, 2.4 GHz Intel Core
i5,
8
GB 1600 MHz DDR3.

I have researched the forum on how to stop the function from
trying
to
initiate parallel processing but so far haven’t been able figure
out
how to overcome this.

Any help would be much appreciated.

Mayank Kaushal MD MBA
Postdoctoral Fellow
Department of Neurosurgery
Medical College of Wisconsin

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh
.h
ar
vard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglY
HT
MV
0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=o0oLymaypGqFbkf
AR
-
cOnHzq1lBIA47IRaf9HlVhH8c&s=JDoMa8C-
2GQ4TpMIyRj4xZ0XosQFEMbzwvKLY9s5G9M&e=

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
Compliance
HelpLine at
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.
or
g_
complianceline&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgs
pw
4Y
&r=RqvEwdmcEg_aWsE7PBL80w&m=o0oLymaypGqFbkfAR-
cOnHzq1lBIA47IRaf9HlVhH8c&s=4ORZf53F92dPjiBGXnKHpr-
EpQ0EcHphHdwjrXBmi2M&e= . If the e-mail was sent to you
in error
sender
and
properly
dispose of the e-mail.

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh
.h
ar
vard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglY
HT
MV
0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=o0oLymaypGqFbkf
AR
-
cOnHzq1lBIA47IRaf9HlVhH8c&s=JDoMa8C-
2GQ4TpMIyRj4xZ0XosQFEMbzwvKLY9s5G9M&e=
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.h
ar
vard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglYHT
MV
0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=OYRCgY8BRpqstbCR3
wn
uPmKgzUIsDM1jpSeXZ5Vq_k4&s=vZuOCZdUz6e6UbqOzq6Wt-
CfJpE_fTmXKmRXAEOva_U&e=

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
Compliance
HelpLine at
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.or
g_
complianceline&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw
4Y
&r=RqvEwdmcEg_aWsE7PBL80w&m=OYRCgY8BRpqstbCR3wnuPmKgzUIsDM1jpSeXZ5V
q_
k4&s=l79g5eOp0ctiFMn0i9TPGz-xgQD77NyKMbK1SskWckA&e= . If the e-mail
was sent to you
in error
and
properly
dispose of the e-mail.

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.h
ar
vard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglYHT
MV
0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=OYRCgY8BRpqstbCR3
wn
uPmKgzUIsDM1jpSeXZ5Vq_k4&s=vZuOCZdUz6e6UbqOzq6Wt-
CfJpE_fTmXKmRXAEOva_U&e=
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.har
vard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV
0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=1p97jFA3j0xKIWnKfnu
9m0d_7s53UXt0ZNl0blCKxNs&s=hnOncrG2_ylJ3FodlXAbE1EVVhUUtXgGEnkiGlXXh8
c&e=

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
HelpLine at
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.org_
complianceline&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y
&r=RqvEwdmcEg_aWsE7PBL80w&m=1p97jFA3j0xKIWnKfnu9m0d_7s53UXt0ZNl0blCKx
Ns&s=GexmzGtdEYAmFIlm6hCmI2663Z-CgUy8UHaLR-K7C2M&e= . If the e-mail
was sent to you
in error
and
properly
dispose of the e-mail.

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.har
vard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV
0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=1p97jFA3j0xKIWnKfnu
9m0d_7s53UXt0ZNl0blCKxNs&s=hnOncrG2_ylJ3FodlXAbE1EVVhUUtXgGEnkiGlXXh8
c&e=

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harvard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=2vVWX9l8uCW6PNDofp_jxzkt51TCVmkFxY2vY-Ag_iM&s=GO_IQm-SiVRVkbf2CjC0vitbE36m5J11HMxymoSucXI&e=

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
HelpLine at
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.org_complianceline&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=2vVWX9l8uCW6PNDofp_jxzkt51TCVmkFxY2vY-Ag_iM&s=IjgRll5-M3Zti1umbPJ31L6xeflAsxz9YUcZS2jnsyE&e=
. If the e-mail was sent to you
in error
properly
dispose of the e-mail.

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harvard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=2vVWX9l8uCW6PNDofp_jxzkt51TCVmkFxY2vY-Ag_iM&s=GO_IQm-SiVRVkbf2CjC0vitbE36m5J11HMxymoSucXI&e=

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harvard.edu_mailman_listinfo_freesurfer&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=JtHeh4F36Zz1ELE7LnYzZXcblTZGl5bubrruLBAzfrw&s=N7bPtrlGX5UKHsj87HzubSjQ5VXnkSpEuYwo_I-ypJU&e=

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
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.org_complianceline&d=DwIGaQ&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=RqvEwdmcEg_aWsE7PBL80w&m=JtHeh4F36Zz1ELE7LnYzZXcblTZGl5bubrruLBAzfrw&s=4RDz2B3bkbGv045ePFVlaXOUhwU-3UOmzh11Xp8sYJc&e=
. If the e-mail was sent to you in error
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
http://www.partners.org/complianceline . If the e-mail was sent to you in error