Hi Doug,
   Thanks for the help!  I think I figured out the issue based on your response. 
1) I created a template to use for this group and named it fsaverage (including creating monte carlo simulations) for simplicity of integrating with freesurfer as I am newer to it.  This is why the sizes didn't match up as you expected
    but the mri_glmfit still ran. 

2) I deleted the folder and restarted without background processes.  The error became apparent.  Of my covariates (2 fix factors and 3 quantitative), not all were orthogonal.  In looking at the error more, it seems that i need to add the
--perm-force if I wanted the simulation to run, however the background processes were not aware of this error and kept polling as you mentioned.

This brings me to a new but related issue.  From what I have read in other freesurfer posts, it is statistically incorrect to use --perm-force for non-orthogonal covariates (or continuous covariates).  I am unsure how to proceed.
a) If I ran permutation testing (to overcome the issue of incorrect smoothness estimations from the gaussian distribution assumption), then I run into the issue of non-orthogonal covariates.  Is there a way to orthogonalize the data in
    freesurfer, or a solution to this issue?

b) If orthogonalizing is difficult to implement, another option is running Qdec with the montecarlo simulation at a more conservative p value (p< 0.001).  From your previous posts, the testing at this p value for 10mm seems to meet the 5% FPR.  One question is if the non-orthogonal data affects this analysis as well for this model?

Thanks,
Ajay

On Thu, Aug 25, 2016 at 12:18 PM, Ajay Kurani <dr.ajay.kurani@gmail.com> wrote:
Hi Freesurfer Experts,
   I am trying to use freesurfer's mri_glmfit-sim tool to run permutation testing on cortical thickness data (as recommended by Doug in my previous post: http://www.mail-archive.com/freesurfer%40nmr.mgh.harvard.edu/msg48653.html )

Most of the tutorials I found were not related to permutation testing so the subsequent steps may be incorrect.  Please let me know where I go wrong...

1) I first ran QDec to generate a folder for the analysis which would create the subsequent fsgd and y files needed my mri_glmfit-sim.  I am running both left and right hemisphere cortical thickness analysis with 10mm smoothing.  The following is for just the left hemisphere.   Note I am doing a 3 group comparison, but for this 2 group ttest I manually centered the data based on the 3 group mean for age and education. 

2) I ran the following command:
/mri_glmfit-sim --glmdir ./HCvsPAT_lh_thickness_10mm/ --sim perm 10000 2 perm.abs.2 --sim-sign abs --bg 16

Prior to running the command above, from the y.fsdg file I deleted the fwhm estimate of 13mm since this was not correctly estimated (ACF with long tails).  I assumed that by removing this estimate, it would force the permutation test to calculate based on the data but when looking at the log output I see the following which says fwhm 0:

cmdline mri_glmfit.bin --C ./HCvsPAT_lh_thickness_10mm//tmp.mri_glmfit-sim-19468/lh-Avg-Intercept-thickness.mtx --C ./HCvsPAT_lh_thickness_10mm//tmp.mri_glmfit-sim-19468/lh-Diff-Male-Female-Intercept-thickness.mtx --C ./HCvsPAT_lh_thickness_10mm//tmp.mri_glmfit-sim-19468/lh-Diff-PD-MCI-Intercept-thickness.mtx --C ./HCvsPAT_lh_thickness_10mm//tmp.mri_glmfit-sim-19468/lh-X-Gender-Group-Intercept-thickness.mtx --sim perm 625 2 ./HCvsPAT_lh_thickness_10mm//csd/perm.abs.2.j013 --y /home/akurani/Documents/PPMI/FS_Final/qdec/HCvsPAT_lh_thickness_10mm/y.mgh --mask ./HCvsPAT_lh_thickness_10mm//mask.mgh --sim-sign abs --fwhm 0 --fsgd ./HCvsPAT_lh_thickness_10mm//y.fsgd dods --surf fsaverage lh white --sim-done ./HCvsPAT_lh_thickness_10mm//csd/poll/done.perm.abs.2.j013

3)I started this a few days ago on a 16 core machine and it is still running in the terminal.  I have 150 subjects in the analysis and specified 10000 iterations.  In the terminal I assumed when I reach Poll 10000 it would be complete but currently I am at : Poll 13341 job 1 Thu Aug 25 12:03:51 CDT 2016

Questions:
a) I am curious, is this going to run 10,000 simulations X 150 patients or does the Poll number not have anything to do with the number of iterations it is on? 


b) Did I run this procedure correctly?  Was I incorrect in deleting the fwhm estimate from y.fsgd file generated by Qdec even though we know the estimate is incorrect since smoothness assumed a gaussian distribution as opposed to gaussian with heavy tails

c) I noticed in the logfile the following warning:
INFO: gd2mtx_method is dods
Computing normalized matrix
Normalized matrix condition is 5.65727
Matrix condition is 935.597
Found 136777 voxels in mask
Reshaping mriglm->mask...
search space = 89675.729228
ERROR: design matrix is not orthogonal, cannot be used with permutation.
If this something you really want to do, run with --perm-force
Poll 2 job 1 Tue Aug 23 22:58:18 CDT 2016

I am not sure if this means my simulation is incorrect?

Thanks,
Ajay