Hi Doug,

I know I'm reviving an old question. It seems to me that the variance of the errors estimated the way you are proposing below (i.e. using the residuals provided by selxavg3-sess) is biased in the sense that the residuals are not whitened (i.e. they are not independent becasue there is a temporal correlation), and that I could  make an incorrect inference because of that. Am I right? If so, could you perhaps suggest a way of correcting for that?


Thank you very much,
Pablo


On Fri, Nov 12, 2010 at 11:03 AM, Douglas N Greve <greve@nmr.mgh.harvard.edu> wrote:

The residuals are not saved by default, but you can tell selxavg3-sess to save them by adding the -svres flag. By variance I mean the  temporal variance of the mean waveform of the residuals. The t that you want is given by:

t = ces/sqrt(rvar * C'*inv(X'*X)*C)

where ces is the average ces over the ROI, the rvar is the variance described above, X is the design matrix, and C is the contrast matrix. Both of these are in the X.mat matrix.

doug

Pablo Polosecki wrote:
Oh, thank you. I am a little bit lost now. Could you clarify a little bit more for me? Could you tell where the residuals are stored?
By variance of the residuals you mean variance across voxels in the ROI?
What is the efficiency of the contrast?


On Thu, Nov 11, 2010 at 12:15 PM, Douglas N Greve <greve@nmr.mgh.harvard.edu <mailto:greve@nmr.mgh.harvard.edu>> wrote:

   That's actually not the right way to do it either. You need to get
   the residuals for the ROI, average the residuals, compute the
   variance of the average residual. Then divide this by the
   efficiency for the contrast, then take the sqrt() of this number.
   This is the standard error of the ces. Then compute the average
   ces over the ROI. The t is then the average  ces/standard error.

   doug

   Pablo Polosecki wrote:

       Well, that is bad (beacuse there is a bug) and good (because
       now it is known) at the same time.
       I wanted to estimate a p-value for a group of voxels of
       interest for a certain contrast in my analysis. Instead of
       averaging the p values for these voxels, I thought it would
       make more sense to calculate the average t statistic for the
       voxels and then estimate the p-value for the group of voxels
       myself using tcdf function in matlab. So, I guess I need the t
       values for that, unless I can think of a workaround, which so
       far I couldn't.
       Best,
       Pablo

       On Thu, Nov 11, 2010 at 11:57 AM, Douglas N Greve
       <greve@nmr.mgh.harvard.edu <mailto:greve@nmr.mgh.harvard.edu>
       <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>> wrote:

          Hi Pablo, you have found a bug in FSFAST in which the values in
          the t.nii file are actually the sqrt of the p-values. I
       have fixed
          it in our code base and it will be in the next version. Do you
          actually need the t-values?

          thanks!

          doug

          Pablo Polosecki wrote:

              I understand the X.mat contains the variable DOF which
       tells
              me the degrees of freedom for the analysis, right? In
       my case
              it is 5915. This is what I get when I load X.mat into a
              structure named 'x':

              x =

                       DoSynth: 0
                      UseFloat: 0
                     SynthSeed: -1
                         flac0: [1x1 struct]
                       runflac: [1x21 struct]
                             X: [6048x133 double]
                           DOF: 5915
                           rfm: [1x1 struct]
                    yrun_randn: []
                 RescaleFactor: 5.6510
                     ErrCovMtx: 0
                        acfseg: [1x1 struct]
                      acfsegmn: [6048x1 double]
                    nrho1segmn: 0.1456
                             W: [6048x6048 double]



              On Thu, Nov 11, 2010 at 11:35 AM, Douglas N Greve
              <greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
       <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>> wrote:

                 what is your dof?

                 Pablo Polosecki wrote:

                     Oh, sure. It is:


                     t.vol(test_voxel_number)

                     ans =

                       -0.6368


                     On Thu, Nov 11, 2010 at 10:25 AM, Douglas N Greve
                     <greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>>> wrote:

                        sorry, I meant what is the actual value of
       the t in
                        t.vol(test_voxel_number)?

                        Pablo Polosecki wrote:

                            Firstly, thank you for the quickyresponse.

                            t.vol is the t-volume, loaded from t.nii
       using
              the MRIread
                            function (i.e. t=MRIread('t.nii');).
              test_voxel_number
                     is just
                            some voxel of the volume that I'm using as an
              example
                     in this
                            sanity check  (I set it to 4000 in the sample
              code but it
                            could have been anything else). I'm using
                            -(abs(t.vol(test_voxel_number)
                            )) because that is how I think the p-value is
                     calculated from
                            the t-statistic is a 2 tailed test.  (See for
              instance the
                            matlab code of the built-in ttest.m function
              where you
                     have p
                            = 2 * tcdf(-abs(tval), df)  with df being the
              degrees of
                            freedom.)  Still if I used the
       alternative you
              sugggest,
                            without the minus sign, I get:

                                          my_pval=-log10(2*tcdf((abs(t.vol(test_voxel_number))),
                     x.DOF))

                            my_pval =

                              -0.1690

                            While I still have the stored p-value of

                            stored_pval =

                              -0.4055


                            Thanks again!
                                     On Thu, Nov 11, 2010 at 10:02 AM,
              Douglas N Greve
                            <greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>>
                            <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>
                            <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>>>> wrote:

                               what is t.vol(test_voxel_number)? Why
       do you use
                               -(abs(t.vol(test_voxel_number)))
       instead of
                               +(abs(t.vol(test_voxel_number)))?

                               doug

                               Pablo Polosecki wrote:

                                   Dear experts,

                                   For different reasons I found
       myself double
                     checking the
                                   relationship between t-values in t.nii
              and p-values
                            stored in
                                   sig.nii. If I use the following
       matlab code I
                     thought
                            that I
                                   should get the values of my_pval and
              stored_pval
                     to be the
                                   same (except perhaps for the sign):

                                                 cd(fullfile(basedir,session,'bold',anal,contrast))
                                   x=load('../X.mat')
                                   t=MRIread('t.nii');
                                   sig=MRIread('sig.nii');
                                   test_voxel_number=4000;
                                                        my_pval=-log10(2*tcdf(-(abs(t.vol(test_voxel_number))),
                            x.DOF))
                                   stored_pval=sig.vol(test_voxel_number)



                                   However I get:
                                   stored_pval =

                                     -0.4055

                                   my_pval =

                                      0.2804

                                   Am I doing something wrong here? My
              FreeSurfer
                     version
                            is 4.5
                                   Thank you!

                                   --         Pablo Polosecki
                                   Graduate Fellow
                                   Laboratory of Neural Systems
                                   The Rockefeller University
                                   1230 York Avenue, Box 9
                                   New York, NY 10065



                                                               ------------------------------------------------------------------------

                                                 _______________________________________________
                                   Freesurfer mailing list
                                   Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>
              <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>>
                     <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>
              <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>>>
                            <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>
              <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>>
                     <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>
              <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>>>>
                                          <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>
              <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>>
                     <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>
              <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>>>
                            <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>
              <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>>
                     <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>
              <mailto:Freesurfer@nmr.mgh.harvard.edu
       <mailto:Freesurfer@nmr.mgh.harvard.edu>>>>>

                                                               https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


                               --     Douglas N. Greve, Ph.D.
                               MGH-NMR Center
                               greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>
                            <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>>
                            <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>
                            <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>>>

                               Phone Number: 617-724-2358 Fax:
       617-726-7422

                               Bugs:
              surfer.nmr.mgh.harvard.edu/fswiki/BugReporting
       <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
              <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
                            <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
                                          <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
                                             <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>

                               FileDrop:
                                          www.nmr.mgh.harvard.edu/facility/filedrop/index.html
       <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                     <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                                   <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                                                 <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                                                    <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>




                               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.



                        --     Douglas N. Greve, Ph.D.
                        MGH-NMR Center
                        greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
                     <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>>
                        Phone Number: 617-724-2358 Fax: 617-726-7422

                        Bugs:
       surfer.nmr.mgh.harvard.edu/fswiki/BugReporting
       <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
              <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
                            <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
                               <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
                        FileDrop:
                            www.nmr.mgh.harvard.edu/facility/filedrop/index.html
       <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                     <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                                   <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                                      <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>



                 --     Douglas N. Greve, Ph.D.
                 MGH-NMR Center
                 greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
              <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>>
                 Phone Number: 617-724-2358 Fax: 617-726-7422

                 Bugs: surfer.nmr.mgh.harvard.edu/fswiki/BugReporting
       <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
              <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
                 <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
                 FileDrop:
              www.nmr.mgh.harvard.edu/facility/filedrop/index.html
       <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                     <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
                        <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>



          --     Douglas N. Greve, Ph.D.
          MGH-NMR Center
          greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>
       <mailto:greve@nmr.mgh.harvard.edu
       <mailto:greve@nmr.mgh.harvard.edu>>
          Phone Number: 617-724-2358 Fax: 617-726-7422

          Bugs: surfer.nmr.mgh.harvard.edu/fswiki/BugReporting
       <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
          <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
          FileDrop:
       www.nmr.mgh.harvard.edu/facility/filedrop/index.html
       <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>
          <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>



   --     Douglas N. Greve, Ph.D.
   MGH-NMR Center
   greve@nmr.mgh.harvard.edu <mailto:greve@nmr.mgh.harvard.edu>
   Phone Number: 617-724-2358 Fax: 617-726-7422

   Bugs: surfer.nmr.mgh.harvard.edu/fswiki/BugReporting
   <http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting>
   FileDrop: www.nmr.mgh.harvard.edu/facility/filedrop/index.html
   <http://www.nmr.mgh.harvard.edu/facility/filedrop/index.html>



--
Douglas N. Greve, Ph.D.
MGH-NMR Center
greve@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